private object[] GetItemValues(System.Type childRuntimeType)
        {
            TypeDecoratorList type = (decorator as TypeDecoratorList);

            if (null == type || string.IsNullOrEmpty(value))
            {
                return(new object[0]);
            }

            if (type.flag < 0)
            {
                throw new System.Exception(string.Format("value depth is overflow, max depth is 2"));
            }

            char split = type.flag == 0 ? Define.UserDefine.global.excel.splitFlag0 : Define.UserDefine.global.excel.splitFlag1;

            string[] str_values = value.Split(split);
            int      count      = str_values.Length;

            object[] obj_values = new object[count];

            TypeDecorator child = type.child;

            child.runtimeType = childRuntimeType;
            for (int i = 0; i < count; i++)
            {
                obj_values[i] = ValueAdapter.Adapter(str_values[i], child);
            }
            return(obj_values);
        }
示例#2
0
        public override object GetValue()
        {
            TypeDecoratorList itemsDecorator = TypeAdapter.Adapter("[float]") as TypeDecoratorList;

            itemsDecorator.runtimeType = typeof(List <float>);
            itemsDecorator.ResetFlag(1);
            object       vs     = ValueAdapter.Adapter(value, itemsDecorator);
            List <float> realvs = vs as List <float>;

            BindingFlags flags = BindingFlags.Public | BindingFlags.Instance;
            object       v2    = Common.Utility.Reflection.CreateInstance(decorator.runtimeType);

            Common.Utility.Reflection.SetValue(decorator.runtimeType, "x", v2, realvs.Count > 0 ? realvs[0] : 0, flags);
            Common.Utility.Reflection.SetValue(decorator.runtimeType, "y", v2, realvs.Count > 1 ? realvs[1] : 0, flags);
            return(v2);
        }
        public override object GetValue()
        {
            TypeDecoratorList itemsDecorator = TypeAdapter.Adapter("[int]") as TypeDecoratorList;

            itemsDecorator.runtimeType = typeof(List <int>);
            itemsDecorator.ResetFlag(1);
            object     vs     = ValueAdapter.Adapter(value, itemsDecorator);
            List <int> realvs = vs as List <int>;
            int        r      = realvs.Count > 0 ? realvs[0] : 0;
            int        g      = realvs.Count > 1 ? realvs[1] : 0;
            int        b      = realvs.Count > 2 ? realvs[2] : 0;
            int        a      = realvs.Count > 3 ? realvs[3] : 255;

            BindingFlags flags = BindingFlags.Public | BindingFlags.Instance;
            object       Color = Common.Utility.Reflection.CreateInstance(decorator.runtimeType);

            Common.Utility.Reflection.SetValue(decorator.runtimeType, "r", Color, (float)r / 255f, flags);
            Common.Utility.Reflection.SetValue(decorator.runtimeType, "g", Color, (float)g / 255f, flags);
            Common.Utility.Reflection.SetValue(decorator.runtimeType, "b", Color, (float)b / 255f, flags);
            Common.Utility.Reflection.SetValue(decorator.runtimeType, "a", Color, (float)a / 255f, flags);
            return(Color);
        }
示例#4
0
        private object[] GetItemValues(TypeDecorator type, System.Type runtimeType, string[] values)
        {
            if (TypeAdapter.IsContainer(type.typeDecotrator))
            {
                throw new Exception(string.Format("map key or value type is container, the type is {0}.", type.GetName()));
            }

            if (null == runtimeType || null == values || values.Length < 1)
            {
                return(new object[0]);
            }

            int count = values.Length;

            object[] obj_values = new object[count];

            type.runtimeType = runtimeType;
            for (int i = 0; i < count; i++)
            {
                obj_values[i] = ValueAdapter.Adapter(values[i], type);
            }
            return(obj_values);
        }