@@ -10,7 +10,7 @@ namespace SER.Code.MethodSystem;
1010public static class MethodIndex
1111{
1212 private static readonly Dictionary < string , Method > NameToMethodIndex = [ ] ;
13- private static readonly Dictionary < IDependOnFramework . Type , List < Type > > FrameworkDependentMethods = [ ] ;
13+ private static readonly Dictionary < IDependOnFramework . Type , List < Method > > FrameworkDependentMethods = [ ] ;
1414
1515 /// <summary>
1616 /// Initializes the method index.
@@ -41,17 +41,15 @@ public static void AddAllDefinedMethodsInAssembly(Assembly? assembly = null)
4141 assembly ??= Assembly . GetCallingAssembly ( ) ;
4242 var definedMethods = assembly . GetTypes ( )
4343 . Where ( t => t . IsClass && ! t . IsAbstract && typeof ( Method ) . IsAssignableFrom ( t ) )
44+ . Select ( t => Activator . CreateInstance ( t ) as Method )
4445 . Where ( t =>
4546 {
46- if ( ! typeof ( IDependOnFramework ) . IsAssignableFrom ( t ) )
47+ if ( t is not IDependOnFramework framework )
4748 return true ;
4849
49- var framework = t . CreateInstance < IDependOnFramework > ( ) . DependsOn ;
50- FrameworkDependentMethods . AddOrInitListWithKey ( framework , t ) ;
50+ FrameworkDependentMethods . AddOrInitListWithKey ( framework . DependsOn , t ) ;
5151 return false ;
52-
5352 } )
54- . Select ( t => Activator . CreateInstance ( t ) as Method )
5553 . ToList ( ) ;
5654
5755 foreach ( var method in definedMethods . OfType < Method > ( ) )
@@ -103,7 +101,7 @@ internal static void LoadMethodsOfFramework(IDependOnFramework.Type framework)
103101 {
104102 foreach ( var method in FrameworkDependentMethods . TryGetValue ( framework , out var methods ) ? methods : [ ] )
105103 {
106- AddMethod ( ( Method ) Activator . CreateInstance ( method ) ) ;
104+ AddMethod ( method ) ;
107105 }
108106 }
109107
0 commit comments