Beispiel #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;
            }
        }
Beispiel #2
0
        /// <summary>
        /// 反射模式对象扫描
        /// </summary>
        /// <param name="scanner">类型扫描</param>
        /// <param name="fieldInfo">当前扫描静态字段</param>
        internal ReflectionScanner(ReflectionTypeScanner scanner, FieldInfo fieldInfo)
        {
            Scanner          = scanner;
            FieldInfo        = fieldInfo;
            objectReferences = HashSetCreator <ObjectReference> .Create();

            Arrays          = new LeftArray <ReflectionArrayScanner>(0);
            Objects         = new LeftArray <ReflectionObjectScanner>(0);
            IsLimitExceeded = false;
        }
        /// <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;
            }
        }