Beispiel #1
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);
                }
            }
        }
Beispiel #2
0
        public void ApplyInputType(Type inputType)
        {
            if (inputType.CanBeCastTo <ResourcePath>())
            {
                return;
            }

            Input = RouteBuilder.Build(inputType, Pattern).Input;
        }
Beispiel #3
0
        public static void PopulateQuerystringParameters(Type inputType, IRouteInput input)
        {
            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);
                }
            }
        }
Beispiel #4
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);
            });
        }
        public void ApplyInputType(Type inputType)
        {
            if (inputType.CanBeCastTo<ResourcePath>()) return;

            Input = RouteBuilder.Build(inputType, Pattern).Input;
        }
Beispiel #6
0
 public void ApplyInputType(Type inputType)
 {
     Input = RouteBuilder.Build(inputType, Pattern).Input;
 }