/// <summary>
 /// Initializes a new instance of the <see cref="ApiVersioningOptions"/> class.
 /// </summary>
 public ApiVersioningOptions()
 {
     apiVersionSelector = new DefaultApiVersionSelector(this);
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="EdmModelSelector"/> class.
        /// </summary>
        /// <param name="models">The <see cref="IEnumerable{T}">sequence</see> of <see cref="IEdmModel">models</see> to select from.</param>
        /// <param name="defaultApiVersion">The default <see cref="ApiVersion">API version</see>.</param>
        /// <param name="apiVersionSelector">The <see cref="IApiVersionSelector">selector</see> used to choose API versions.</param>
        public EdmModelSelector(IEnumerable <IEdmModel> models, ApiVersion defaultApiVersion, IApiVersionSelector apiVersionSelector)
        {
            if (models == null)
            {
                throw new ArgumentNullException(nameof(models));
            }

            if (defaultApiVersion == null)
            {
                throw new ArgumentNullException(nameof(defaultApiVersion));
            }

            selector = apiVersionSelector ?? throw new ArgumentNullException(nameof(apiVersionSelector));

            List <ApiVersion> versions;
            Dictionary <ApiVersion, IEdmModel> collection;

            switch (models)
            {
            case IList <IEdmModel> list:
                versions   = new(list.Count);
                collection = new(list.Count);

                for (var i = 0; i < list.Count; i++)
                {
                    AddVersionFromModel(list[i], versions, collection);
                }

                break;

            case IReadOnlyList <IEdmModel> list:
                versions   = new(list.Count);
                collection = new(list.Count);

                for (var i = 0; i < list.Count; i++)
                {
                    AddVersionFromModel(list[i], versions, collection);
                }

                break;

            default:
                versions   = new();
                collection = new();

                foreach (var model in models)
                {
                    AddVersionFromModel(model, versions, collection);
                }
#if !WEBAPI
                collection.TrimExcess();
#endif
                break;
            }

            versions.Sort();
#pragma warning disable IDE0056 // Use index operator (cannot be used in web api)
            maxVersion = versions.Count == 0 ? defaultApiVersion : versions[versions.Count - 1];
#pragma warning restore IDE0056
            ApiVersions = versions.ToArray();
            Models      = collection;
        }