コード例 #1
0
 /// <summary>
 /// 添加扫描对象
 /// </summary>
 /// <param name="scanner"></param>
 /// <param name="value"></param>
 /// <param name="isArray">对象是否数组元素,数组元素不统计根静态字段</param>
 /// <returns>添加对象类型</returns>
 internal override byte Append(ref ReflectionScanner scanner, object value, bool isArray)
 {
     if (ScanFields.Length != 0)
     {
         scanner.Append(new ReflectionObjectScanner(value, this, isArray));
         return(0);
     }
     return(BaseType.IsScan == 0 ? (byte)2 : BaseType.Append(ref scanner, value, isArray));
 }
コード例 #2
0
        /// <summary>
        /// 读取下一个数据
        /// </summary>
        /// <param name="scanner"></param>
        internal void Next(ref ReflectionScanner scanner)
        {
            object value      = this.value;
            bool   isArray    = this.isArray;
            int    isEndIndex = 0;

            do
            {
                KeyValue <FieldInfo, ReflectionType> field = this.objectType.ScanFields[index++];
                if (index == this.objectType.ScanFields.Length)
                {
                    --scanner.Objects.Length;
                    if (this.objectType.BaseType.IsScan != 0)
                    {
                        this.objectType.BaseType.Append(ref scanner, value, isArray);
                    }
                    isEndIndex = 1;
                }
                object fieldValue = field.Key.GetValue(value);
                if (fieldValue != null)
                {
                    ReflectionType objectType = field.Value;
                    Type           fieldType  = fieldValue.GetType();
                    if (fieldType != objectType.Type)
                    {
                        objectType = scanner.Scanner.GetObjectType(fieldType);
                    }
                    if (objectType.IsScan != 0)
                    {
                        if (fieldType.IsClass)
                        {
                            if (scanner.AddObject(fieldValue))
                            {
                                if (!isArray)
                                {
                                    objectType.Add(scanner.FieldInfo, scanner.Scanner);
                                }
                                if (objectType.Append(ref scanner, fieldValue, false) == 0)
                                {
                                    return;
                                }
                            }
                            else if (scanner.IsLimitExceeded)
                            {
                                return;
                            }
                        }
                        else if (objectType.Append(ref scanner, fieldValue, false) == 0)
                        {
                            return;
                        }
                    }
                }
            }while (isEndIndex == 0);
        }
コード例 #3
0
 /// <summary>
 /// 添加扫描对象
 /// </summary>
 /// <param name="scanner"></param>
 /// <param name="value"></param>
 /// <param name="isArray">对象是否数组元素,数组元素不统计根静态字段</param>
 /// <returns>添加对象类型</returns>
 internal override byte Append(ref ReflectionScanner scanner, object value, bool isArray)
 {
     if (value.GetType() == typeof(string))
     {
         ElementCount += ((string)value).Length;
     }
     else
     {
         ElementCount += ((Array)value).Length;
         if (IsScan == 2)
         {
             scanner.Append(new ReflectionArrayScanner(value, ElementType));
             return(1);
         }
     }
     return(2);
 }
コード例 #4
0
 /// <summary>
 /// 读取下一个数据
 /// </summary>
 /// <param name="scanner"></param>
 internal void Next(ref ReflectionScanner scanner)
 {
     while (enumerator.MoveNext())
     {
         object elementValue = enumerator.Current;
         if (elementValue != null)
         {
             Type fieldType = elementValue.GetType();
             if (fieldType != objectType.Type)
             {
                 objectType = scanner.Scanner.GetObjectType(fieldType);
             }
             if (objectType.IsScan != 0)
             {
                 if (fieldType.IsClass)
                 {
                     if (scanner.AddObject(elementValue))
                     {
                         if (objectType.Append(ref scanner, elementValue, true) != 2)
                         {
                             return;
                         }
                     }
                     else if (scanner.IsLimitExceeded)
                     {
                         return;
                     }
                 }
                 else if (objectType.Append(ref scanner, elementValue, true) != 2)
                 {
                     return;
                 }
             }
         }
     }
     --scanner.Arrays.Length;
 }
コード例 #5
0
ファイル: ReflectionType.cs プロジェクト: AutoCSer/AutoCSer
 /// <summary>
 /// 添加扫描对象
 /// </summary>
 /// <param name="scanner"></param>
 /// <param name="value"></param>
 /// <param name="isArray">对象是否数组元素,数组元素不统计根静态字段</param>
 /// <returns>添加对象类型</returns>
 internal abstract byte Append(ref ReflectionScanner scanner, object value, bool isArray);