Exemple #1
0
 internal ManagementGroupInfo(int?version, DateTimeOffset?updatedOn, string updatedBy, ParentManagementGroupInfo parent, IReadOnlyList <ManagementGroupPathElement> path, IReadOnlyList <string> managementGroupAncestors, IReadOnlyList <ManagementGroupPathElement> managementGroupAncestorChain)
 {
     Version   = version;
     UpdatedOn = updatedOn;
     UpdatedBy = updatedBy;
     Parent    = parent;
     Path      = path;
     ManagementGroupAncestors     = managementGroupAncestors;
     ManagementGroupAncestorChain = managementGroupAncestorChain;
 }
        internal static ManagementGroupInfo DeserializeManagementGroupInfo(JsonElement element)
        {
            Optional <int>                       version                = default;
            Optional <DateTimeOffset>            updatedTime            = default;
            Optional <string>                    updatedBy              = default;
            Optional <ParentManagementGroupInfo> parent                 = default;
            Optional <IReadOnlyList <ManagementGroupPathElement> > path = default;
            Optional <IReadOnlyList <string> > managementGroupAncestors = default;
            Optional <IReadOnlyList <ManagementGroupPathElement> > managementGroupAncestorsChain = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("version"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    version = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("updatedTime"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    updatedTime = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("updatedBy"))
                {
                    updatedBy = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("parent"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    parent = ParentManagementGroupInfo.DeserializeParentManagementGroupInfo(property.Value);
                    continue;
                }
                if (property.NameEquals("path"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        path = null;
                        continue;
                    }
                    List <ManagementGroupPathElement> array = new List <ManagementGroupPathElement>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(ManagementGroupPathElement.DeserializeManagementGroupPathElement(item));
                    }
                    path = array;
                    continue;
                }
                if (property.NameEquals("managementGroupAncestors"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        managementGroupAncestors = null;
                        continue;
                    }
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(item.GetString());
                    }
                    managementGroupAncestors = array;
                    continue;
                }
                if (property.NameEquals("managementGroupAncestorsChain"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        managementGroupAncestorsChain = null;
                        continue;
                    }
                    List <ManagementGroupPathElement> array = new List <ManagementGroupPathElement>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(ManagementGroupPathElement.DeserializeManagementGroupPathElement(item));
                    }
                    managementGroupAncestorsChain = array;
                    continue;
                }
            }
            return(new ManagementGroupInfo(Optional.ToNullable(version), Optional.ToNullable(updatedTime), updatedBy.Value, parent.Value, Optional.ToList(path), Optional.ToList(managementGroupAncestors), Optional.ToList(managementGroupAncestorsChain)));
        }