internal PersonalizerPolicyResult(string name, string arguments, PersonalizerPolicySource?policySource, IReadOnlyList <PersonalizerPolicyResultSummary> summary, PersonalizerPolicyResultSummary totalSummary)
 {
     Name         = name;
     Arguments    = arguments;
     PolicySource = policySource;
     Summary      = summary;
     TotalSummary = totalSummary;
 }
Exemplo n.º 2
0
        internal static PersonalizerPolicyResult DeserializePersonalizerPolicyResult(JsonElement element)
        {
            Optional <string> name      = default;
            Optional <string> arguments = default;
            Optional <PersonalizerPolicySource> policySource = default;
            Optional <IReadOnlyList <PersonalizerPolicyResultSummary> > summary = default;
            Optional <PersonalizerPolicyResultSummary> totalSummary             = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("arguments"))
                {
                    arguments = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("policySource"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    policySource = new PersonalizerPolicySource(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("summary"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <PersonalizerPolicyResultSummary> array = new List <PersonalizerPolicyResultSummary>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(PersonalizerPolicyResultSummary.DeserializePersonalizerPolicyResultSummary(item));
                    }
                    summary = array;
                    continue;
                }
                if (property.NameEquals("totalSummary"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    totalSummary = PersonalizerPolicyResultSummary.DeserializePersonalizerPolicyResultSummary(property.Value);
                    continue;
                }
            }
            return(new PersonalizerPolicyResult(name.Value, arguments.Value, Optional.ToNullable(policySource), Optional.ToList(summary), totalSummary.Value));
        }
Exemplo n.º 3
0
        public static PersonalizerPolicyResult PersonalizerPolicyResult(string name = null, string arguments = null, PersonalizerPolicySource?policySource = null, IEnumerable <PersonalizerPolicyResultSummary> summary = null, PersonalizerPolicyResultSummary totalSummary = null)
        {
            summary ??= new List <PersonalizerPolicyResultSummary>();

            return(new PersonalizerPolicyResult(name, arguments, policySource, summary?.ToList(), totalSummary));
        }