示例#1
0
 internal Indexer(string name, string description, string dataSourceName, string skillsetName, string targetIndexName, IndexingSchedule schedule, IndexingParameters parameters, IList <FieldMapping> fieldMappings, IList <FieldMapping> outputFieldMappings, bool?isDisabled, string eTag)
 {
     Name                = name;
     Description         = description;
     DataSourceName      = dataSourceName;
     SkillsetName        = skillsetName;
     TargetIndexName     = targetIndexName;
     Schedule            = schedule;
     Parameters          = parameters;
     FieldMappings       = fieldMappings;
     OutputFieldMappings = outputFieldMappings;
     IsDisabled          = isDisabled;
     ETag                = eTag;
 }
        internal static Indexer DeserializeIndexer(JsonElement element)
        {
            string               name                = default;
            string               description         = default;
            string               dataSourceName      = default;
            string               skillsetName        = default;
            string               targetIndexName     = default;
            IndexingSchedule     schedule            = default;
            IndexingParameters   parameters          = default;
            IList <FieldMapping> fieldMappings       = default;
            IList <FieldMapping> outputFieldMappings = default;
            bool?  disabled  = default;
            string odataEtag = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("description"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    description = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("dataSourceName"))
                {
                    dataSourceName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("skillsetName"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    skillsetName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("targetIndexName"))
                {
                    targetIndexName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("schedule"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    schedule = IndexingSchedule.DeserializeIndexingSchedule(property.Value);
                    continue;
                }
                if (property.NameEquals("parameters"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    parameters = IndexingParameters.DeserializeIndexingParameters(property.Value);
                    continue;
                }
                if (property.NameEquals("fieldMappings"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <FieldMapping> array = new List <FieldMapping>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(FieldMapping.DeserializeFieldMapping(item));
                        }
                    }
                    fieldMappings = array;
                    continue;
                }
                if (property.NameEquals("outputFieldMappings"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <FieldMapping> array = new List <FieldMapping>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(FieldMapping.DeserializeFieldMapping(item));
                        }
                    }
                    outputFieldMappings = array;
                    continue;
                }
                if (property.NameEquals("disabled"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    disabled = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("@odata.etag"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    odataEtag = property.Value.GetString();
                    continue;
                }
            }
            return(new Indexer(name, description, dataSourceName, skillsetName, targetIndexName, schedule, parameters, fieldMappings, outputFieldMappings, disabled, odataEtag));
        }