コード例 #1
0
 private static ActionDescriptor GetActionDescriptor(ControllerBase controller, RouteData routeData)
 {
     var controllerDescriptor = new ReflectedControllerDescriptor(controller.GetType());
     var actionName = routeData.GetRequiredString("action");
     var actionDescriptor = controllerDescriptor.FindAction(controller.ControllerContext, actionName);
     return actionDescriptor;
 }
コード例 #2
0
ファイル: GetCogHandler.cs プロジェクト: averyj/cogs
        private Cog GetRequestedCog(RouteData routeData)
        {
            string package = routeData.GetRequiredString("package");

            if (routeData.Values.ContainsKey("version"))
                return Cogs.GetCog(package, new Version(routeData.Values["version"].ToString()));
            else
                return Cogs.GetCog(package);
        }
コード例 #3
0
ファイル: Log.cs プロジェクト: stevenbey/beyond.utilities
        protected Log(RouteData data, HttpContextBase context) : base(context)
        {
            if (data == null) return;
            
            var route = data.Route as Route;
            if (route != null)
            {
                this.RouteConstraints = new Dictionary(route.Constraints);
                this.RouteDefaults = new Dictionary(route.Defaults);
                this.RouteUrl = route.Url;
            }

            this.RouteData = new Dictionary(data.Values);
            this.DataTokens = new Dictionary(data.DataTokens);

            this.Action = data.GetRequiredString("action").ToPascal();
            this.Controller = data.GetRequiredString("controller").ToPascal();
            this.Area = this.DataTokens.ContainsKey("area") ? this.DataTokens["area"].ToPascal() : string.Empty;
        }
コード例 #4
0
        protected virtual string GetAreaName(System.Web.Routing.RouteData routeData)
        {
            if (routeData.Values.ContainsKey("pluginName"))
            {
                var pluginName = routeData.GetRequiredString("pluginName");
                return(pluginName);
            }

            object obj2;

            if (routeData.DataTokens.TryGetValue("area", out obj2))
            {
                return(obj2 as string);
            }
            return(GetAreaName(routeData.Route));
        }
コード例 #5
0
		public override ControllerMeta Create(RouteData data)
		{
			TypedControllerMeta meta = null;

			var accessor = httpContext.ApplicationInstance as IContainerAccessor;
			if (accessor != null)
			{
				var container = accessor.Container;
				var controllerName = data.GetRequiredString("controller").ToLowerInvariant();

				if (!container.Kernel.HasComponent(controllerName)) return null;

				var args = CreateArgs();
				var controller = container.Resolve<object>(controllerName, args);

				var descriptor = DescriptorBuilder.Build(controller.GetType());

				meta = new TypedControllerMeta(controller, descriptor);
			}

			return meta;
		}
コード例 #6
0
 private static string GetActionName(RouteData routeData)
 {
     //if (DirectRouteExtensions.HasDirectRouteMatch(routeData)) return null;
     try
     {
         return routeData.GetRequiredString("action");
     }
     catch
     {
         return null;
     }
 }
コード例 #7
0
		public MetaTable GetTableFromRouteData (RouteData routeData)
		{
			if (routeData == null)
				throw new ArgumentNullException ("routeData");
			var t = routeData.GetRequiredString ("Table");
			if (Model == null)
				throw new InvalidOperationException ("MetaModel must be set to the DynamicDataRoute before retrieving MetaTable");

			return Model.GetTable (t);
		}
コード例 #8
0
		public string GetActionFromRouteData (RouteData routeData)
		{
			if (routeData == null)
				throw new ArgumentNullException ("routeData");
			return routeData.GetRequiredString ("Action");
		}
コード例 #9
0
 private bool RouteRequiresPublicCaching(RouteData routeData)
 {
     if (routeData == null)
     {
         return false;
     }
     
     try
     {
         var controller = routeData.GetRequiredString("controller");
         var action = routeData.GetRequiredString("action");
         return (controller == "Help" && action == "Index");
     }
     catch
     {
         // request may be for asset
         return false;
     }
 }
コード例 #10
0
 private static string GetViewName(RouteData routeData, string viewName)
 {
     return !string.IsNullOrEmpty(viewName)
            	? viewName
            	: routeData.GetRequiredString("action");
 }
コード例 #11
0
 /// <summary>
 /// Extract the MetaTable from the RouteData. Fails if it can't find it
 /// </summary>
 /// <param name="routeData">The route data</param>
 /// <returns>The found MetaTable</returns>
 public MetaTable GetTableFromRouteData(RouteData routeData) {
     string tableName = routeData.GetRequiredString(TableToken);
     return Model.GetTable(tableName);
 }
コード例 #12
0
ファイル: RouteDataTest.cs プロジェクト: nobled/mono
		public void GetRequiredStringNull ()
		{
			var d = new RouteData ();
			d.GetRequiredString (null);
		}
コード例 #13
0
        protected virtual string GetAreaName(RouteData routeData)
        {
            if (routeData.Values.ContainsKey("pluginName"))
            {
                var pluginName = routeData.GetRequiredString("pluginName");
                return pluginName;
            }

            object obj2;
            if (routeData.DataTokens.TryGetValue("area", out obj2))
            {
                return (obj2 as string);
            }
            return GetAreaName(routeData.Route);
        }
コード例 #14
0
 private static bool IsActionValid(IEnumerable<string> actionNames, RouteData routeData)
 {
     return ((actionNames == null) || actionNames.Contains(routeData.GetRequiredString("action")));
 }
コード例 #15
0
 public static bool CurrentPageIsBasket(RouteData routeData) 
 {
     return routeData.GetRequiredString("controller").IsCaseInsensitiveEqual("ShoppingCart")
         && routeData.GetRequiredString("action").IsCaseInsensitiveEqual("Cart");
 }
コード例 #16
0
 private static IEnumerable<string> PathForFeatureBundle(RouteData routeData, string extension)
 {
     if (!routeData.DataTokens.ContainsKey("area"))
     {
         return PathForFeatureBundle(
             routeData.GetRequiredString("action"),
             routeData.GetRequiredString("controller"),
             extension);
     }
     else
     {
         return PathForFeatureBundle(
             routeData.GetRequiredString("action"),
             routeData.GetRequiredString("controller"),
             routeData.DataTokens["area"] as string,
             extension);
     }
 }
コード例 #17
0
ファイル: RouteDataTest.cs プロジェクト: nobled/mono
		public void GetRequiredStringNonexistent ()
		{
			var d = new RouteData ();
			d.GetRequiredString ("a");
		}
コード例 #18
0
ファイル: RouteDataTest.cs プロジェクト: nobled/mono
		public void GetRequiredStringForNonStringValue ()
		{
			var d = new RouteData ();
			d.Values.Add ("a", 10);
			Assert.AreEqual ("10", d.GetRequiredString ("a"));
		}
コード例 #19
0
ファイル: RouteDataTest.cs プロジェクト: nobled/mono
		public void GetRequiredStringExistent ()
		{
			var d = new RouteData ();
			d.Values.Add ("a", "x");
			Assert.AreEqual ("x", d.GetRequiredString ("a"));
		}
コード例 #20
0
 private static bool IsControllerValid(string controllerName, RouteData routeData)
 {
     return ((String.IsNullOrEmpty(controllerName)) || (routeData.GetRequiredString("controller") == controllerName));
 }
コード例 #21
0
        public static string SortableColumn(this HtmlHelper htmlHelper, string linkText, string columnName, object routeValues)
        {
            //automatically determine the current action
            System.Web.Routing.RouteData data = htmlHelper.ViewContext.Controller.ControllerContext.RouteData;
            string actionName = data.GetRequiredString("action");

            StringBuilder sb   = new StringBuilder();
            var           vals = new RouteValueDictionary(routeValues);

            string sidx = String.Empty;

            if (System.Web.HttpContext.Current.Request["sidx"] != null)
            {
                sidx = System.Web.HttpContext.Current.Request["sidx"].ToString();
            }

            //modify the sidx
            if (vals.ContainsKey("sidx") == false)
            {
                vals.Add("sidx", columnName);
            }
            else
            {
                vals["sidx"] = columnName;
            }

            //get the sort order from the request variable if it exists
            string sord = String.Empty;

            if (System.Web.HttpContext.Current.Request["sord"] != null)
            {
                sord = System.Web.HttpContext.Current.Request["sord"].ToString();
            }

            //add the sord key if needed
            if (vals.ContainsKey("sord") == false)
            {
                vals.Add("sord", String.Empty);
            }

            //if column matches
            if (sidx.Equals(columnName, StringComparison.CurrentCultureIgnoreCase) == true)
            {
                if (sord.Equals("asc", StringComparison.CurrentCultureIgnoreCase) == true)
                {
                    //draw the ascending sort indicator using the wingdings font.
                    sb.Append(" <font face='Wingdings 3'>&#112;</font>");
                    vals["sord"] = "desc";
                }
                else
                {
                    sb.Append(" <font face='Wingdings 3'>&#113;</font>");
                    vals["sord"] = "asc";
                }
            }
            else
            {
                //if the column does not match then force the next sort to ascending order
                vals["sord"] = "asc";
            }

            //Use the ActionLink to build the link and insert it into the string
            sb.Insert(0, System.Web.Mvc.Html.LinkExtensions.ActionLink(htmlHelper, linkText, actionName, vals));
            return(sb.ToString());
        }
コード例 #22
0
 /// <summary>
 /// Extract the Action from the RouteData. Fails if it can't find it
 /// </summary>
 /// <param name="routeData">The route data</param>
 /// <returns>The found Action</returns>
 public string GetActionFromRouteData(RouteData routeData) {
     return routeData.GetRequiredString(ActionToken);
 }
コード例 #23
0
ファイル: ViewPromptKey.cs プロジェクト: paulzhousz/YOYOHRMS
        public static string GetViewPath(RouteData routeData)
        {
            if (routeData == null) throw new ArgumentNullException("routeData");

            var controllerName = routeData.GetRequiredString("Controller");
            var actionName = routeData.GetRequiredString("Action");
            var area = routeData.Values["area"] ?? routeData.DataTokens["area"];
            return area != null
                       ? string.Format("/{0}/{1}/{2}", area, controllerName, actionName)
                       : string.Format("/{0}/{1}", controllerName, actionName);
        }