10
10
public class AssemblyVersionInfoTemplates
11
11
{
12
12
static readonly IDictionary < string , FileInfo > assemblyInfoSourceList ;
13
+ static readonly IDictionary < string , string > assemblyInfoAddFormats ;
13
14
14
15
static AssemblyVersionInfoTemplates ( )
15
16
{
16
17
assemblyInfoSourceList = GetEmbeddedVersionAssemblyFiles ( ) . ToDictionary ( k => k . Extension , v => v ) ;
18
+ // TODO: It would be nice to do something a bit more clever here, like reusing the VersionAssemblyInfo.* templates somehow. @asbjornu
19
+ assemblyInfoAddFormats = new Dictionary < string , string >
20
+ {
21
+ { ".cs" , "[assembly: {0}]" } ,
22
+ { ".vb" , "<assembly: {0}>" } ,
23
+ { ".fs" , "[<assembly: {0}>]" }
24
+ } ;
17
25
}
18
26
19
27
public static string GetAssemblyInfoTemplateFor ( string assemblyInfoFile )
@@ -35,18 +43,19 @@ public static string GetAssemblyInfoAddFormatFor([NotNull] string fileExtension)
35
43
if ( fileExtension == null )
36
44
throw new ArgumentNullException ( "fileExtension" ) ;
37
45
38
- // TODO: It would be nice to do something a bit more clever here, like reusing the VersionAssemblyInfo.* templates somehow. @asbjornu
39
- switch ( fileExtension . ToLowerInvariant ( ) )
40
- {
41
- case ".cs" :
42
- return "[assembly: {0}]" ;
43
- case ".vb" :
44
- return "<assembly: {0}>" ;
45
- case ".fs" :
46
- return "[<assembly: {0}>]" ;
47
- }
46
+ string assemblyInfoAddFormat ;
47
+ if ( ! assemblyInfoAddFormats . TryGetValue ( fileExtension , out assemblyInfoAddFormat ) )
48
+ throw new NotSupportedException ( string . Format ( "Unknown file extension '{0}'." , fileExtension ) ) ;
49
+
50
+ return assemblyInfoAddFormat ;
51
+ }
52
+
53
+ public static bool IsSupported ( [ NotNull ] string fileExtension )
54
+ {
55
+ if ( fileExtension == null )
56
+ throw new ArgumentNullException ( "fileExtension" ) ;
48
57
49
- throw new NotSupportedException ( string . Format ( "Unknown file extension '{0}'." , fileExtension ) ) ;
58
+ return assemblyInfoAddFormats . Keys . Contains ( fileExtension , StringComparer . OrdinalIgnoreCase ) ;
50
59
}
51
60
52
61
private static IEnumerable < FileInfo > GetEmbeddedVersionAssemblyFiles ( )
0 commit comments