private string CreateAddSourceCommand(ChocolateySource source)
        {
            const string addSourceCommandTemplate = @"choco sources add -name '{0}' -source '{1}'";

            var addSourceCommand = string.Format(addSourceCommandTemplate, source.Name, source.Location);

            return addSourceCommand;
        }
Пример #2
0
        public void RemoveSource(ChocolateySource source)
        {
            var config = XDocument.Load(ConfigurationLocation);

            config.Descendants("source").Where(e => e.Attribute("id").Value == source.Name).Remove();

            config.Save(ConfigurationLocation);
        }
        public ChocolateyFeed(ChocolateyFeedClient feedClient, ChocolateySource source, IInstalledPackagesManager installedPackages)
        {
            this._feedClient = feedClient;
            this._installedPackages = installedPackages;
            this.Source = source;

            this._packageCache = new List<ChocolateyPackage>();
        }
Пример #4
0
        public void AddSource(ChocolateySource source)
        {
            this.RemoveSource(source);

            var config = XDocument.Load(ConfigurationLocation);

            var newElement = new XElement("source", new XAttribute("id", source.Name), new XAttribute("value", source.Location.AbsoluteUri));

            config.Descendants("sources").FirstOrDefault().Add(newElement);

            config.Save(ConfigurationLocation);
        }
        public IChocolateyFeed Create(ChocolateySource source)
        {
            if(this._feedCache.ContainsKey(source))
            {
                return this._feedCache[source];
            }

            var client = new ChocolateyFeedClient(source.Location)
            {
                IgnoreMissingProperties = true,
                MergeOption = MergeOption.NoTracking
            };

            var feed = new ChocolateyFeed(client, source, this._installedPackages);

            this._feedCache.Add(source, feed);

            return feed;
        }
        private void RemoveSource(ChocolateySource source)
        {
            if (this.SelectedChocolateySource == source)
            {
                if (this.SelectedSourceChanged != null)
                {
                    this.SelectedSourceChanged(null);
                }
            }

            this._sourcesManager.RemoveSource(source);

            this.Sources = new ObservableCollection<ChocolateySource>(this.Sources.Where(s => s.Name != source.Name));
            this.RaisePropertyChanged(() => this.Sources);
        }
        private void AddSource()
        {
            var newSource = new ChocolateySource
            {
                Name = this.NewSourceId,
                Location = this.NewSourceLocation
            };

            this.RemoveSource(newSource);

            this._sourcesManager.AddSource(newSource);

            this.Sources.Add(newSource);

            this.NewSourceId = string.Empty;
            this.NewSourceLocation = null;
        }
        private async Task HandleSelectedSourceChanged(ChocolateySource source)
        {
            this.Packages.Clear();
            this.HasSearchResults = false;
            this.SearchTerm = string.Empty;
            
            this._feed = null;

            if (source != null)
            {
                this._feed = this._feedFactory.Create(source);
                await this.LoadPackages();
            }
            
            this.LoadMorePackagesCommand.RaiseCanExecuteChanged();
            this.SearchPackagesCommand.RaiseCanExecuteChanged();
            this.RaisePropertyChanged(() => this.CanSearchPackages);
        }