< Summary

Class:Azure.Search.Documents.Indexes.Models.CorsOptions
Assembly:Azure.Search.Documents
File(s):C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Generated\Models\CorsOptions.cs
C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Generated\Models\CorsOptions.Serialization.cs
C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Indexes\Models\CorsOptions.cs
Covered lines:0
Uncovered lines:34
Coverable lines:34
Total lines:114
Line coverage:0% (0 of 34)
Covered branches:0
Total branches:14
Branch coverage:0% (0 of 14)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-0%0%
.ctor(...)-0%100%
get_MaxAgeInSeconds()-0%100%
Azure.Core.IUtf8JsonSerializable.Write(...)-0%0%
DeserializeCorsOptions(...)-0%0%
get_AllowedOrigins()-0%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Generated\Models\CorsOptions.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4// <auto-generated/>
 5
 6#nullable disable
 7
 8using System;
 9using System.Collections.Generic;
 10using System.Linq;
 11
 12namespace Azure.Search.Documents.Indexes.Models
 13{
 14    /// <summary> Defines options to control Cross-Origin Resource Sharing (CORS) for an index. </summary>
 15    public partial class CorsOptions
 16    {
 17        /// <summary> Initializes a new instance of CorsOptions. </summary>
 18        /// <param name="allowedOrigins"> The list of origins from which JavaScript code will be granted access to your 
 19        /// <exception cref="ArgumentNullException"> <paramref name="allowedOrigins"/> is null. </exception>
 020        public CorsOptions(IEnumerable<string> allowedOrigins)
 21        {
 022            if (allowedOrigins == null)
 23            {
 024                throw new ArgumentNullException(nameof(allowedOrigins));
 25            }
 26
 027            AllowedOrigins = allowedOrigins.ToList();
 028        }
 29
 30        /// <summary> Initializes a new instance of CorsOptions. </summary>
 31        /// <param name="allowedOrigins"> The list of origins from which JavaScript code will be granted access to your 
 32        /// <param name="maxAgeInSeconds"> The duration for which browsers should cache CORS preflight responses. Defaul
 033        internal CorsOptions(IList<string> allowedOrigins, long? maxAgeInSeconds)
 34        {
 035            AllowedOrigins = allowedOrigins;
 036            MaxAgeInSeconds = maxAgeInSeconds;
 037        }
 38        /// <summary> The duration for which browsers should cache CORS preflight responses. Defaults to 5 minutes. </su
 039        public long? MaxAgeInSeconds { get; set; }
 40    }
 41}

C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Generated\Models\CorsOptions.Serialization.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4// <auto-generated/>
 5
 6#nullable disable
 7
 8using System.Collections.Generic;
 9using System.Text.Json;
 10using Azure.Core;
 11
 12namespace Azure.Search.Documents.Indexes.Models
 13{
 14    public partial class CorsOptions : IUtf8JsonSerializable
 15    {
 16        void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 17        {
 018            writer.WriteStartObject();
 019            writer.WritePropertyName("allowedOrigins");
 020            writer.WriteStartArray();
 021            foreach (var item in AllowedOrigins)
 22            {
 023                writer.WriteStringValue(item);
 24            }
 025            writer.WriteEndArray();
 026            if (Optional.IsDefined(MaxAgeInSeconds))
 27            {
 028                writer.WritePropertyName("maxAgeInSeconds");
 029                writer.WriteNumberValue(MaxAgeInSeconds.Value);
 30            }
 031            writer.WriteEndObject();
 032        }
 33
 34        internal static CorsOptions DeserializeCorsOptions(JsonElement element)
 35        {
 036            IList<string> allowedOrigins = default;
 037            Optional<long> maxAgeInSeconds = default;
 038            foreach (var property in element.EnumerateObject())
 39            {
 040                if (property.NameEquals("allowedOrigins"))
 41                {
 042                    List<string> array = new List<string>();
 043                    foreach (var item in property.Value.EnumerateArray())
 44                    {
 045                        array.Add(item.GetString());
 46                    }
 047                    allowedOrigins = array;
 048                    continue;
 49                }
 050                if (property.NameEquals("maxAgeInSeconds"))
 51                {
 052                    maxAgeInSeconds = property.Value.GetInt64();
 53                    continue;
 54                }
 55            }
 056            return new CorsOptions(allowedOrigins, Optional.ToNullable(maxAgeInSeconds));
 57        }
 58    }
 59}

C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Indexes\Models\CorsOptions.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System.Collections.Generic;
 5using Azure.Core;
 6
 7namespace Azure.Search.Documents.Indexes.Models
 8{
 9    public partial class CorsOptions
 10    {
 11        /// <summary> The list of origins from which JavaScript code will be granted access to your index. Can contain a
 012        public IList<string> AllowedOrigins { get; }
 13    }
 14}