Beispiel #1
0
 internal ManagementPolicyRule(bool?enabled, string name, RuleType type, ManagementPolicyDefinition definition)
 {
     Enabled    = enabled;
     Name       = name;
     Type       = type;
     Definition = definition;
 }
        internal static ManagementPolicyRule DeserializeManagementPolicyRule(JsonElement element)
        {
            Optional <bool>            enabled    = default;
            string                     name       = default;
            RuleType                   type       = default;
            ManagementPolicyDefinition definition = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("enabled"))
                {
                    enabled = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    type = new RuleType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("definition"))
                {
                    definition = ManagementPolicyDefinition.DeserializeManagementPolicyDefinition(property.Value);
                    continue;
                }
            }
            return(new ManagementPolicyRule(Optional.ToNullable(enabled), name, type, definition));
        }
Beispiel #3
0
        public ManagementPolicyRule(string name, RuleType type, ManagementPolicyDefinition definition)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }
            if (definition == null)
            {
                throw new ArgumentNullException(nameof(definition));
            }

            Name       = name;
            Type       = type;
            Definition = definition;
        }
        internal static ManagementPolicyRule DeserializeManagementPolicyRule(JsonElement element)
        {
            bool?  enabled = default;
            string name    = default;
            string type    = default;
            ManagementPolicyDefinition definition = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("enabled"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    enabled = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    type = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("definition"))
                {
                    definition = ManagementPolicyDefinition.DeserializeManagementPolicyDefinition(property.Value);
                    continue;
                }
            }
            return(new ManagementPolicyRule(enabled, name, type, definition));
        }