Пример #1
0
 public PluginLoadOptions(
     IAssemblyScanner <T> assemblyScanner,
     ISharedServicesProvider <T> sharedServicesProvider,
     IRemotePluginActivator activator,
     IParameterConverter parameterConverter,
     IResultConverter resultConverter,
     IPluginAssemblyLoader <T> assemblyLoader,
     IProxyCreator <T> proxyCreator,
     IHostTypesProvider hostTypesProvider,
     IRemoteTypesProvider <T> remoteTypesProvider,
     IRuntimePlatformContext runtimePlatformContext,
     IAssemblySelector <T> assemblySelector,
     IPluginSelector <T> pluginSelector
     )
 {
     this.assemblyScanner        = assemblyScanner;
     this.sharedServicesProvider = sharedServicesProvider;
     this.activator              = activator;
     this.parameterConverter     = parameterConverter;
     this.resultConverter        = resultConverter;
     this.assemblyLoader         = assemblyLoader;
     this.proxyCreator           = proxyCreator;
     this.hostTypesProvider      = hostTypesProvider;
     this.remoteTypesProvider    = remoteTypesProvider;
     this.runtimePlatformContext = runtimePlatformContext;
     this.assemblySelector       = assemblySelector;
     this.pluginSelector         = pluginSelector;
 }
        internal static void Build(Dictionary <MonikerHelper.MonikerAttribute, string> propertyTable, ref Guid riid, IntPtr ppv)
        {
            string str;

            if (IntPtr.Zero == ppv)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("ppv");
            }
            Marshal.WriteIntPtr(ppv, IntPtr.Zero);
            IProxyCreator proxyCreator = null;

            if (propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.Wsdl, out str))
            {
                proxyCreator = new WsdlServiceChannelBuilder(propertyTable);
            }
            else if (propertyTable.TryGetValue(MonikerHelper.MonikerAttribute.MexAddress, out str))
            {
                proxyCreator = new MexServiceChannelBuilder(propertyTable);
            }
            else
            {
                proxyCreator = new TypedServiceChannelBuilder(propertyTable);
            }
            IProxyManager proxyManager = new ProxyManager(proxyCreator);

            Marshal.WriteIntPtr(ppv, OuterProxyWrapper.CreateOuterProxyInstance(proxyManager, ref riid));
        }
Пример #3
0
        public PluginLoadOptionsBuilder <T> WithDefaultOptions(string pluginPath = null)
        {
            if (String.IsNullOrEmpty(pluginPath))
            {
                pluginPath = Path.Join(GetLocalExecutionPath(), "Plugins");
            }

            this.pluginPathProvider     = new DefaultPluginPathProvider <T>(pluginPath);
            this.dependencyPathProvider = new DependencyPathProvider <T>(pluginPath);

            this.runtimePlatformContext = new RuntimePlatformContext();
            this.ScanForAssemblies(composer =>
                                   composer.WithDefaultOptions <DefaultAssemblyScanner <T>, DefaultAssemblyScannerOptions <T> >());

            this.pluginAssemblyNameProvider = new PluginAssemblyNameProvider <T>($"{typeof(T).Name}.dll");
            this.sharedServicesProvider     = new DefaultSharedServicesProvider <T>(new ServiceCollection());
            this.activator    = new DefaultRemotePluginActivator <T>(this.sharedServicesProvider);
            this.proxyCreator = new PluginProxyCreator <T>();

            // Use System.Text.Json in 3.0
#if NETCORE3_0
            this.parameterConverter = new JsonSerializerParameterConverter();
            this.resultConverter    = new JsonSerializerResultConverter();
            this.assemblyLoaderType = typeof(DefaultAssemblyLoaderWithNativeResolver <T>);
#endif
            // Use Newtonsoft.Json in 2.1
#if NETCORE2_1
            this.parameterConverter = new NewtonsoftParameterConverter();
            this.resultConverter    = new NewtonsoftResultConverter();
            this.assemblyLoaderType = typeof(DefaultAssemblyLoader <T>);
#endif
            this.assemblySelector    = new DefaultAssemblySelector <T>();
            this.assemblyLoadOptions = new DefaultAssemblyLoadOptions <T>(
                PluginPlatformVersion.Empty(),
                false,
                NativeDependencyLoadPreference.PreferInstalledRuntime);

            this.probingPathsProvider = new ProbingPathsProvider <T>();

            var hostTypesProvider = new HostTypesProvider();
            hostTypesProvider.AddHostType(typeof(Prise.Plugin.PluginAttribute)); // Add the Prise.Infrastructure assembly to the host types
            hostTypesProvider.AddHostType(typeof(ServiceCollection));            // Adds the BuildServiceProvider assembly to the host types
            this.hostTypesProvider = hostTypesProvider;

            var remoteTypesProvider = new RemoteTypesProvider <T>();
            remoteTypesProvider.AddRemoteType(typeof(T)); // Add the contract to the remote types, so that we can have backwards compatibility
            this.remoteTypesProvider = remoteTypesProvider;

            this.pluginSelector               = new DefaultPluginSelector <T>();
            this.depsFileProviderType         = typeof(DefaultDepsFileProvider <T>);
            this.pluginDependencyResolverType = typeof(DefaultPluginDependencyResolver <T>);
            // Typically used for downloading and storing plugins from the network, but it could be useful for caching local plugins as well
            this.tempPathProviderType = typeof(UserProfileTempPathProvider <T>);

            this.nativeAssemblyUnloaderType = typeof(DefaultNativeAssemblyUnloader);
            this.hostFrameworkProviderType  = typeof(HostFrameworkProvider);

            return(this);
        }
Пример #4
0
        /// <summary>
        /// Create proxy js files
        /// </summary>
        /// <param name="svTypes"></param>
        /// <param name="itTypes"></param>
        public void GenerateProxy(List <Type> svTypes, List <Type> itTypes)
        {
            switch (Config.ProxyType)
            {
            case ProxyOutputType.AngularJs:
                Creator = IocResover.Resolve <AngularJsProxyCreator>();
                break;

            case ProxyOutputType.Angular:
                Creator = IocResover.Resolve <AngularProxyCreator>();
                break;

            default:
                break;
            }
            Creator.CreateProxy(svTypes, itTypes);
        }
Пример #5
0
 void IProxyManager.TearDownChannels()
 {
     lock (this)
     {
         IEnumerator<KeyValuePair<Guid, ComProxy>> enumeratorInterfaces = InterfaceIDToComProxy.GetEnumerator();
         while (enumeratorInterfaces.MoveNext())
         {
             KeyValuePair<Guid, ComProxy> current = enumeratorInterfaces.Current;
             IDisposable comProxy = current.Value as IDisposable;
             if (comProxy == null)
                 Fx.Assert("comProxy should not be null");
             else
                 comProxy.Dispose();
         }
         InterfaceIDToComProxy.Clear();
         proxyCreator.Dispose();
         enumeratorInterfaces.Dispose();
         proxyCreator = null;
     }
 }
Пример #6
0
 void IProxyManager.TearDownChannels()
 {
     lock (this)
     {
         IEnumerator <KeyValuePair <Guid, ComProxy> > enumerator = this.InterfaceIDToComProxy.GetEnumerator();
         while (enumerator.MoveNext())
         {
             KeyValuePair <Guid, ComProxy> current = enumerator.Current;
             IDisposable disposable = current.Value;
             if (disposable != null)
             {
                 disposable.Dispose();
             }
         }
         this.InterfaceIDToComProxy.Clear();
         this.proxyCreator.Dispose();
         enumerator.Dispose();
         this.proxyCreator = null;
     }
 }
Пример #7
0
 void IProxyManager.TearDownChannels()
 {
     lock (this)
     {
         IEnumerator <KeyValuePair <Guid, ComProxy> > enumeratorInterfaces = InterfaceIDToComProxy.GetEnumerator();
         while (enumeratorInterfaces.MoveNext())
         {
             KeyValuePair <Guid, ComProxy> current = enumeratorInterfaces.Current;
             IDisposable comProxy = current.Value as IDisposable;
             if (comProxy == null)
             {
                 Fx.Assert("comProxy should not be null");
             }
             else
             {
                 comProxy.Dispose();
             }
         }
         InterfaceIDToComProxy.Clear();
         proxyCreator.Dispose();
         enumeratorInterfaces.Dispose();
         proxyCreator = null;
     }
 }
 public SameTypeServiceDescriptorConvertHandler(IProxyCreator creator)
 {
     this.creator = creator;
 }
Пример #9
0
 internal ProxyManager(IProxyCreator proxyCreator)
 {
     this.proxyCreator     = proxyCreator;
     InterfaceIDToComProxy = new Dictionary <Guid, ComProxy>();
 }
 public ImplementationTypeServiceDescriptorConvertHandler(IProxyCreator creator)
 {
     this.creator = creator;
 }
Пример #11
0
 public PluginLoadOptionsBuilder <T> WithProxyCreator(IProxyCreator <T> proxyCreator)
 {
     this.proxyCreator = proxyCreator;
     return(this);
 }
Пример #12
0
 internal ProxyManager(IProxyCreator proxyCreator)
 {
     this.proxyCreator = proxyCreator;
     InterfaceIDToComProxy = new Dictionary<Guid, ComProxy>();
 }
 void IProxyManager.TearDownChannels()
 {
     lock (this)
     {
         IEnumerator<KeyValuePair<Guid, ComProxy>> enumerator = this.InterfaceIDToComProxy.GetEnumerator();
         while (enumerator.MoveNext())
         {
             KeyValuePair<Guid, ComProxy> current = enumerator.Current;
             IDisposable disposable = current.Value;
             if (disposable != null)
             {
                 disposable.Dispose();
             }
         }
         this.InterfaceIDToComProxy.Clear();
         this.proxyCreator.Dispose();
         enumerator.Dispose();
         this.proxyCreator = null;
     }
 }