Esempio n. 1
0
 public ApplicationModel()
 {
     ApiExplorer = new ApiExplorerModel();
     Controllers = new List<ControllerModel>();
     Filters = new List<IFilterMetadata>();
     Properties = new Dictionary<object, object>();
 }
Esempio n. 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;
        }
Esempio n. 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>();
        }
Esempio n. 4
0
        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)));
        }
Esempio n. 5
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>();
            RouteValues = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
            Selectors = new List<SelectorModel>();
        }
Esempio n. 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>();
        }
Esempio n. 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)));
        }
Esempio n. 8
0
 public ApplicationModel()
 {
     ApiExplorer = new ApiExplorerModel();
     Controllers = new List <ControllerModel>();
     Filters     = new List <IFilterMetadata>();
     Properties  = new Dictionary <object, object>();
 }
Esempio n. 9
0
        /// <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)));
        }
Esempio n. 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);
        }
        /// <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;
        }
Esempio n. 12
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;
        }
Esempio n. 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;
        }
Esempio n. 14
0
        /// <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>();
        }
Esempio n. 15
0
        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>();
        }
Esempio n. 16
0
        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)));
        }
Esempio n. 17
0
        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>();
        }
 /// <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);
 }