SosigScript/src/Libraries/LibraryLoader.cs
/// <summary>
/// Loads all the classes with SosigScriptLibraryAttribute in the specified assembly
/// </summary>
/// <param name="asm">Assembly to get types from</param>
Loads all the classes with SosigScriptLibraryAttribute in the specified assembly
Loads all the classes with SosigScriptLibraryAttribute in the specified assembly
private void LoadAssemblyTypes(Assembly asm)
        {
            var typeList = new SosigScriptTypeList() { Source = asm };
            foreach (var type in asm.SafeGetTypes())
            {
                if (!type.IsClass) continue;
                if (type.BaseType != typeof(SosigScriptTypeList)) continue;
                var types = new Type[] { typeof(SosigScriptTypeList) };
                var ctor = type.GetConstructor
                (
                    BindingFlags.Instance | BindingFlags.Public,
                    null,
                    CallingConventions.HasThis,
                    types,
                    null
                );
                ctor?.Invoke(new object[] { typeList });
            }
            LoadedTypes.AddItem(typeList);
        }
private void LoadAssemblyTypes ( Assembly asm ) { var typeList = new SosigScriptTypeList ( ) { Source = asm } ; foreach ( var type in asm . SafeGetTypes ( ) ) { if ( ! type . IsClass ) continue ; if ( type . BaseType != typeof ( SosigScriptTypeList ) ) continue ; var types = new Type [ ] { typeof ( SosigScriptTypeList ) } ; var ctor = type . GetConstructor ( BindingFlags . Instance | BindingFlags . Public , null , CallingConventions . HasThis , types , null ) ; ctor ? . Invoke ( new object [ ] { typeList } ) ; } LoadedTypes . AddItem ( typeList ) ; }
Loads all the classes with SosigScriptLibraryAttribute in the specified assembly
Loads all the classes with SosigScriptLibraryAttribute in the specified assembly
asm
Assembly
Assembly to get types from
Assembly to get types from