Exemplo n.º 1
0
        /// <summary>
        /// 初始化需要扫描的字段集合
        /// </summary>
        /// <param name="scanner">对象扫描</param>
        internal void CreateScanFiled(ReflectionTypeScanner scanner)
        {
            BaseType = (ReflectionObjectType)scanner.GetObjectType(Type.BaseType);

            List <KeyValue <FieldInfo, ReflectionType> > fieldList = null;

            foreach (FieldInfo field in Type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly))
            {
                Type fieldType = field.FieldType;
                if (!fieldType.IsPointer && fieldType != typeof(System.Reflection.Pointer))
                {
                    ReflectionType objectType = scanner.GetObjectType(fieldType);
                    if (objectType.IsScan != 0 || IsScanDerived(fieldType))
                    {
                        if (fieldList == null)
                        {
                            fieldList = new List <KeyValue <FieldInfo, ReflectionType> >();
                        }
                        fieldList.Add(new KeyValue <FieldInfo, ReflectionType>(field, objectType));
                    }
                }
            }
            if (fieldList != null)
            {
                ScanFields = fieldList.ToArray();
            }
            else if (BaseType.IsScan == 0)
            {
                IsScan = 0;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取数组元素类型
        /// </summary>
        /// <param name="scanner"></param>
        internal void GetElementType(ReflectionTypeScanner scanner)
        {
            Type ElementType = Type.GetElementType();

            if (!ElementType.IsPointer && ElementType != typeof(System.Reflection.Pointer))
            {
                this.ElementType = scanner.GetObjectType(ElementType);
                if (this.ElementType.IsScan != 0 || IsScanDerived(ElementType))
                {
                    IsScan = 2;
                }
            }
            else
            {
                this.ElementType = ReflectionObjectType.NullType;
            }
        }