internal static ManagementPolicy DeserializeManagementPolicy(JsonElement element)
        {
            Optional <string>                 id               = default;
            Optional <string>                 name             = default;
            Optional <string>                 type             = default;
            Optional <DateTimeOffset>         lastModifiedTime = default;
            Optional <ManagementPolicySchema> policy           = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("id"))
                {
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    type = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("properties"))
                {
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.NameEquals("lastModifiedTime"))
                        {
                            lastModifiedTime = property0.Value.GetDateTimeOffset("O");
                            continue;
                        }
                        if (property0.NameEquals("policy"))
                        {
                            policy = ManagementPolicySchema.DeserializeManagementPolicySchema(property0.Value);
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new ManagementPolicy(id.Value, name.Value, type.Value, Optional.ToNullable(lastModifiedTime), policy.Value));
        }
        internal static ManagementPolicy DeserializeManagementPolicy(JsonElement element)
        {
            string                 id               = default;
            string                 name             = default;
            string                 type             = default;
            DateTimeOffset?        lastModifiedTime = default;
            ManagementPolicySchema policy           = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("id"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    type = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("properties"))
                {
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.NameEquals("lastModifiedTime"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                continue;
                            }
                            lastModifiedTime = property0.Value.GetDateTimeOffset("O");
                            continue;
                        }
                        if (property0.NameEquals("policy"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                continue;
                            }
                            policy = ManagementPolicySchema.DeserializeManagementPolicySchema(property0.Value);
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new ManagementPolicy(id, name, type, lastModifiedTime, policy));
        }
Exemple #3
0
 internal ManagementPolicy(string id, string name, string type, DateTimeOffset?lastModifiedTime, ManagementPolicySchema policy) : base(id, name, type)
 {
     LastModifiedTime = lastModifiedTime;
     Policy           = policy;
 }