Datei: NDOEnhancer/NDOEnhancer/Enhancer/NDOAssemblyChecker.cs

Last Commit (dbc6a64)
1 //
2 // Copyright (c) 2002-2019 Mirko Matytschak
3 // (www.netdataobjects.de)
4 //
5 // Author: Mirko Matytschak
6 //
7 // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
8 // documentation files (the "Software"), to deal in the Software without restriction, including without limitation
9 // the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
10 // Software, and to permit persons to whom the Software is furnished to do so, subject to the following
11 // conditions:
12
13 // The above copyright notice and this permission notice shall be included in all copies or substantial portions
14 // of the Software.
15 //
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
17 // TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
19 // CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 // DEALINGS IN THE SOFTWARE.
21
22 using System;
23 using System.Diagnostics;
24 using System.IO;
25 using System.Linq;
26 using Mono.Cecil;
27
28 namespace NDOEnhancer
29 {
30 ····public class NDOAssemblyChecker
31 ····{
32 ········public static bool IsEnhanced( string targetFileName )
33 ········{
34 ············if (!File.Exists( targetFileName ))
35 ············{
36 ················Debug.WriteLine( "NDOAssemblyChecker: DLL doesn't exist: " + targetFileName );
37 ················return false;
38 ············}
39 var module = ModuleDefinition. ReadModule( targetFileName ) ;
40 ············return module.Assembly.CustomAttributes.Any( a => a.AttributeType.Name == "NDOEnhancedAttribute" );
41 ········}
42
43 ········public static string GetAssemblyName(string targetFileName)
44 ········{
45 ············if (!File.Exists( targetFileName ))
46 ············{
47 ················Debug.WriteLine( "NDOAssemblyChecker: DLL doesn't exist: " + targetFileName );
48 ················return String.Empty;
49 ············}
50 var module = ModuleDefinition. ReadModule( targetFileName ) ;
51 ············return module.Assembly.FullName;
52 ········}
53 ····}
54 }
55
New Commit (fa8b781)
1 //
2 // Copyright (c) 2002-2019 Mirko Matytschak
3 // (www.netdataobjects.de)
4 //
5 // Author: Mirko Matytschak
6 //
7 // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
8 // documentation files (the "Software"), to deal in the Software without restriction, including without limitation
9 // the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
10 // Software, and to permit persons to whom the Software is furnished to do so, subject to the following
11 // conditions:
12
13 // The above copyright notice and this permission notice shall be included in all copies or substantial portions
14 // of the Software.
15 //
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
17 // TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
19 // CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 // DEALINGS IN THE SOFTWARE.
21
22 using System;
23 using System.Diagnostics;
24 using System.IO;
25 using System.Linq;
26 using Mono.Cecil;
27
28 namespace NDOEnhancer
29 {
30 ····public class NDOAssemblyChecker
31 ····{
32 ········public static bool IsEnhanced( string targetFileName )
33 ········{
34 ············if (!File.Exists( targetFileName ))
35 ············{
36 ················Debug.WriteLine( "NDOAssemblyChecker: DLL doesn't exist: " + targetFileName );
37 ················return false;
38 ············}
39 using var module = ModuleDefinition. ReadModule( targetFileName ) ;
40 ············return module.Assembly.CustomAttributes.Any( a => a.AttributeType.Name == "NDOEnhancedAttribute" );
41 ········}
42
43 ········public static string GetAssemblyName(string targetFileName)
44 ········{
45 ············if (!File.Exists( targetFileName ))
46 ············{
47 ················Debug.WriteLine( "NDOAssemblyChecker: DLL doesn't exist: " + targetFileName );
48 ················return String.Empty;
49 ············}
50 using var module = ModuleDefinition. ReadModule( targetFileName ) ;
51 ············return module.Assembly.FullName;
52 ········}
53 ····}
54 }
55