Beispiel #1
0
        private bool GetClassValue(System.Collections.Specialized.NameValueCollection data, string Prefix, out object value)
        {
            IConvert convert = null;

            value = null;
            Type createtype = Info.ParameterType;

            if (Binder != null && Binder.Convert == null && Binder.Fungible != null)
            {
                createtype = Binder.Fungible;
            }
            bool succed = false;

            if (Binder != null && !string.IsNullOrEmpty(Binder.Prefix))
            {
                Prefix = Binder.Prefix;
            }
            if (Binder != null)
            {
                convert = Binder.GetConvert();
            }
            if (convert == null)
            {
                if (BindUtils.Converts.ContainsKey(createtype))
                {
                    convert = BindUtils.Converts[createtype];
                }
            }
            if (convert != null)
            {
                value = convert.Parse(data, Info.Name, Prefix, out succed);
            }
            else if (createtype.IsArray)
            {
                if (createtype.GetElementType().IsEnum)
                {
                    Type     toenumtype = typeof(ToEnumArray <>).MakeGenericType(createtype.GetElementType());
                    IConvert tea        = (IConvert)Activator.CreateInstance(toenumtype);
                    BindUtils.AddCustomConvert(toenumtype, tea);
                    value = tea.Parse(data, Info.Name, Prefix, out succed);
                }
            }
            else
            {
                if (createtype.IsClass && !createtype.IsInterface &&
                    !createtype.IsAbstract)
                {
                    ClassBinder cb = BindUtils.GetBinder(createtype);
                    succed = true;
                    value  = cb.CreateObject(data, Prefix);
                }
            }

            return(succed);
        }
Beispiel #2
0
        public bool GetClassValue(System.Collections.Specialized.NameValueCollection data, string Prefix, out object value)
        {
            IConvert convert = null;

            value = null;
            Type createtype = Handler.Property.PropertyType;

            if (Binder != null && Binder.Convert == null && Binder.Fungible != null)
            {
                createtype = Binder.Fungible;
            }
            bool succed = false;

            if (Binder != null && !string.IsNullOrEmpty(Binder.Prefix))
            {
                Prefix = Binder.Prefix;
            }
            if (Binder != null)
            {
                convert = Binder.GetConvert();
            }
            if (convert == null)
            {
                if (BindUtils.Converts.ContainsKey(createtype))
                {
                    convert = BindUtils.Converts[createtype];
                }
            }
            if (convert != null)
            {
                value = convert.Parse(data, Handler.Property.Name, Prefix, out succed);
            }
            else
            {
                if (createtype.IsClass && !createtype.IsInterface &&
                    !createtype.IsAbstract)
                {
                    if (createtype.IsArray)
                    {
                        succed = true;
                        value  = Activator.CreateInstance(createtype, 0);
                    }
                    else
                    {
                        ClassBinder cb = BindUtils.GetBinder(createtype);
                        succed = true;
                        value  = cb.CreateObject(data, Prefix);
                    }
                }
            }

            return(succed);
        }
Beispiel #3
0
        internal static object CreateInstance(Type type, NameValueCollection data, string prefix)
        {
            object result;

            if (BindUtils.Converts.ContainsKey(type))
            {
                IConvert convert = BindUtils.Converts[type];
                bool     flag;
                result = convert.Parse(data, null, prefix, out flag);
            }
            else
            {
                ClassBinder binder = BindUtils.GetBinder(type);
                result = binder.CreateObject(data, prefix);
            }
            return(result);
        }
Beispiel #4
0
        internal static void Full(object obj, NameValueCollection data, string prefix, bool ispostback)
        {
            ClassBinder binder = BindUtils.GetBinder(obj.GetType());

            binder.FullData(obj, data, prefix, ispostback);
        }