Esempio n. 1
0
        private static Type CreateType()
        {
            string          name            = string.Concat(typeof(DataFunctionsRegistration).Namespace, ".Functions");
            AssemblyBuilder dynamicAssembly = AppDomain.CurrentDomain.DefineDynamicAssembly(new AssemblyName {
                Name = name
            }, AssemblyBuilderAccess.RunAndSave);
            ModuleBuilder module              = dynamicAssembly.DefineDynamicModule(nameof(Module), string.Concat(name, ".dll"));
            TypeBuilder   typeBuilder         = module.DefineType(name, TypeAttributes.Public | TypeAttributes.Class | TypeAttributes.Abstract | TypeAttributes.Sealed);
            Expression    functionsExpression = Expression.Call(
                Expression.Field(
                    null,
                    typeof(Container).GetField(nameof(Container.Instance), BindingFlags.Public | BindingFlags.Static)
                    ),
                nameof(IWindsorContainer.Resolve),
                new[] { typeof(IDataFunctions) }
                );

            foreach (MethodInfo method in typeof(IDataFunctions).GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly))
            {
                DataFunctionsRegistration.CreateMethod(typeBuilder, method, functionsExpression);
            }
            return(typeBuilder.CreateType());
        }
Esempio n. 2
0
 void IExcelAddIn.AutoOpen()
 {
     Container.Instance.Install(FromAssembly.InThisApplication());
     DataFunctionsRegistration.RegisterDataFunctions();
     IntelliSenseServer.Install();
 }