コード例 #1
0
 internal static TopologyResource DeserializeTopologyResource(JsonElement element)
 {
     string name = default;
     string id = default;
     string location = default;
     IReadOnlyList<TopologyAssociation> associations = default;
     foreach (var property in element.EnumerateObject())
     {
         if (property.NameEquals("name"))
         {
             if (property.Value.ValueKind == JsonValueKind.Null)
             {
                 continue;
             }
             name = property.Value.GetString();
             continue;
         }
         if (property.NameEquals("id"))
         {
             if (property.Value.ValueKind == JsonValueKind.Null)
             {
                 continue;
             }
             id = property.Value.GetString();
             continue;
         }
         if (property.NameEquals("location"))
         {
             if (property.Value.ValueKind == JsonValueKind.Null)
             {
                 continue;
             }
             location = property.Value.GetString();
             continue;
         }
         if (property.NameEquals("associations"))
         {
             if (property.Value.ValueKind == JsonValueKind.Null)
             {
                 continue;
             }
             List<TopologyAssociation> array = new List<TopologyAssociation>();
             foreach (var item in property.Value.EnumerateArray())
             {
                 if (item.ValueKind == JsonValueKind.Null)
                 {
                     array.Add(null);
                 }
                 else
                 {
                     array.Add(TopologyAssociation.DeserializeTopologyAssociation(item));
                 }
             }
             associations = array;
             continue;
         }
     }
     return new TopologyResource(name, id, location, associations);
 }
コード例 #2
0
        internal static TopologyResourceInfo DeserializeTopologyResourceInfo(JsonElement element)
        {
            Optional <string>        name     = default;
            Optional <string>        id       = default;
            Optional <AzureLocation> location = default;
            Optional <IReadOnlyList <TopologyAssociation> > associations = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("id"))
                {
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("location"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    location = new AzureLocation(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("associations"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <TopologyAssociation> array = new List <TopologyAssociation>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(TopologyAssociation.DeserializeTopologyAssociation(item));
                    }
                    associations = array;
                    continue;
                }
            }
            return(new TopologyResourceInfo(name.Value, id.Value, Optional.ToNullable(location), Optional.ToList(associations)));
        }
 internal static TopologyResource DeserializeTopologyResource(JsonElement element)
 {
     Optional<string> name = default;
     Optional<string> id = default;
     Optional<string> location = default;
     Optional<IReadOnlyList<TopologyAssociation>> associations = default;
     foreach (var property in element.EnumerateObject())
     {
         if (property.NameEquals("name"))
         {
             name = property.Value.GetString();
             continue;
         }
         if (property.NameEquals("id"))
         {
             id = property.Value.GetString();
             continue;
         }
         if (property.NameEquals("location"))
         {
             location = property.Value.GetString();
             continue;
         }
         if (property.NameEquals("associations"))
         {
             List<TopologyAssociation> array = new List<TopologyAssociation>();
             foreach (var item in property.Value.EnumerateArray())
             {
                 array.Add(TopologyAssociation.DeserializeTopologyAssociation(item));
             }
             associations = array;
             continue;
         }
     }
     return new TopologyResource(name.Value, id.Value, location.Value, Optional.ToList(associations));
 }