- Timestamp:
- 04/19/10 21:00:30 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.MainForm/3.2/MainFormManager.cs
r3389 r3416 26 26 using HeuristicLab.PluginInfrastructure; 27 27 using System.Diagnostics; 28 using HeuristicLab.Common; 28 29 29 30 namespace HeuristicLab.MainForm { … … 75 76 76 77 public static IEnumerable<Type> GetViewTypes(Type contentType) { 78 CheckForContentType(contentType); 77 79 List<Type> viewTypes = (from v in views 78 80 where ContentAttribute.CanViewType(v, contentType) … … 86 88 87 89 public static IEnumerable<Type> GetViewTypes(Type contentType, bool returnOnlyMostSpecificViewTypes) { 90 CheckForContentType(contentType); 88 91 List<Type> viewTypes = new List<Type>(GetViewTypes(contentType)); 89 92 if (returnOnlyMostSpecificViewTypes) { … … 102 105 } 103 106 104 public static bool ViewCanViewObject(IContentView view, object content) {107 public static bool ViewCanViewObject(IContentView view, IContent content) { 105 108 return ContentAttribute.CanViewType(view.GetType(), content.GetType()); 106 109 } 107 110 108 111 public static Type GetDefaultViewType(Type contentType) { 112 CheckForContentType(contentType); 109 113 //check base classes for default view 110 114 Type type = contentType; … … 148 152 return (IContentView)Activator.CreateInstance(t, content); 149 153 } 150 public static IContentView CreateDefaultView(object content, bool readOnly) {151 IContentView view = CreateDefaultView(content);152 if (view != null)153 view.ReadOnly = readOnly;154 return view;155 }156 157 154 public static IContentView CreateView(Type viewType) { 158 if (!typeof(I ContentView).IsAssignableFrom(viewType))155 if (!typeof(IView).IsAssignableFrom(viewType)) 159 156 throw new ArgumentException("View can not be created becaues given type " + viewType.ToString() + " is not of type IView."); 160 157 if (viewType.IsGenericTypeDefinition) … … 163 160 return (IContentView)Activator.CreateInstance(viewType); 164 161 } 165 public static IContentView CreateView(Type viewType, bool readOnly) {166 IContentView view = CreateView(viewType);167 view.ReadOnly = readOnly;168 return view;169 }170 171 162 public static IContentView CreateView(Type viewType, object content) { 172 if (!typeof(IContentView).IsAssignableFrom(viewType)) 173 throw new ArgumentException("View can not be created becaues given type " + viewType.ToString() + " is not of type IView."); 163 CheckForContentType(content.GetType()); 164 CheckForContentViewType(viewType); 165 174 166 Type view = viewType; 175 167 if (view.IsGenericTypeDefinition) … … 178 170 return (IContentView)Activator.CreateInstance(view, content); 179 171 } 180 public static IContentView CreateView(Type viewType, object content, bool readOnly) { 181 IContentView view = CreateView(viewType, content); 182 view.ReadOnly = readOnly; 183 return view; 172 173 private static void CheckForContentType(Type contentType) { 174 if (!typeof(IContent).IsAssignableFrom(contentType)) 175 throw new ArgumentException("DefaultViews are only specified for types of IContent and not for " + contentType + "."); 176 } 177 private static void CheckForContentViewType(Type viewType) { 178 if (!typeof(IContentView).IsAssignableFrom(viewType)) 179 throw new ArgumentException("View can not be created becaues given type " + viewType.ToString() + " is not of type IContentView."); 184 180 } 185 181
Note: See TracChangeset
for help on using the changeset viewer.