Exemplo n.º 1
0
 private static void _checkEnumerable(object objData, ref CheckValueResult resultData, string[] files, string _strResultKey, List <SeachData> SeachList)
 {
     foreach (object item in (objData as IEnumerable <object>))
     {
         if (CheckModel._canAdd(item, files, ref resultData))
         {
             if (SeachList.Count == 0)
             {
                 resultData.AddData(item, _strResultKey);
             }
             else
             {
                 CheckModel._getValueData(item, SeachList, _strResultKey, ref resultData, false);
             }
         }
     }
 }
Exemplo n.º 2
0
        private static void _checkList(dynamic objData, ref CheckValueResult resultData, string[] files, string _strResultKey, List <SeachData> SeachList)
        {
            FieldInfo info = objData.GetType().GetField("_items", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

            if (null == info)
            {
                resultData.Info = _strResultKey + " _items type.GetField = null";
            }
            else
            {
                dynamic _list = info.GetValue(objData);
                info = objData.GetType().GetField("_size", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
                if (null == info)
                {
                    resultData.Info = _strResultKey + " _size type.GetField = null";
                }
                else
                {
                    int size = (int)info.GetValue(objData);
                    if (size >= 1)
                    {
                        for (int i = 0; i < size; i++)
                        {
                            object data = _list[i];
                            if (CheckModel._canAdd(data, files, ref resultData))
                            {
                                if (SeachList.Count == 0)
                                {
                                    resultData.AddData(data, _strResultKey);
                                }
                                else
                                {
                                    CheckModel._getValueData(data, SeachList, _strResultKey, ref resultData, false);
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
        private static void _checkDict(dynamic objData, ref CheckValueResult resultData, string[] files, string _strResultKey, List <SeachData> SeachList)
        {
            FieldInfo info = objData.GetType().GetField("count", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

            if (null == info)
            {
                resultData.Info = _strResultKey + " count type.GetField = null";
            }
            else
            {
                int size = (int)info.GetValue(objData);
                if (size >= 1)
                {
                    foreach (var item in objData)
                    {
                        string arg          = "{0}[key={1}]";
                        string strResultKey = string.Format(arg, _strResultKey, item.Key);
                        if (_canAdd(item, files, ref resultData))
                        {
                            if (SeachList.Count == 0)
                            {
                                resultData.AddData(item.Value, _strResultKey);
                            }
                            else
                            {
                                List <object> list = new List <object>();
                                list.Add(item.Value);
                                List <object>    value    = list;
                                List <SeachData> TempList = CheckModel.CopySeachList(SeachList);
                                TempList.Insert(0, new SeachData());
                                CheckModel._getValueData(value, TempList, strResultKey, ref resultData, false);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 4
0
 private static void _getValueData(object objData, List <SeachData> SeachList, string _strResultKey, ref CheckValueResult resultData, bool isFirst = false)
 {
     if (null == objData)
     {
         resultData.AddData(null, _strResultKey);
     }
     else if (SeachList == null || SeachList.Count < 1)
     {
         resultData.AddData(objData, _strResultKey);
     }
     else
     {
         Type             type         = objData.GetType();
         string           strResultKey = "";
         List <SeachData> seachList    = CheckModel.CopySeachList(SeachList);
         SeachData        Seach        = seachList[0];
         seachList.RemoveAt(0);
         object infoData;
         if (!string.IsNullOrEmpty(Seach.AttName))
         {
             FieldInfo info = type.GetField(Seach.AttName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
             if (null == info)
             {
                 resultData.Info = Seach.AttName + "type.GetField = null";
                 return;
             }
             infoData = info.GetValue(objData);
             if (null == infoData)
             {
                 resultData.AddData(null, _strResultKey);
                 return;
             }
             Type infoType = infoData.GetType();
         }
         else
         {
             infoData = objData;
         }
         string[] files = null;
         if (!string.IsNullOrEmpty(Seach.SeachVal))
         {
             files = Seach.SeachVal.Split(new char[]
             {
                 '|'
             });
         }
         if (CheckModel.IsList(infoData))
         {
             if (!string.IsNullOrEmpty(Seach.AttName))
             {
                 strResultKey = string.Format("{0}查找[{1}][list]->", _strResultKey, Seach.AttName);
             }
             else
             {
                 strResultKey = _strResultKey + "[list]->";
             }
             if (!string.IsNullOrEmpty(Seach.SeachVal))
             {
                 strResultKey = string.Format("{0}筛选[{1}]->", strResultKey, Seach.SeachVal);
             }
             CheckModel._checkList(infoData, ref resultData, files, strResultKey, CheckModel.CopySeachList(seachList));
         }
         else if (CheckModel.IsDict(infoData))
         {
             if (!string.IsNullOrEmpty(Seach.AttName))
             {
                 strResultKey = string.Format("{0}查找[{1}][dict]->", _strResultKey, Seach.AttName);
             }
             else
             {
                 strResultKey = _strResultKey + "[dict]->";
             }
             if (!string.IsNullOrEmpty(Seach.SeachVal))
             {
                 strResultKey = string.Format("{0}筛选[{1}]->", strResultKey, Seach.SeachVal);
             }
             CheckModel._checkDict(infoData, ref resultData, files, strResultKey, CheckModel.CopySeachList(seachList));
         }
         else if (CheckModel.IsIEnumerable(infoData))
         {
             if (!string.IsNullOrEmpty(Seach.AttName))
             {
                 strResultKey = string.Format("{0}查找[{1}][Enumerable]->", _strResultKey, Seach.AttName);
             }
             else
             {
                 strResultKey = _strResultKey + "[Enumerable]->";
             }
             if (!string.IsNullOrEmpty(Seach.SeachVal))
             {
                 strResultKey = string.Format("{0}筛选[{1}]->", strResultKey, Seach.SeachVal);
             }
             CheckModel._checkEnumerable(infoData, ref resultData, files, strResultKey, CheckModel.CopySeachList(seachList));
         }
         else if (CheckModel.IsArray(infoData))
         {
             if (!string.IsNullOrEmpty(Seach.AttName))
             {
                 strResultKey = string.Format("{0}查找[{1}][Array]->", _strResultKey, Seach.AttName);
             }
             else
             {
                 strResultKey = _strResultKey + "[Array]->";
             }
             if (!string.IsNullOrEmpty(Seach.SeachVal))
             {
                 strResultKey = string.Format("{0}筛选[{1}]->", strResultKey, Seach.SeachVal);
             }
             CheckModel._checkArray(infoData, ref resultData, files, strResultKey, CheckModel.CopySeachList(seachList));
         }
         else if (string.IsNullOrEmpty(Seach.AttName) && isFirst)
         {
             resultData.AddData(objData, strResultKey);
         }
         else if (CheckModel._canAdd(infoData, files, ref resultData))
         {
             strResultKey = _strResultKey;
             if (!string.IsNullOrEmpty(Seach.AttName))
             {
                 strResultKey = string.Format("{0}查找[{1}]->", _strResultKey, Seach.AttName);
             }
             if (!string.IsNullOrEmpty(Seach.SeachVal))
             {
                 strResultKey = string.Format("{0}筛选[{1}]->", strResultKey, Seach.SeachVal);
             }
             if (seachList.Count == 0)
             {
                 resultData.AddData(infoData, strResultKey);
             }
             else
             {
                 CheckModel._getValueData(infoData, CheckModel.CopySeachList(seachList), strResultKey, ref resultData, false);
             }
         }
     }
 }
Exemplo n.º 5
0
 private static void _checkArray(object objData, ref CheckValueResult resultData, string[] files, string _strResultKey, List <SeachData> SeachList)
 {
     resultData.AddData(CheckModel.Data2Json(objData), _strResultKey);
 }