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 { } } }
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; }