public override void AddOrUpdateSecretKind()

in Vault/Explorer/PropertyObjectSecret.cs [87:113]


        public override void AddOrUpdateSecretKind(SecretKind sk)
        {
            TagItem newTag = new TagItem(Consts.SecretKindKey, sk.Alias);
            TagItem oldTag = this.Tags.GetOrNull(newTag);

            // Don't add the SecretKind to a secret that doesn't have any custom tags
            if (null == _customTags) return;
            
            // Don't add the SecretKind to a secret that's defaulted to Custom
            if (sk.Alias == "Custom" && !this.Tags.Contains(newTag)) return;
            
            // Don't add the SecretKind to a secret that is defaulted to Custom and doesn't have any custom tags.
            if (oldTag == null && newTag.Value == "Custom") return;

            if (oldTag == null) // Add the SecretKind tag
            {
                Tags.AddOrReplace(newTag);
            }
            else if (oldTag.Value != newTag.Value) // Update the SecretKind tag
            {
                Tags.AddOrReplace(newTag);
            }
            else // Leave the SecretKind tag alone
            {
                Tags.AddOrReplace(oldTag);
            }
        }