コード例 #1
0
        internal static HookList DeserializeHookList(JsonElement element)
        {
            Optional <string> nextLink = default;
            Optional <IReadOnlyList <AlertingHook> > value = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("@nextLink"))
                {
                    nextLink = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("value"))
                {
                    List <AlertingHook> array = new List <AlertingHook>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(AlertingHook.DeserializeAlertingHook(item));
                    }
                    value = array;
                    continue;
                }
            }
            return(new HookList(nextLink.Value, Optional.ToList(value)));
        }
コード例 #2
0
 internal static HookInfoPatch GetPatchModel(AlertingHook hook)
 {
     return(hook switch
     {
         EmailHook h => new EmailHookInfoPatch()
         {
             HookName = h.Name, Description = h.Description, ExternalLink = h.ExternalLink, HookParameter = h.HookParameter, Admins = h.Administrators
         },
         WebHook h => new WebhookHookInfoPatch()
         {
             HookName = h.Name, Description = h.Description, ExternalLink = h.ExternalLink, HookParameter = h.HookParameter, Admins = h.Administrators
         },
         _ => throw new InvalidOperationException("Unknown AlertingHook type.")
     });