public static void Implement(string entryAssemblyPath, IReadOnlyCollection <PluginMetadata> plugins) { using (var assemblyFile = File.Open(entryAssemblyPath, FileMode.Open, FileAccess.ReadWrite)) { var assembly = AssemblyDefinition.ReadAssembly(assemblyFile, new ReaderParameters { AssemblyResolver = new DirectoryAssemblyResolver(entryAssemblyPath) }); var implementor = new FunctionImplementor(assembly, plugins); foreach (var type in implementor._module.Types.ToList()) { if (type.Name == "FunctionImpl") { implementor._module.Types.Remove(type); } } if (plugins.Any(x => x.ServiceType == ServiceType.MessageHandler)) { var functionType = implementor.CreateServiceFunctionType(); implementor.ImplementCtor(functionType); implementor.ImplementServiceCreateHandler(functionType); } else { var functionType = implementor.CreateHttpFunctionType(); implementor.ImplementCtor(functionType); implementor.ImplementHttpGetServiceKey(functionType); implementor.ImplementHttpGetServiceType(functionType); } assembly.Write(); } }