Пример #1
0
        public static List <string> FuzzySeachType(string name)
        {
            name = name.Trim();
            List <string> dlist = new List <string>();
            List <string> result;

            if (string.IsNullOrEmpty(name))
            {
                result = dlist;
            }
            else
            {
                RelationMapModel.ReadRelationMap();
                foreach (string item in RelationMapModel.Map.Keys)
                {
                    if (item.ToLower().IndexOf(name.ToLower()) > -1)
                    {
                        dlist.Add(item);
                    }
                }
                dlist.Sort();
                result = dlist;
            }
            return(result);
        }
Пример #2
0
 private static void ReadRelationMap()
 {
     if (RelationMapModel.Map.Count <= 0)
     {
         string Path     = RelationMapModel.CreatDirectory();
         string filePath = Path + "RelationMapAll.txt";
         try
         {
             if (File.Exists(filePath))
             {
                 string       key = null;
                 StreamReader sr  = new StreamReader(filePath);
                 while (sr.Peek() >= 0)
                 {
                     string str = sr.ReadLine().Trim();
                     if (string.IsNullOrEmpty(key))
                     {
                         key = str;
                     }
                     else if (str.IndexOf("******************") > -1)
                     {
                         key = null;
                     }
                     else if (!string.IsNullOrEmpty(str))
                     {
                         if (RelationMapModel.Map.ContainsKey(key))
                         {
                             RelationMapModel.Map[key].Add(str);
                         }
                         else
                         {
                             RelationMapModel.Map.Add(key, new List <string>
                             {
                                 str
                             });
                         }
                     }
                 }
                 sr.Close();
             }
         }
         catch
         {
         }
     }
 }
Пример #3
0
 private static void GetRelationMap(Assembly assembly)
 {
     RelationMapModel.Map.Clear();
     if (RelationMapModel.EnumList.Count < 1)
     {
         RelationMapModel.GetEnumList();
     }
     foreach (Type type in assembly.GetTypes())
     {
         if (!RelationMapModel.IsFilter(type.FullName))
         {
             if (RelationMapModel.IsEnum(type))
             {
                 RelationMapModel.EnumList.Add(type.FullName);
             }
             else
             {
                 FieldInfo[] Infos = type.GetFields(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
                 foreach (FieldInfo info in Infos)
                 {
                     try
                     {
                         if (RelationMapModel.Map.ContainsKey(type.FullName))
                         {
                             RelationMapModel.Map[type.FullName].Add(info.Name);
                         }
                         else
                         {
                             RelationMapModel.Map.Add(type.FullName, new List <string>
                             {
                                 info.Name
                             });
                         }
                     }
                     catch
                     {
                     }
                 }
             }
         }
     }
 }
Пример #4
0
        public static CheckValueResult GetValue(GetValueModel model, Assembly assembly, bool isFirst = false)
        {
            CheckValueResult resultData = new CheckValueResult();

            resultData.Info = "";
            try
            {
                object objData = RelationMapModel.GetObject(assembly, model.TypeName, model.SeachName, ref resultData);
                if (!string.IsNullOrEmpty(resultData.Info))
                {
                    return(resultData);
                }
                CheckModel._getValueData(objData, model.SeachDataList, string.Format("{0}->[{1}]->", model.TypeName, model.SeachName), ref resultData, true);
            }
            catch (Exception ex)
            {
                resultData.Info = ex.ToString();
            }
            return(resultData);
        }
Пример #5
0
        public static List <string> GetSeachAttr(string type)
        {
            RelationMapModel.ReadRelationMap();
            type = type.Trim();
            List <string> dlist = new List <string>();
            List <string> result;

            if (!RelationMapModel.Map.ContainsKey(type))
            {
                result = dlist;
            }
            else
            {
                foreach (string item in RelationMapModel.Map[type])
                {
                    dlist.Add(item);
                }
                dlist.Sort();
                result = dlist;
            }
            return(result);
        }
Пример #6
0
        public static void WriteMap(Assembly assembly)
        {
            string Path = RelationMapModel.CreatDirectory();

            if (!RelationMapModel.isWrite || RelationMapModel.Map.Count < 1)
            {
                RelationMapModel.GetRelationMap(assembly);
            }
            string path = Path + "RelationMapKey.txt";

            using (StreamWriter sw = new StreamWriter(path))
            {
                foreach (KeyValuePair <string, List <string> > d in RelationMapModel.Map)
                {
                    sw.WriteLine(d.Key);
                }
            }
            path = Path + "RelationMapAll.txt";
            using (StreamWriter sw = new StreamWriter(path))
            {
                foreach (KeyValuePair <string, List <string> > d in RelationMapModel.Map)
                {
                    sw.WriteLine(d.Key);
                    foreach (string item in d.Value)
                    {
                        sw.WriteLine("     " + item);
                    }
                    sw.WriteLine("**************************************************************************************************");
                }
            }
            path = Path + "EnumType.json";
            using (StreamWriter sw = new StreamWriter(path))
            {
                sw.WriteLine(CheckModel.Data2Json(RelationMapModel.EnumList));
            }
            Console.WriteLine("画图完成 RelationMap end");
            RelationMapModel.isWrite = true;
        }