Changeset 3268
- Timestamp:
- 04/05/10 14:50:55 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.MainForm/3.2/MainFormManager.cs
r3255 r3268 95 95 96 96 foreach (Type viewType in viewTypes.ToList()) { 97 if ((viewType != defaultViewType) && viewTypes.Any(t => t.IsSubclassOf(viewType)))97 if ((viewType != defaultViewType) && viewTypes.Any(t => t.IsSubclassOf(viewType))) 98 98 viewTypes.Remove(viewType); 99 99 } … … 114 114 Type type = contentType; 115 115 while (type != null) { 116 //check classes 116 117 foreach (Type defaultContentType in defaultViews.Keys) { 117 118 if (type == defaultContentType || type.CheckGenericTypes(defaultContentType)) 118 119 return TransformGenericTypeDefinition(defaultViews[defaultContentType], contentType); 119 120 } 121 122 //check interfaces 123 IEnumerable<Type> nonInheritedInterfaces = type.GetInterfaces().Where(i => !i.IsAssignableFrom(type.BaseType)); 124 List<Type> defaultViewList = new List<Type>(); 125 foreach (Type defaultContentType in defaultViews.Keys) { 126 if (nonInheritedInterfaces.Contains(defaultContentType) || nonInheritedInterfaces.Any(i => i.CheckGenericTypes(defaultContentType))) 127 defaultViewList.Add(defaultViews[defaultContentType]); 128 } 129 130 //return only most spefic view as default view 131 foreach (Type viewType in defaultViewList.ToList()) { 132 if (defaultViewList.Any(t => t.IsSubclassOf(viewType))) 133 defaultViewList.Remove(viewType); 134 } 135 136 if (defaultViewList.Count == 1) 137 return TransformGenericTypeDefinition(defaultViewList[0], contentType); 138 else if (defaultViewList.Count > 1) 139 throw new InvalidOperationException("Could not determine which is the default view for type " + contentType.ToString() + ". Because more than one implemented interfaces have a default view."); 140 120 141 type = type.BaseType; 121 142 } 122 143 123 //check if exactly one implemented interface has a default view124 List<Type> temp = (from t in defaultViews.Keys125 where t.IsInterface && contentType.IsAssignableTo(t)126 select t).ToList();127 if (temp.Count == 1)128 return TransformGenericTypeDefinition(defaultViews[temp[0]], contentType);129 //more than one default view for implemented interfaces are found130 if (temp.Count > 1)131 throw new InvalidOperationException("Could not determine which is the default view for type " + contentType.ToString() + ". Because more than one implemented interfaces have a default view.");132 144 return null; 133 145 }
Note: See TracChangeset
for help on using the changeset viewer.