Ejemplo n.º 1
0
        /// <inheritdoc />
        public virtual string Action(UrlActionContext actionContext)
        {
            var valuesDictionary = PropertyHelper.ObjectToDictionary(actionContext.Values);

            if (actionContext.Action == null)
            {
                object action;
                if (!valuesDictionary.ContainsKey("action") &&
                    AmbientValues.TryGetValue("action", out action))
                {
                    valuesDictionary["action"] = action;
                }
            }
            else
            {
                valuesDictionary["action"] = actionContext.Action;
            }

            if (actionContext.Controller == null)
            {
                object controller;
                if (!valuesDictionary.ContainsKey("controller") &&
                    AmbientValues.TryGetValue("controller", out controller))
                {
                    valuesDictionary["controller"] = controller;
                }
            }
            else
            {
                valuesDictionary["controller"] = actionContext.Controller;
            }

            var path = GeneratePathFromRoute(valuesDictionary);

            if (path == null)
            {
                return(null);
            }

            return(GenerateUrl(actionContext.Protocol, actionContext.Host, path, actionContext.Fragment));
        }
Ejemplo n.º 2
0
        /// <inheritdoc />
        public virtual string Action(UrlActionContext actionContext)
        {
            var valuesDictionary = PropertyHelper.ObjectToDictionary(actionContext.Values);

            if (actionContext.Action == null)
            {
                object action;
                if (!valuesDictionary.ContainsKey("action") && 
                    AmbientValues.TryGetValue("action", out action))
                {
                    valuesDictionary["action"] = action;
                }
            }
            else
            {
                valuesDictionary["action"] = actionContext.Action;
            }

            if (actionContext.Controller == null)
            {
                object controller;
                if (!valuesDictionary.ContainsKey("controller") && 
                    AmbientValues.TryGetValue("controller", out controller))
                {
                    valuesDictionary["controller"] = controller;
                }
            }
            else
            {
                valuesDictionary["controller"] = actionContext.Controller;
            }

            var path = GeneratePathFromRoute(valuesDictionary);
            if (path == null)
            {
                return null;
            }

            return GenerateUrl(actionContext.Protocol, actionContext.Host, path, actionContext.Fragment);
        }
Ejemplo n.º 3
0
        /// <inheritdoc />
        public virtual string Action(UrlActionContext actionContext)
        {
            var valuesDictionary = PropertyHelper.ObjectToDictionary(actionContext.Values);

            if (actionContext.Action != null)
            {
                valuesDictionary["action"] = actionContext.Action;
            }

            if (actionContext.Controller != null)
            {
                valuesDictionary["controller"] = actionContext.Controller;
            }

            var path = GeneratePathFromRoute(valuesDictionary);
            if (path == null)
            {
                return null;
            }

            return GenerateUrl(actionContext.Protocol, actionContext.Host, path, actionContext.Fragment);
        }
Ejemplo n.º 4
0
        public void UrlActionWithUrlActionContext_ReturnsExpectedResult()
        {
            // Arrange
            var services  = GetServices();
            var urlHelper = CreateUrlHelperWithRouteCollection(services, "/app");

            var actionContext = new UrlActionContext()
            {
                Action     = "contact",
                Controller = "home3",
                Values     = new { id = "idone" },
                Protocol   = "ftp",
                Host       = "remotelyhost",
                Fragment   = "somefragment"
            };

            // Act
            var url = urlHelper.Action(actionContext);

            // Assert
            Assert.Equal("ftp://remotelyhost/app/home3/contact/idone#somefragment", url);
        }
Ejemplo n.º 5
0
        /// <inheritdoc />
        public virtual string Action(UrlActionContext actionContext)
        {
            var valuesDictionary = PropertyHelper.ObjectToDictionary(actionContext.Values);

            if (actionContext.Action != null)
            {
                valuesDictionary["action"] = actionContext.Action;
            }

            if (actionContext.Controller != null)
            {
                valuesDictionary["controller"] = actionContext.Controller;
            }

            var path = GeneratePathFromRoute(valuesDictionary);

            if (path == null)
            {
                return(null);
            }

            return(GenerateUrl(actionContext.Protocol, actionContext.Host, path, actionContext.Fragment));
        }
Ejemplo n.º 6
0
 public override string Action(UrlActionContext actionContext)
 {
     return ConvertToLowercaseUrl(base.Action(actionContext));
 }
Ejemplo n.º 7
0
 public string Action(UrlActionContext actionContext)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 8
0
        public void UrlActionWithUrlActionContext_ReturnsExpectedResult()
        {
            // Arrange
            var services = GetServices();
            var urlHelper = CreateUrlHelperWithRouteCollection(services, "/app");

            var actionContext = new UrlActionContext()
            {
                Action = "contact",
                Controller = "home3",
                Values = new { id = "idone" },
                Protocol = "ftp",
                Host = "remotelyhost",
                Fragment = "somefragment"
            };

            // Act
            var url = urlHelper.Action(actionContext);

            // Assert
            Assert.Equal("ftp://remotelyhost/app/home3/contact/idone#somefragment", url);
        }
Ejemplo n.º 9
0
 public string Action(UrlActionContext actionContext)
 {
     throw new NotImplementedException();
 }