Exemplo n.º 1
0
        internal static EmailNotificationHook DeserializeEmailNotificationHook(JsonElement element)
        {
            EmailHookParameter hookParameter          = default;
            HookType           hookType               = default;
            Optional <string>  hookId                 = default;
            string             hookName               = default;
            Optional <string>  description            = default;
            Optional <string>  externalLink           = default;
            Optional <IReadOnlyList <string> > admins = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("hookParameter"))
                {
                    hookParameter = EmailHookParameter.DeserializeEmailHookParameter(property.Value);
                    continue;
                }
                if (property.NameEquals("hookType"))
                {
                    hookType = new HookType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("hookId"))
                {
                    hookId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("hookName"))
                {
                    hookName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("description"))
                {
                    description = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("externalLink"))
                {
                    externalLink = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("admins"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(item.GetString());
                    }
                    admins = array;
                    continue;
                }
            }
            return(new EmailNotificationHook(hookType, hookId.Value, hookName, description.Value, externalLink.Value, Optional.ToList(admins), hookParameter));
        }
Exemplo n.º 2
0
 internal EmailNotificationHook(HookType hookType, string id, string name, string description, string externalLink, IReadOnlyList <string> administrators, EmailHookParameter hookParameter)
     : base(hookType, id, name, description, externalLink, administrators)
 {
     HookType      = hookType;
     EmailsToAlert = hookParameter.ToList;
 }