예제 #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 (ConverCore.Converts.ContainsKey(createtype))
                {
                    convert = ConverCore.Converts[createtype];
                }
            }
            if (convert != null)
            {
                value = convert.Parse(data, Info.Name, Prefix, out succed);
            }
            else if (createtype.IsArray)
            {
                if (createtype.GetElementType().IsEnum)
                {
                    ToEnumArray tea = new ToEnumArray();
                    tea.EnumType = createtype.GetElementType();
                    value        = tea.Parse(data, Info.Name, Prefix, out succed);
                }
            }
            else
            {
                if (createtype.IsClass && !createtype.IsInterface &&
                    !createtype.IsAbstract)
                {
                    ClassBinder cb = ConverCore.GetBinder(createtype);
                    succed = true;
                    value  = cb.CreateObject(data, Prefix);
                }
            }

            return(succed);
        }
예제 #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 (ConverCore.Converts.ContainsKey(createtype))
                {
                    convert = ConverCore.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 = ConverCore.GetBinder(createtype);
                        succed = true;
                        value  = cb.CreateObject(data, Prefix);
                    }
                }
            }

            return(succed);
        }
예제 #3
0
        public static object CreateInstance(Type type, NameValueCollection data, string prefix)
        {
            if (ConverCore.Converts.ContainsKey(type))
            {
                IConvert convert = ConverCore.Converts[type];
                bool     succed;
                return(convert.Parse(data, null, prefix, out succed));
            }
            ClassBinder cb = ConverCore.GetBinder(type);

            return(cb.CreateObject(data, prefix));
        }
예제 #4
0
        public static IList <ValidaterInfo> Validating(object obj, bool throwerr)
        {
            ClassBinder           cb     = ConverCore.GetBinder(obj.GetType());
            IList <ValidaterInfo> result = cb.Validating(obj);

            if (throwerr)
            {
                foreach (ValidaterInfo vi in result)
                {
                    if (vi.State == ValidaterState.Error)
                    {
                        throw new ValidaterException(vi.Message);
                    }
                }
            }
            return(result);
        }
예제 #5
0
        public static IList <ValidaterInfo> Validating(object obj)
        {
            ClassBinder cb = ConverCore.GetBinder(obj.GetType());

            return(cb.Validating(obj));
        }
예제 #6
0
        public static void Full(object obj, NameValueCollection data, string prefix, bool ispostback)
        {
            ClassBinder cb = ConverCore.GetBinder(obj.GetType());

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