/// <summary> /// 统计Class的引用和静态成员 /// </summary> static int CountClassInclude( Type type, ClusterSubDict allClass ) { HashSet <Type> types = new HashSet <Type>(); int bias = 0; // PropertyInfo[] propertyInfos = PropertyHelpers.GetAllPropertys(type); FieldInfo[] fieldInfos = FieldHelpers.GetAllFields(type); //count field class include number foreach (FieldInfo fieldInfo in fieldInfos) { Caller.Try(() => { if (allClass.ContainsKey(fieldInfo.FieldType.Name)) { //static class field if (fieldInfo.IsStatic && fieldInfo.FieldType.IsEnum == false) { bias += 1; } types.Add(fieldInfo.FieldType); } }); } //count property class include number foreach (PropertyInfo propertyInfo in propertyInfos) { if (allClass.ContainsKey(propertyInfo.PropertyType.Name)) { //static class property if (propertyInfo.GetAccessors().Length > 0 && propertyInfo.GetAccessors()[0].IsStatic && propertyInfo.PropertyType.IsEnum == false) { bias += 1; } types.Add(propertyInfo.PropertyType); } } return(types.Count + bias); }