Ejemplo n.º 1
0
        protected override bool Request(HandlerParameter input, ref IFormInput result)
        {
            var content = input.PropertyContent;
            var type    = content.Property.PropertyType;

            if (type.IsGenericType && type.GetInterfaces().Contains(typeof(IEnumerable)))
            {
                var itemType = type.GetGenericArguments()[0];
                if (itemType.IsEnum)
                {
                    result = new Inputs.CheckBoxList();
                    input.SetInputProperty(result);
                    result.Init(content, input.Name, input.Value, Util.EnumProvider.Instance.GetDataItems(itemType, input.Source.GetCanNull(input.Name)));
                    return(true);
                }
                else if (ItemHandlers.TryGetValue(itemType, out Func <HandlerParameter, ModelPropertyContent, IFormInput> deal))
                {
                    result = deal(input, content);
                    return(true);
                }
                else if (!itemType.IsClass)
                {
                    result = new Inputs.CheckBoxList();
                    input.SetInputProperty(result);
                    result.Init(content, input.Name, input.Value, input.Source.Get(input.Name));
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 2
0
        protected override bool Request(HandlerParameter input, ref IFormInput result)
        {
            var customInput = input.PropertyContent.Attributes.Get <Annotations.CustomInputAttribute>();

            if (customInput == null)
            {
                return(false);
            }

            var customer = Activator.CreateInstance(customInput.InputType) as ICustomInput;

            customer.Set(customInput.Parameter);

            result = customer;
            input.SetInputProperty(result);
            var options = Util.EnumProvider.Instance.GetDataItems(input.PropertyContent.Property.PropertyType, input.Source.GetCanNull(input.Name));

            result.Init(input.PropertyContent, input.Name, input.Value, options);
            return(true);
        }