1+ #region README
2+
3+ /*
4+ * README
5+ *
6+ * Current Thread User : GUOCOLAND\wangyucai
7+ * Machine Name : GLCHQWYCWINW7
8+ * Visual Studio : Microsoft Visual Studio 2010 Ultimate Edition
9+ * Create Time : 2014-11-24 9:39:52
10+ * Common Language Runtime : 4.0.30319.18444
11+ * Minimum .Net Framework Version : 4.0
12+ *
13+ * SourcePro Studio 2014
14+ * Project Url : https://github.com/SourceproStudio/CodeTemplates
15+ * Home Page Url : https://github.com/SourceproStudio
16+ * E-mail Address : MasterDuner@yeah.net or Yucai.Wang-Public@outlook.com
17+ * QQ : 180261899
18+ */
19+
20+ #endregion
21+
22+ using System ;
23+ using System . Collections . Generic ;
24+ using System . IO ;
25+ using System . Linq ;
26+
27+ namespace SourcePro . Csharp . Lab . Templates
28+ {
29+ /// <summary>
30+ /// <para>
31+ /// 提供了用于查找模板的方法。
32+ /// </para>
33+ /// <para>
34+ /// Namespace : <see cref="SourcePro.Csharp.Lab.Templates"/>
35+ /// </para>
36+ /// <para>
37+ /// Type : <see cref="TemplateFinder"/>
38+ /// </para>
39+ /// <para>
40+ /// The minimum .Net Framework version requirements : 4.0
41+ /// </para>
42+ /// <para>
43+ /// <see cref="TemplateFinder"/> is a static type !
44+ /// </para>
45+ /// </summary>
46+ /// <remarks>
47+ /// <see cref="TemplateFinder"/> is a static type !
48+ /// </remarks>
49+ /// <seealso cref="SourcePro.Csharp.Lab.Templates"/>
50+ public static class TemplateFinder
51+ {
52+ private static readonly DirectoryInfo TemplatesDir = new DirectoryInfo ( Path . Combine ( Environment . GetFolderPath ( Environment . SpecialFolder . MyDocuments ) , @"SourcePro Studio\AssemblyInfoManager\Templates" ) ) ;
53+
54+ #region GetAllTemplates
55+ /// <summary>
56+ /// 获取所有模板。
57+ /// </summary>
58+ /// <returns>动态类型数组。</returns>
59+ static public dynamic [ ] GetAllTemplates ( )
60+ {
61+ List < dynamic > output = new List < dynamic > ( ) ;
62+ if ( TemplatesDir . Exists )
63+ {
64+ var enumerator = from item in TemplatesDir . GetFiles ( "*.t" , SearchOption . TopDirectoryOnly )
65+ orderby item . CreationTime descending
66+ select item ;
67+ foreach ( var item in enumerator )
68+ output . Add ( new
69+ {
70+ Name = item . Name ,
71+ Path = item . FullName ,
72+ CreateTime = item . CreationTime
73+ } ) ;
74+ }
75+ return output . ToArray ( ) ;
76+ }
77+ #endregion
78+
79+ #region DeleteAll
80+ /// <summary>
81+ /// 删除所有模板文件。
82+ /// </summary>
83+ static public void DeleteAll ( )
84+ {
85+ try
86+ {
87+ FileInfo [ ] files = TemplatesDir . GetFiles ( "*.t" ) ;
88+ for ( var i = 0 ; i < files . Length ; i ++ )
89+ {
90+ files [ i ] . Delete ( ) ;
91+ }
92+ }
93+ catch { }
94+ }
95+ #endregion
96+ }
97+ }
98+
99+ /*
100+ * Copyright © 2014 Wang Yucai. All rights reserved.
101+ */
0 commit comments