/// <summary> /// 命名空间归类 /// </summary> public static ClusterDict NamespaceClasses(ClusterSubDict classDict) { var classCluster = new ClusterDict(); classCluster.Add("________##", NewClassDict()); foreach (var name2type in classDict) { //主命名空间 if (name2type.Value.Namespace == null) { classCluster["________##"].Add(name2type.Key, name2type.Value); } else { if (classCluster.ContainsKey(name2type.Value.Namespace) == false) { classCluster.Add(name2type.Value.Namespace, NewClassDict()); } classCluster[name2type.Value.Namespace].Add(name2type.Key, name2type.Value); } } return(classCluster); }
static void EndNameCluster <T>( ref ClusterDict classCluster, SortedDictionary <string, Type> allClass, SortedDictionary <string, T> classDict ) { Dictionary <string, int> endNameCount = CountEndName(classDict); foreach (var i in endNameCount) { if (i.Value > 4 && i.Key.Length > 1 && classCluster.ContainsKey(i.Key) == false) { classCluster.Add(i.Key, new SortedDictionary <string, Type>()); foreach (var str2type in allClass) { if (str2type.Key.EndsWith(i.Key)) { classCluster[i.Key].Add(str2type.Key, str2type.Value); } } } } }
/// <summary> /// 主要的Class /// </summary> public static ClusterDict MainClass(ClusterSubDict classDict) { var classCluster = new ClusterDict(); classCluster.Add("Enum##Class", NewClassDict()); classCluster.Add("______##Class", NewClassDict()); //PreProcess UI And Enum foreach (var str2type in classDict) { if (str2type.Value.IsEnum) { classCluster["Enum##Class"].Add(str2type.Key, str2type.Value); } classCluster["______##Class"].Add(str2type.Key, str2type.Value); } RootClass(ref classCluster, classDict); SingletonClass(ref classCluster, classDict); return(classCluster); }
static void SingletonClass( ref ClusterDict classCluster, ClusterSubDict allClass) { classCluster.Add("Singleton##Class", NewClassDict()); bool added = false; foreach (var class2type in allClass) { added = false; if (class2type.Value.IsEnum) { continue; } PropertyInfo[] propertyInfos = PropertyHelpers.GetStaticPropertys(class2type.Value); FieldInfo[] fieldInfos = FieldHelpers.GetStaticFields(class2type.Value); //Seach propertys singleton foreach (PropertyInfo propertyInfo in propertyInfos) { if (propertyInfo.PropertyType.FullName == class2type.Value.FullName) { classCluster["Singleton##Class"].Add(class2type.Key, class2type.Value); added = true; break; } } if (added) { continue; } //Seach fields singleton foreach (FieldInfo fieldInfo in fieldInfos) { if (fieldInfo.FieldType.FullName == class2type.Value.FullName) { classCluster["Singleton##Class"].Add(class2type.Key, class2type.Value); break; } } } }
static void RootClass( ref ClusterDict classCluster, ClusterSubDict allClass, uint limit = 5 ) { classCluster.Add("Root##Class", NewClassDict()); foreach (var class2type in allClass) { int num = CountClassInclude(class2type.Value, allClass); if (num > limit) { classCluster["Root##Class"].Add(class2type.Key, class2type.Value); } } }