internal UrlRewriteActionParameters(UrlRewriteActionParametersTypeName typeName, string sourcePattern, string destination, bool?preserveUnmatchedPath)
 {
     TypeName              = typeName;
     SourcePattern         = sourcePattern;
     Destination           = destination;
     PreserveUnmatchedPath = preserveUnmatchedPath;
 }
        public UrlRewriteActionParameters(UrlRewriteActionParametersTypeName typeName, string sourcePattern, string destination)
        {
            if (sourcePattern == null)
            {
                throw new ArgumentNullException(nameof(sourcePattern));
            }
            if (destination == null)
            {
                throw new ArgumentNullException(nameof(destination));
            }

            TypeName      = typeName;
            SourcePattern = sourcePattern;
            Destination   = destination;
        }
        internal static UrlRewriteActionParameters DeserializeUrlRewriteActionParameters(JsonElement element)
        {
            UrlRewriteActionParametersTypeName typeName = default;
            string          sourcePattern         = default;
            string          destination           = default;
            Optional <bool> preserveUnmatchedPath = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("typeName"))
                {
                    typeName = new UrlRewriteActionParametersTypeName(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("sourcePattern"))
                {
                    sourcePattern = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("destination"))
                {
                    destination = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("preserveUnmatchedPath"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    preserveUnmatchedPath = property.Value.GetBoolean();
                    continue;
                }
            }
            return(new UrlRewriteActionParameters(typeName, sourcePattern, destination, Optional.ToNullable(preserveUnmatchedPath)));
        }