示例#1
0
        /// <summary>
        /// 连接
        /// </summary>
        internal void Connect()
        {
            var opt = AppContext.Instance.Options;

            //标记禁用的处理器
            opt.DisableDownloadProviders.ForEach(s =>
            {
                var service = DownloadServiceProviders.FirstOrDefault(x => x.Info.Name == s);
                if (service != null)
                {
                    service.Disabled = true;
                }
            });
            opt.DisabledSearchProviders.ForEach(s =>
            {
                var service = ResourceProviders.FirstOrDefault(x => x.Info.Name == s);
                if (service != null)
                {
                    service.Disabled = true;
                }
            });

            //处理默认的引擎
            if (ResourceProviders.Any())
            {
                if (!string.IsNullOrEmpty(opt.ActiveSearchProvider))
                {
                    ActiveSearchService = ResourceProviders.FirstOrDefault(s => s.Info.Name == opt.ActiveSearchProvider);
                }
            }
            foreach (var torrentResourceProvider in ResourceProviders)
            {
                torrentResourceProvider.Init(_container);
            }
            foreach (var torrentDownloadServiceProvider in DownloadServiceProviders)
            {
                torrentDownloadServiceProvider.Init(_container);
            }
            Array.ForEach(ResourceProcessors, s => s.Init(_container));
            Array.ForEach(ResourceContextMenuAddins, s => s.Init(_container));

            foreach (var torrentResourceProvider in ResourceProviders)
            {
                torrentResourceProvider.Connect();
                if (opt.AppVersion != Program.CurrentVersion)
                {
                    torrentResourceProvider.UpgradeFrom(opt.AppVersion, Program.CurrentVersion);
                }
            }
            foreach (var torrentDownloadServiceProvider in DownloadServiceProviders)
            {
                torrentDownloadServiceProvider.Connect();
                if (opt.AppVersion != Program.CurrentVersion)
                {
                    torrentDownloadServiceProvider.UpgradeFrom(opt.AppVersion, Program.CurrentVersion);
                }
            }
            Array.ForEach(ResourceProcessors, s =>
            {
                s.Connect();
                if (opt.AppVersion != Program.CurrentVersion)
                {
                    s.UpgradeFrom(opt.AppVersion, Program.CurrentVersion);
                }
            });
            Array.ForEach(ResourceContextMenuAddins, s =>
            {
                s.Connect();
                if (opt.AppVersion != Program.CurrentVersion)
                {
                    s.UpgradeFrom(opt.AppVersion, Program.CurrentVersion);
                }
            });

            opt.AppVersion = Program.CurrentVersion;
        }
 protected NuGetAction(IEnumerable <string>?sources)
 {
     ResourceProviders.AddRange(Repository.Provider.GetCoreV3());
     Settings           = NuGet.Configuration.Settings.LoadDefaultSettings(null, null, new MachineWideSettings());
     SourceRepositories = GetSourceRepositories(sources).ToList();
 }