Пример #1
0
        internal bool RegisterProvidersViaMetaProvider(IMetaProvider provider, FourPartVersion asmVersion, IHostApi request)
        {
            var             found               = false;
            var             metaProviderName    = provider.GetMetaProviderName();
            FourPartVersion metaProviderVersion = provider.GetProviderVersion();

                                                                              if (!_metaProviders.ContainsKey(metaProviderName))
            {
                // Meta Providers can't be replaced at this point
                _metaProviders.AddOrSet(metaProviderName, provider);
            }

                                                                              try {
                provider.InitializeProvider(request.As <IRequest>());
                var metaProvider = provider;
                provider.GetProviderNames().ParallelForEach(name => {
                    // foreach (var name in provider.GetProviderNames()) {
                    var instance = metaProvider.CreateProvider(name);
                    if (instance != null)
                    {
                        // check if it's a Package Provider
                        if (typeof(IPackageProvider).CanDynamicCastFrom(instance))
                        {
                            try {
                                found = found | RegisterPackageProvider(instance.As <IPackageProvider>(), asmVersion, request);
                            } catch (Exception e) {
                                e.Dump();
                            }
                        }

                        // check if it's a Services Provider
                        if (typeof(IArchiver).CanDynamicCastFrom(instance))
                        {
                            try {
                                found = found | RegisterArchiver(instance.As <IArchiver>(), asmVersion, request);
                            } catch (Exception e) {
                                e.Dump();
                            }
                        }

                        if (typeof(IDownloader).CanDynamicCastFrom(instance))
                        {
                            try {
                                found = found | RegisterDownloader(instance.As <IDownloader>(), asmVersion, request);
                            } catch (Exception e) {
                                e.Dump();
                            }
                        }
                    }
                });
            } catch (Exception e) {
                e.Dump();
            }
                                                                              return(found);
        }
Пример #2
0
        internal static bool AcquireProvidersViaMetaProvider(IMetaProvider provider, YieldMetaProvider yieldMetaProvider, YieldPackageProvider yieldPackageProvider, YieldArchiver yieldArchiver, YieldDownloader yieldDownloader, FourPartVersion asmVersion,
                                                             IRequest request)
        {
            var             found               = false;
            var             metaProviderName    = provider.GetMetaProviderName();
            FourPartVersion metaProviderVersion = provider.GetProviderVersion();
            var             reloading           = yieldMetaProvider(metaProviderName, provider, (metaProviderVersion == 0 ? asmVersion : metaProviderVersion), request);

            try {
                provider.InitializeProvider(request);
                var metaProvider = provider;
                Parallel.ForEach(provider.GetProviderNames(), name => {
                    // foreach (var name in provider.GetProviderNames()) {
                    var instance = metaProvider.CreateProvider(name);
                    if (instance != null)
                    {
                        // check if it's a Package Provider
                        if (DynamicInterface.Instance.IsInstanceCompatible <IPackageProvider>(instance))
                        {
                            try {
                                found = found | ProcessPackageProvider(DynamicInterface.Instance.Create <IPackageProvider>(instance), yieldPackageProvider, asmVersion, request);
                            } catch (Exception e) {
                                e.Dump();
                            }
                        }

                        // check if it's a Services Provider
                        if (DynamicInterface.Instance.IsInstanceCompatible <IArchiver>(instance))
                        {
                            try {
                                found = found | ProcessArchiver(DynamicInterface.Instance.Create <IArchiver>(instance), yieldArchiver, asmVersion, request);
                            } catch (Exception e) {
                                e.Dump();
                            }
                        }

                        if (DynamicInterface.Instance.IsInstanceCompatible <IDownloader>(instance))
                        {
                            try {
                                found = found | ProcessDownloader(DynamicInterface.Instance.Create <IDownloader>(instance), yieldDownloader, asmVersion, request);
                            } catch (Exception e) {
                                e.Dump();
                            }
                        }
                    }
                });
            } catch (Exception e) {
                e.Dump();
            }
            return(found);
        }