ACMESharp.POSH.UpdateRegistration.ProcessRecord C# (CSharp) Method

ProcessRecord() protected method

protected ProcessRecord ( ) : void
return void
        protected override void ProcessRecord()
        {
            using (var vlt = Util.VaultHelper.GetVault(VaultProfile))
            {
                vlt.OpenStorage();
                var v = vlt.LoadVault();

                if (v.Registrations == null || v.Registrations.Count < 1)
                    throw new InvalidOperationException("No registrations found");

                var ri = v.Registrations[0];
                var r = ri.Registration;

                // If we're renaming the Alias, do that
                // first in case there are any problems
                if (NewAlias != null)
                {
                    v.Registrations.Rename("0", NewAlias);
                    ri.Alias = NewAlias == "" ? null : NewAlias;
                }

                if (!LocalOnly)
                {
                    try
                    {
                        using (var c = ClientHelper.GetClient(v, ri))
                        {
                            c.Init();
                            c.GetDirectory(true);

                            r = c.UpdateRegistration(UseBaseUri, AcceptTos, Contacts);
                            ri.Registration = r;
                        }
                    }
                    catch (AcmeClient.AcmeWebException ex)
                    {
                        ThrowTerminatingError(PoshHelper.CreateErrorRecord(ex, ri));
                        return;
                    }

                    vlt.SaveVault(v);
                }

                ri.Label = StringHelper.IfNullOrEmpty(Label);
                ri.Memo = StringHelper.IfNullOrEmpty(Memo);

                vlt.SaveVault(v);

                WriteObject(r);
            }
        }
UpdateRegistration