Beispiel #1
0
        /// <summary>
        /// Register a new convention
        /// </summary>
        /// <param name="convention"><see cref="IPropertyModelMetadataConvention"/> class</param>
        public virtual void RegisterConvention([NotNull] IPropertyModelMetadataConvention convention)
        {
            Invariant.IsNotNull(convention, "convention");

            conventions.Add(convention);
        }
        private static IServiceRegistrar RegisterType <TService, TImplementation>([NotNull] this IServiceRegistrar instance, LifetimeType lifetime) where TImplementation : TService where TService : class
        {
            Invariant.IsNotNull(instance, "instance");

            return(instance.RegisterType(typeof(TService), typeof(TImplementation), lifetime));
        }
Beispiel #3
0
 /// <summary>
 /// Allows to define custom factory to contruct model metadata configuration classes
 /// </summary>
 /// <param name="configurationFactory">A factory to instantiate <see cref="IModelMetadataConfiguration"/> classes</param>
 public static IRegistrar ConstructMetadataUsing(Func <IEnumerable <IModelMetadataConfiguration> > configurationFactory)
 {
     Invariant.IsNotNull(configurationFactory, "configurationFactory");
     return(Registrar.ConstructMetadataUsing(configurationFactory));
 }
Beispiel #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RegisterValueProviderFactories"/> class.
        /// </summary>
        /// <param name="container">The container.</param>
        public RegisterValueProviderFactories([NotNull] ContainerAdapter container)
        {
            Invariant.IsNotNull(container, "container");

            Container = container;
        }
        /// <summary>
        /// Gets the value that is stored against the specified key, if the key does not exists it will return the provided default value.
        /// </summary>
        /// <typeparam name="TValue">The type of the value.</typeparam>
        /// <param name="instance">The instance.</param>
        /// <param name="key">The key.</param>
        /// <param name="defaultValue">The default value.</param>
        /// <returns></returns>
        public static TValue Get <TValue>(this ViewDataDictionary instance, string key, TValue defaultValue)
        {
            Invariant.IsNotNull(instance, "instance");

            return(instance.ContainsKey(key) ? (TValue)instance[key] : defaultValue);
        }
        /// <summary>
        /// Determines whether  the specified type exists.
        /// </summary>
        /// <typeparam name="TValue">The type of the value.</typeparam>
        /// <param name="instance">The instance.</param>
        /// <returns>
        /// <c>true</c> if [contains] [the specified instance]; otherwise, <c>false</c>.
        /// </returns>
        public static bool Contains <TValue>(this ViewDataDictionary instance)
        {
            Invariant.IsNotNull(instance, "instance");

            return(instance.ContainsKey(MakeKey <TValue>()));
        }
Beispiel #7
0
        /// <summary>
        /// Actions the name.
        /// </summary>
        /// <param name="instance">The instance.</param>
        /// <returns></returns>
        public static string ActionName(this RouteData instance)
        {
            Invariant.IsNotNull(instance, "instance");

            return(instance.GetRequiredString("action"));
        }
Beispiel #8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ExtendedModelMetadataProvider"/> class.
        /// </summary>
        /// <param name="registry">The registry.</param>
        public ExtendedModelMetadataProvider(IModelMetadataRegistry registry)
        {
            Invariant.IsNotNull(registry, "registry");

            this.registry = registry;
        }
        protected virtual ModelMetadataItem Append <TType>([NotNull] Expression <Func <TModel, TType> > expression)
        {
            Invariant.IsNotNull(expression, "expression");

            return(Append(ExpressionHelper.GetExpressionText(expression)));
        }
Beispiel #10
0
        /// <summary>
        /// Controllers the name.
        /// </summary>
        /// <param name="instance">The instance.</param>
        /// <returns></returns>
        public static string ControllerName(this RouteData instance)
        {
            Invariant.IsNotNull(instance, "instance");

            return(instance.GetRequiredString("controller"));
        }
        public static IServiceRegistrar RegisterAsPerRequest([NotNull] this IServiceRegistrar instance, Type serviceType, Type implementationType)
        {
            Invariant.IsNotNull(instance, "instance");

            return(instance.RegisterType(serviceType, implementationType, LifetimeType.PerRequest));
        }
        public static IServiceRegistrar RegisterInstance([NotNull] this IServiceRegistrar instance, [NotNull] object service)
        {
            Invariant.IsNotNull(instance, "instance");

            return(instance.RegisterInstance(service.GetType(), service));
        }
        public static IServiceRegistrar RegisterInstance <TService>([NotNull] this IServiceRegistrar instance, TService service)
        {
            Invariant.IsNotNull(instance, "instance");

            return(instance.RegisterInstance(typeof(TService), service));
        }
Beispiel #14
0
 protected ModelMetadataItemBuilder <object> Configure([NotNull] string property)
 {
     Invariant.IsNotNull(property, "property");
     return(GetOrCreate <object>(property));
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="RegisterFilterProviders"/> class.
        /// </summary>
        /// <param name="container">The container.</param>
        public RegisterFilterProviders(ContainerAdapter container)
        {
            Invariant.IsNotNull(container, "container");

            Container = container;
        }
Beispiel #16
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ModelMetadataItemBuilder{TValue}"/> class.
        /// </summary>
        /// <param name="item">The item.</param>
        public ModelMetadataItemBuilder(ModelMetadataItem item)
        {
            Invariant.IsNotNull(item, "item");

            Item = item;
        }
Beispiel #17
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RegisterModelBinders"/> class.
        /// </summary>
        /// <param name="container">The container.</param>
        public RegisterModelBinders(ContainerAdapter container)
        {
            Invariant.IsNotNull(container, "container");

            Container = container;
        }
        /// <summary>
        /// Removes the specified type.
        /// </summary>
        /// <typeparam name="TValue">The type of the value.</typeparam>
        /// <param name="instance">The instance.</param>
        public static bool Remove <TValue>(this ViewDataDictionary instance)
        {
            Invariant.IsNotNull(instance, "instance");

            return(instance.Remove(MakeKey <TValue>()));
        }
Beispiel #19
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ExtendedControllerActionInvoker"/> class.
        /// </summary>
        /// <param name="container">The container.</param>
        public ExtendedControllerActionInvoker(ContainerAdapter container)
        {
            Invariant.IsNotNull(container, "container");

            Container = container;
        }
        /// <summary>
        /// Sets the value against the specified key.
        /// </summary>
        /// <typeparam name="TValue">The type of the value.</typeparam>
        /// <param name="instance">The instance.</param>
        /// <param name="key">The key.</param>
        /// <param name="value">The value.</param>
        public static void Set <TValue>(this ViewDataDictionary instance, string key, TValue value)
        {
            Invariant.IsNotNull(instance, "instance");

            instance[key] = value;
        }
Beispiel #21
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ConfigureFiltersBase"/> class.
        /// </summary>
        /// <param name="registry">The registry.</param>
        protected ConfigureFiltersBase([NotNull] IFilterRegistry registry)
        {
            Invariant.IsNotNull(registry, "registry");

            Registry = registry;
        }
Beispiel #22
0
        private static bool IsNullable(Type type)
        {
            Invariant.IsNotNull(type, "type");

            return(type.IsGenericType && type.GetGenericTypeDefinition().Equals(typeof(Nullable <>)));
        }
Beispiel #23
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RegisterViews"/> class.
        /// </summary>
        /// <param name="container">The container.</param>
        public RegisterViews([NotNull] ContainerAdapter container)
        {
            Invariant.IsNotNull(container, "container");

            Container = container;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="RegisterActionInvokers"/> class.
        /// </summary>
        /// <param name="container">The container.</param>
        public RegisterActionInvokers(ContainerAdapter container)
        {
            Invariant.IsNotNull(container, "container");

            Container = container;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="RegisterRoutesBase"/> class.
        /// </summary>
        /// <param name="routes">The routes.</param>
        protected RegisterRoutesBase(RouteCollection routes)
        {
            Invariant.IsNotNull(routes, "routes");

            Routes = routes;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="RegisterControllers"/> class.
        /// </summary>
        /// <param name="container">The container.</param>
        public RegisterControllers(ContainerAdapter container)
        {
            Invariant.IsNotNull(container, "container");

            Container = container;
        }
Beispiel #27
0
 /// <summary>
 /// Register configuration types from the assembly containing type
 /// </summary>
 /// <param name="type"></param>
 /// <returns></returns>
 public static IEnumerable <Assembly> AssemblyContainingType(Type type)
 {
     Invariant.IsNotNull(type, "type");
     yield return(type.Assembly);
 }
        /// <summary>
        /// Handles the unauthorized request.
        /// </summary>
        /// <param name="filterContext">The filter context.</param>
        protected virtual void HandleUnauthorized(AuthorizationContext filterContext)
        {
            Invariant.IsNotNull(filterContext, "filterContext");

            filterContext.Result = new HttpUnauthorizedResult();
        }
Beispiel #29
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RegisterModelMetadata"/> class.
        /// </summary>
        /// <param name="container">The container.</param>
        public RegisterModelMetadata([NotNull] ContainerAdapter container)
        {
            Invariant.IsNotNull(container, "container");

            Container = container;
        }