Пример #1
0
        /// <summary>
        /// Initialise the core dbcontext, the collator, the repository and the editor redirect for a content type
        /// </summary>
        /// <param name="t">content type</param>
        /// <param name="coll">the collator</param>
        /// <param name="repo">the repository</param>
        /// <param name="redir">the editor redirect</param>
        public void SetupType(Type t, ICollator coll, IRepository repo, IEditorRedirect redir)
        {
            CompositeTypeManager.Instance.RegisterType(t);

            if (coll != null)
            {
                coll.Repository = this.Repository;
                this.Register(t, coll);
            }

            if (repo != null)
            {
                Lynicon.Repositories.Repository.Instance.Register(t, repo);
            }
            if (redir != null)
            {
                EditorRedirect.Instance.Register(t, redir);
            }
        }
Пример #2
0
        /// <summary>
        /// Add a DataRoute to an AreaRegistractionContext with route name, url pattern, default values and specific EditorRedirect to use
        /// </summary>
        /// <typeparam name="TData">The type of the content data attached by the DataRoute</typeparam>
        /// <param name="areaReg">An AreaRegistrationContext</param>
        /// <param name="name">Name of the route table entry</param>
        /// <param name="url">The url matching pattern</param>
        /// <param name="defaults">Default values for unmatched pattern elements</param>
        /// <param name="constraints">Constraints for when the route should match</param>
        /// <param name="dataTokens">Data tokens to add to the route</param>
        /// <param name="redirectOverride">An editor redirect to use with this route</param>
        /// <returns>The DataRoute that was created and registered</returns>
        static public DataRoute <TData> AddDataRoute <TData>(this AreaRegistrationContext areaReg, string name, string url, object defaults, object constraints, object dataTokens, IEditorRedirect redirectOverride)
            where TData : class, new()
        {
            ValidateRouteSpec(name, typeof(TData), url, defaults);
            ContentTypeHierarchy.RegisterType(typeof(TData));
            DataRoute <TData> route = areaReg.Routes.AddDataRoute <TData>(name, url, defaults, constraints, dataTokens, redirectOverride);

            route.DataTokens["area"] = areaReg.AreaName;

            // disabling the namespace lookup fallback mechanism keeps this areas from accidentally picking up
            // controllers belonging to other areas
            //bool useNamespaceFallback = (namespaces == null || namespaces.Length == 0);
            //route.DataTokens["UseNamespaceFallback"] = useNamespaceFallback;
            return(route);
        }
Пример #3
0
        /// <summary>
        /// Add a DataRoute to an RouteCollection with route name, url pattern, default values and constraints
        /// </summary>
        /// <typeparam name="TData">The type of the content data attached by the DataRoute</typeparam>
        /// <param name="routes">A RouteCollection to add the route to</param>
        /// <param name="name">Name of the route table entry</param>
        /// <param name="url">The url matching pattern</param>
        /// <param name="defaults">Default values for unmatched pattern elements</param>
        /// <param name="constraints">Constraints for when the route should match</param>
        /// <param name="dataTokens">Data tokens to add to the route</param>
        /// <param name="redirectOverride">An editor redirect to use with this route</param>
        /// <returns>The DataRoute that was created and registered</returns>
        static public DataRoute <TData> AddDataRoute <TData>(this RouteCollection routes, string name, string url, object defaults, object constraints, object dataTokens, IEditorRedirect redirectOverride)
            where TData : class, new()
        {
            ValidateRouteSpec(name, typeof(TData), url, defaults);
            ContentTypeHierarchy.RegisterType(typeof(TData));
            var route = new DataRoute <TData>(url, new RouteValueDictionary(defaults), new RouteValueDictionary(constraints), new RouteValueDictionary(dataTokens), new MvcRouteHandler());

            if (redirectOverride != null)
            {
                route.RedirectOverride = redirectOverride;
            }
            routes.Add(name, route);
            return(route);
        }
Пример #4
0
 /// <summary>
 /// Initialise the core dbcontext, the collator, the repository and the editor redirect for a content type
 /// </summary>
 /// <typeparam name="T">content type</typeparam>
 /// <param name="coll">the collator</param>
 /// <param name="repo">the repository</param>
 /// <param name="redir">the editor redirect</param>
 public void SetupType <T>(ICollator coll, IRepository repo, IEditorRedirect redir)
 {
     SetupType(typeof(T), coll, repo, redir);
 }