static NativeLibraryBuilder() { AssemblyBuilder = AssemblyBuilder.DefineDynamicAssembly ( new AssemblyName(DynamicAssemblyName), AssemblyBuilderAccess.Run ); #if DEBUG var dbgType = typeof(DebuggableAttribute); var dbgConstructor = dbgType.GetConstructor(new[] { typeof(DebuggableAttribute.DebuggingModes) }); var dbgModes = new object[] { DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.Default }; var dbgBuilder = new CustomAttributeBuilder(dbgConstructor, dbgModes); AssemblyBuilder.SetCustomAttribute(dbgBuilder); #endif ModuleBuilder = AssemblyBuilder.DefineDynamicModule(DynamicModuleName); TypeCache = new ConcurrentDictionary <GeneratedImplementationTypeIdentifier, Type> ( new LibraryIdentifierEqualityComparer() ); TransformerRepository = new TypeTransformerRepository(); Default = new NativeLibraryBuilder ( GenerateDisposalChecks | EnableDllMapSupport ); }
protected NativeLibraryBase ( [NotNull] string path, [NotNull] Type interfaceType, ImplementationOptions options, [NotNull] TypeTransformerRepository transformerRepository ) { Options = options; TransformerRepository = transformerRepository; _libraryHandle = PlatformLoader.LoadLibrary(path); _path = path; _interfaceType = interfaceType; }
private TInterface CreateAnonymousImplementationInstance <TInterface> ( [NotNull] Type finalType, [NotNull] string library, ImplementationOptions options, [NotNull] TypeTransformerRepository transformerRepository ) { return((TInterface)Activator.CreateInstance ( finalType, library, typeof(TInterface), options, transformerRepository )); }