Esempio n. 1
0
        public void AddQueryInput(Expression <Func <T, object> > expression)
        {
            var accessor = ReflectionHelper.GetAccessor(expression);
            var input    = new RouteParameter(accessor);

            _queryParameters.Add(input);
        }
Esempio n. 2
0
        public void AddQueryInput(PropertyInfo property)
        {
            Accessor accessor = new SingleProperty(property);
            var      input    = new RouteParameter(accessor);

            _queryParameters.Add(input);
        }
Esempio n. 3
0
        private static void populateRoute(string pattern, Type inputType, IRouteInput input)
        {
            parse(pattern, (propName, defaultValue) =>
            {
                PropertyInfo property = inputType.GetProperty(propName);
                if (property == null)
                {
                    throw new FubuException(1002, "Url pattern \"{0}\" refers to non-existent property {1} on {2}.",
                                            pattern, propName, inputType.FullName);
                }
                var parameter = new RouteParameter(new SingleProperty(property))
                {
                    DefaultValue = defaultValue
                };

                input.AddRouteInput(parameter, false);
            });

            // Populate the remaining QueryString parameters
            var props = inputType.GetProperties();

            foreach (var propertyInfo in props)
            {
                PropertyInfo info = propertyInfo;
                if (propertyInfo.HasAttribute <QueryStringAttribute>() &&
                    !input.RouteParameters.Any(p => p.Name == info.Name))
                {
                    input.AddQueryInput(propertyInfo);
                }
            }
        }
Esempio n. 4
0
        public void AddRouteInput(Expression <Func <T, object> > expression)
        {
            var accessor = ReflectionHelper.GetAccessor(expression);
            var input    = new RouteParameter(accessor);

            if (_routeParameters.Any(x => x.Name == input.Name))
            {
                return;
            }

            _routeParameters.Add(input);
        }
Esempio n. 5
0
 public bool Equals(RouteParameter other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(Equals(other._accessor, _accessor));
 }
Esempio n. 6
0
        public void AddQueryInput(PropertyInfo property)
        {
            Accessor accessor = new SingleProperty(property);
            var      input    = new RouteParameter(accessor);

            if (Parent != null)
            {
                Parent.Trace("Added '{0}' to query string parameters", input);
            }

            _queryParameters.Fill(input);
        }
Esempio n. 7
0
        public void AddRouteInput(RouteParameter parameter, bool appendToUrl)
        {
            if (_routeParameters.Any(x => x.Name == parameter.Name))
            {
                return;
            }

            if (appendToUrl)
            {
                _parent.Append("{" + parameter.Name + "}");
            }

            _routeParameters.Add(parameter);
        }
Esempio n. 8
0
        private static void populateRoute(string pattern, Type inputType, IRouteInput input)
        {
            parse(pattern, (propName, defaultValue) =>
            {
                PropertyInfo property = inputType.GetProperty(propName);
                if (property == null)
                {
                    throw new FubuException(1002, "Url pattern \"{0}\" refers to non-existent property {1} on {2}.",
                                            pattern, propName, inputType.FullName);
                }
                var parameter = new RouteParameter(new SingleProperty(property))
                {
                    DefaultValue = defaultValue
                };

                input.AddRouteInput(parameter, false);
            });
        }
Esempio n. 9
0
        public void AddRouteInput(RouteParameter parameter, bool appendToUrl)
        {
            if (_routeParameters.Any(x => x.Name == parameter.Name))
            {
                return;
            }

            if (appendToUrl)
            {
                _parent.Append("{" + parameter.Name + "}");
            }

            if (Parent != null)
            {
                Parent.Trace("Added '{0}' to route parameters", parameter);
            }

            _routeParameters.Add(parameter);
        }
Esempio n. 10
0
        public void route_input_should_substitute_method()
        {
            SingleProperty accessor = SingleProperty.Build<SampleViewModel>(x => x.InPath);
            var viewModel = new SampleViewModel
            {
                InPath = "5"
            };
            var routeInput = new RouteParameter(accessor);

            routeInput.Substitute(viewModel, "test/edit/{InPath}").ShouldEqual("test/edit/5");
        }
Esempio n. 11
0
 public bool Equals(RouteParameter other)
 {
     if (ReferenceEquals(null, other)) return false;
     if (ReferenceEquals(this, other)) return true;
     return Equals(other._accessor, _accessor);
 }
Esempio n. 12
0
 public void SetUp()
 {
     _parameter = new RouteParameter(ReflectionHelper.GetAccessor<FakeInput>(x => x.Code));
 }