Пример #1
0
        public async Task AddSource(ChocolateySource source)
        {
            using (await Lock.WriteLockAsync())
            {
                _choco.Set(
                    config =>
                {
                    config.CommandName           = "source";
                    config.SourceCommand.Command = SourceCommandType.add;
                    config.SourceCommand.Name    = source.Id;
                    config.Sources = source.Value;
                    config.SourceCommand.Username            = source.UserName;
                    config.SourceCommand.Password            = source.Password;
                    config.SourceCommand.Certificate         = source.Certificate;
                    config.SourceCommand.CertificatePassword = source.CertificatePassword;
                    config.SourceCommand.Priority            = source.Priority;
                    config.SourceCommand.BypassProxy         = source.BypassProxy;
                    config.SourceCommand.AllowSelfService    = source.AllowSelfService;
                    config.SourceCommand.VisibleToAdminsOnly = source.VisibleToAdminsOnly;
                });

                await _choco.RunAsync();

                if (source.Disabled)
                {
                    await DisableSource(source.Id);
                }
                else
                {
                    await EnableSource(source.Id);
                }
            }
        }
Пример #2
0
        public async Task UpdateSource(string id, ChocolateySource source)
        {
            // NOTE:  The strategy of first removing, and then re-adding the source
            // is due to the fact that there is no "edit source" command that can
            // be used.  This has the side effect of "having" to decrypt the password
            // for an authenticated source, otherwise, when re-adding the source,
            // the encrypted password, is re-encrypted, making it no longer work.
            if (id != source.Id)
            {
                await RemoveSource(id);
            }

            await AddSource(source);
        }
Пример #3
0
 public void Cancel()
 {
     DraftSource = new ChocolateySource(SelectedSource);
 }
Пример #4
0
 public void New()
 {
     SelectedSource = new ChocolateySource();
 }