Beispiel #1
0
        /// <summary>
        /// Applies the builder conventions to the specified controller action.
        /// </summary>
        /// <param name="actionModel">The <see cref="ActionModel">action model</see> to apply the conventions to.</param>
        public virtual void ApplyTo(ActionModel actionModel)
        {
            Arg.NotNull(actionModel, nameof(actionModel));

            MappedVersions.AddRange(from provider in actionModel.Attributes.OfType <IApiVersionProvider>()
                                    where !provider.AdvertiseOnly && !provider.Deprecated
                                    from version in provider.Versions
                                    select version);

            var controllerVersionInfo = actionModel.GetProperty <ControllerVersionInfo>();
            var versionModel          = new ApiVersionModel(
                declaredVersions: MappedVersions,
                supportedVersions: controllerVersionInfo.Item1,
                deprecatedVersions: controllerVersionInfo.Item2,
                advertisedVersions: controllerVersionInfo.Item3,
                deprecatedAdvertisedVersions: controllerVersionInfo.Item4);

            actionModel.SetProperty(versionModel);
        }
Beispiel #2
0
        /// <summary>
        /// Applies the builder conventions to the specified controller action.
        /// </summary>
        /// <param name="actionModel">The <see cref="ActionModel">action model</see> to apply the conventions to.</param>
        public virtual void ApplyTo(ActionModel actionModel)
        {
            Arg.NotNull(actionModel, nameof(actionModel));

            MappedVersions.AddRange(from provider in actionModel.Attributes.OfType <IApiVersionProvider>()
                                    where !provider.AdvertiseOnly && !provider.Deprecated
                                    from version in provider.Versions
                                    select version);

            var(supportedVersions, deprecatedVersions, advertisedVersions, deprecatedAdvertisedVersions) =
                actionModel.GetProperty <Tuple <IEnumerable <ApiVersion>,
                                                IEnumerable <ApiVersion>,
                                                IEnumerable <ApiVersion>,
                                                IEnumerable <ApiVersion> > >();

            var versionModel = new ApiVersionModel(
                declaredVersions: MappedVersions,
                supportedVersions,
                deprecatedVersions,
                advertisedVersions,
                deprecatedAdvertisedVersions);

            actionModel.SetProperty(versionModel);
        }