コード例 #1
0
ファイル: ApplicationModel.cs プロジェクト: ymd1223/Mvc
 public ApplicationModel()
 {
     ApiExplorer = new ApiExplorerModel();
     Controllers = new List<ControllerModel>();
     Filters = new List<IFilterMetadata>();
     Properties = new Dictionary<object, object>();
 }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ODataApiExplorerModel"/> class.
        /// </summary>
        /// <param name="other">The other <see cref="ApiExplorerModel">model</see> to copy from.</param>
        public ODataApiExplorerModel(ApiExplorerModel other) : base(other)
        {
            Arg.NotNull(other, nameof(other));

            IsVisible      = null;
            IsODataVisible = other.IsVisible;
        }
コード例 #3
0
        /// <summary>
        /// Initializes a new instance of <see cref="ControllerModel"/>.
        /// </summary>
        /// <param name="controllerType">The type of the controller.</param>
        /// <param name="attributes">The attributes.</param>
        public ControllerModel(
            TypeInfo controllerType,
            IReadOnlyList <object> attributes)
        {
            if (controllerType == null)
            {
                throw new ArgumentNullException(nameof(controllerType));
            }

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

            ControllerType = controllerType;

            Actions              = new List <ActionModel>();
            ApiExplorer          = new ApiExplorerModel();
            Attributes           = new List <object>(attributes);
            ControllerProperties = new List <PropertyModel>();
            Filters              = new List <IFilterMetadata>();
            Properties           = new Dictionary <object, object>();
            RouteValues          = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);
            Selectors            = new List <SelectorModel>();
        }
コード例 #4
0
ファイル: ControllerModel.cs プロジェクト: ymd1223/Mvc
        public ControllerModel(ControllerModel other)
        {
            if (other == null)
            {
                throw new ArgumentNullException(nameof(other));
            }

            ControllerName = other.ControllerName;
            ControllerType = other.ControllerType;

            // Still part of the same application
            Application = other.Application;

            // These are just metadata, safe to create new collections
            Attributes = new List<object>(other.Attributes);
            Filters = new List<IFilterMetadata>(other.Filters);
            RouteValues = new Dictionary<string, string>(other.RouteValues, StringComparer.OrdinalIgnoreCase);
            Properties = new Dictionary<object, object>(other.Properties);

            // Make a deep copy of other 'model' types.
            Actions = new List<ActionModel>(other.Actions.Select(a => new ActionModel(a)));
            ApiExplorer = new ApiExplorerModel(other.ApiExplorer);
            ControllerProperties =
                new List<PropertyModel>(other.ControllerProperties.Select(p => new PropertyModel(p)));
            Selectors = new List<SelectorModel>(other.Selectors.Select(s => new SelectorModel(s)));
        }
コード例 #5
0
ファイル: ControllerModel.cs プロジェクト: ymd1223/Mvc
        public ControllerModel(
            TypeInfo controllerType,
            IReadOnlyList<object> attributes)
        {
            if (controllerType == null)
            {
                throw new ArgumentNullException(nameof(controllerType));
            }

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

            ControllerType = controllerType;

            Actions = new List<ActionModel>();
            ApiExplorer = new ApiExplorerModel();
            Attributes = new List<object>(attributes);
            ControllerProperties = new List<PropertyModel>();
            Filters = new List<IFilterMetadata>();
            Properties = new Dictionary<object, object>();
            RouteValues = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
            Selectors = new List<SelectorModel>();
        }
コード例 #6
0
        public ControllerModel(
            TypeInfo controllerType,
            IReadOnlyList <object> attributes)
        {
            if (controllerType == null)
            {
                throw new ArgumentNullException(nameof(controllerType));
            }

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

            ControllerType = controllerType;

            Actions              = new List <ActionModel>();
            ApiExplorer          = new ApiExplorerModel();
            Attributes           = new List <object>(attributes);
            ControllerProperties = new List <PropertyModel>();
            Filters              = new List <IFilterMetadata>();
            Properties           = new Dictionary <object, object>();
            RouteConstraints     = new List <IRouteConstraintProvider>();
            Selectors            = new List <SelectorModel>();
        }
コード例 #7
0
        /// <summary>
        /// Initializes a new instance of <see cref="ControllerModel"/>.
        /// </summary>
        /// <param name="other">The other controller model.</param>
        public ControllerModel(ControllerModel other)
        {
            if (other == null)
            {
                throw new ArgumentNullException(nameof(other));
            }

            ControllerName = other.ControllerName;
            ControllerType = other.ControllerType;

            // Still part of the same application
            Application = other.Application;

            // These are just metadata, safe to create new collections
            Attributes  = new List <object>(other.Attributes);
            Filters     = new List <IFilterMetadata>(other.Filters);
            RouteValues = new Dictionary <string, string>(other.RouteValues, StringComparer.OrdinalIgnoreCase);
            Properties  = new Dictionary <object, object>(other.Properties);

            // Make a deep copy of other 'model' types.
            Actions = new List <ActionModel>(other.Actions.Select(a => new ActionModel(a)
            {
                Controller = this
            }));
            ApiExplorer          = new ApiExplorerModel(other.ApiExplorer);
            ControllerProperties =
                new List <PropertyModel>(other.ControllerProperties.Select(p => new PropertyModel(p)
            {
                Controller = this
            }));
            Selectors = new List <SelectorModel>(other.Selectors.Select(s => new SelectorModel(s)));
        }
コード例 #8
0
 public ApplicationModel()
 {
     ApiExplorer = new ApiExplorerModel();
     Controllers = new List <ControllerModel>();
     Filters     = new List <IFilterMetadata>();
     Properties  = new Dictionary <object, object>();
 }
コード例 #9
0
ファイル: ActionModel.cs プロジェクト: lingku7080/asp.netcore
        /// <summary>
        /// Copy constructor for <see cref="ActionModel"/>.
        /// </summary>
        /// <param name="other">The <see cref="ActionModel"/> to copy.</param>
        public ActionModel(ActionModel other)
        {
            if (other == null)
            {
                throw new ArgumentNullException(nameof(other));
            }

            ActionMethod = other.ActionMethod;
            ActionName   = other.ActionName;
            RouteParameterTransformer = other.RouteParameterTransformer;

            // Not making a deep copy of the controller, this action still belongs to the same controller.
            Controller = other.Controller;

            // These are just metadata, safe to create new collections
            Attributes  = new List <object>(other.Attributes);
            Filters     = new List <IFilterMetadata>(other.Filters);
            Properties  = new Dictionary <object, object>(other.Properties);
            RouteValues = new Dictionary <string, string>(other.RouteValues, StringComparer.OrdinalIgnoreCase);

            // Make a deep copy of other 'model' types.
            ApiExplorer = new ApiExplorerModel(other.ApiExplorer);
            Parameters  = new List <ParameterModel>(other.Parameters.Select(p => new ParameterModel(p)
            {
                Action = this
            }));
            Selectors = new List <SelectorModel>(other.Selectors.Select(s => new SelectorModel(s)));
        }
コード例 #10
0
        /// <summary>
        /// Returns a value indicating whether the specified model is visible to OData.
        /// </summary>
        /// <param name="model">The <see cref="ApiExplorerModel">model</see> to evaluate.</param>
        /// <returns>True if the associated controller or action is visible to OData; otherwise, false.</returns>
        public static bool?IsODataVisible(this ApiExplorerModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            return(model is ODataApiExplorerModel odataModel ? odataModel.IsODataVisible : model.IsVisible);
        }
コード例 #11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ODataApiExplorerModel"/> class.
        /// </summary>
        /// <param name="other">The other <see cref="ApiExplorerModel">model</see> to copy from.</param>
        public ODataApiExplorerModel(ApiExplorerModel other) : base(other)
        {
            if (other == null)
            {
                throw new ArgumentNullException(nameof(other));
            }

            IsVisible      = null;
            IsODataVisible = other.IsVisible;
        }
コード例 #12
0
ファイル: ApiExplorerModel.cs プロジェクト: ymd1223/Mvc
        /// <summary>
        /// Creates a new <see cref="ApiExplorerModel"/> with properties copied from <paramref name="other"/>.
        /// </summary>
        /// <param name="other">The <see cref="ApiExplorerModel"/> to copy.</param>
        public ApiExplorerModel(ApiExplorerModel other)
        {
            if (other == null)
            {
                throw new ArgumentNullException(nameof(other));
            }

            GroupName = other.GroupName;
            IsVisible = other.IsVisible;
        }
コード例 #13
0
        /// <summary>
        /// Creates a new <see cref="ApiExplorerModel"/> with properties copied from <paramref name="other"/>.
        /// </summary>
        /// <param name="other">The <see cref="ApiExplorerModel"/> to copy.</param>
        public ApiExplorerModel(ApiExplorerModel other)
        {
            if (other == null)
            {
                throw new ArgumentNullException(nameof(other));
            }

            GroupName = other.GroupName;
            IsVisible = other.IsVisible;
        }
コード例 #14
0
ファイル: ActionModel.cs プロジェクト: YPTopMan/AspNetCore
        /// <summary>
        /// Initializes a new instance of <see cref="ActionModel"/>.
        /// </summary>
        /// <param name="actionMethod">The action <see cref="MethodInfo"/>.</param>
        /// <param name="attributes">The attributes associated with the action.</param>
        public ActionModel(
            MethodInfo actionMethod,
            IReadOnlyList <object> attributes)
        {
            if (attributes == null)
            {
                throw new ArgumentNullException(nameof(attributes));
            }

            ActionMethod = actionMethod ?? throw new ArgumentNullException(nameof(actionMethod));

            ApiExplorer = new ApiExplorerModel();
            Attributes  = new List <object>(attributes);
            Filters     = new List <IFilterMetadata>();
            Parameters  = new List <ParameterModel>();
            RouteValues = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);
            Properties  = new Dictionary <object, object>();
            Selectors   = new List <SelectorModel>();
        }
コード例 #15
0
ファイル: ActionModel.cs プロジェクト: jaysson1710/mvcExample
        public ActionModel(
            MethodInfo actionMethod,
            IReadOnlyList <object> attributes)
        {
            if (actionMethod == null)
            {
                throw new ArgumentNullException(nameof(actionMethod));
            }

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

            ActionMethod = actionMethod;

            ApiExplorer      = new ApiExplorerModel();
            Attributes       = new List <object>(attributes);
            Filters          = new List <IFilterMetadata>();
            Parameters       = new List <ParameterModel>();
            RouteConstraints = new List <IRouteConstraintProvider>();
            Properties       = new Dictionary <object, object>();
            Selectors        = new List <SelectorModel>();
        }
コード例 #16
0
ファイル: ActionModel.cs プロジェクト: ymd1223/Mvc
        public ActionModel(ActionModel other)
        {
            if (other == null)
            {
                throw new ArgumentNullException(nameof(other));
            }

            ActionMethod = other.ActionMethod;
            ActionName = other.ActionName;

            // Not making a deep copy of the controller, this action still belongs to the same controller.
            Controller = other.Controller;

            // These are just metadata, safe to create new collections
            Attributes = new List<object>(other.Attributes);
            Filters = new List<IFilterMetadata>(other.Filters);
            Properties = new Dictionary<object, object>(other.Properties);
            RouteValues = new Dictionary<string, string>(other.RouteValues, StringComparer.OrdinalIgnoreCase);

            // Make a deep copy of other 'model' types.
            ApiExplorer = new ApiExplorerModel(other.ApiExplorer);
            Parameters = new List<ParameterModel>(other.Parameters.Select(p => new ParameterModel(p)));
            Selectors = new List<SelectorModel>(other.Selectors.Select(s => new SelectorModel(s)));
        }
コード例 #17
0
ファイル: ActionModel.cs プロジェクト: ymd1223/Mvc
        public ActionModel(
            MethodInfo actionMethod,
            IReadOnlyList<object> attributes)
        {
            if (actionMethod == null)
            {
                throw new ArgumentNullException(nameof(actionMethod));
            }

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

            ActionMethod = actionMethod;

            ApiExplorer = new ApiExplorerModel();
            Attributes = new List<object>(attributes);
            Filters = new List<IFilterMetadata>();
            Parameters = new List<ParameterModel>();
            RouteValues = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
            Properties = new Dictionary<object, object>();
            Selectors = new List<SelectorModel>();
        }
コード例 #18
0
 /// <summary>
 /// Returns a value indicating whether the specified model is visible to OData.
 /// </summary>
 /// <param name="model">The <see cref="ApiExplorerModel">model</see> to evaluate.</param>
 /// <returns>True if the associated controller or action is visible to OData; otherwise, false.</returns>
 public static bool?IsODataVisible(this ApiExplorerModel model)
 {
     Arg.NotNull(model, nameof(model));
     return(model is ODataApiExplorerModel odataModel ? odataModel.IsODataVisible : model.IsVisible);
 }