Ejemplo n.º 1
0
        public static TempReflection ObjectFields(Type type)
        {
            var            fs   = type.GetFields();
            TempReflection temp = new TempReflection();

            temp.Top = fs.Length;
            ReflectionModel[] reflections = new ReflectionModel[temp.Top];
            for (int i = 0; i < fs.Length; i++)
            {
                ReflectionModel r = new ReflectionModel();
                r.field        = fs[i];
                r.FieldType    = fs[i].FieldType;
                r.name         = fs[i].Name;
                reflections[i] = r;
            }
            temp.All = reflections;
            return(temp);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 将类型中的所有公开字段转换成临时反射类
        /// </summary>
        /// <param name="type">类型</param>
        /// <returns></returns>
        public static TempReflection ObjectFields(Type type)
        {
            var            fs   = type.GetFields();
            TempReflection temp = new TempReflection();

            List <ReflectionModel> list = new List <ReflectionModel>();

            for (int i = 0; i < fs.Length; i++)
            {
                if (!fs[i].IsNotSerialized)
                {
                    ReflectionModel r = new ReflectionModel();
                    r.field     = fs[i];
                    r.FieldType = fs[i].FieldType;
                    r.name      = fs[i].Name;
                    list.Add(r);
                }
            }
            temp.Top = list.Count;
            temp.All = list.ToArray();
            return(temp);
        }