Changeset 3389 for trunk/sources/HeuristicLab.MainForm/3.2
- Timestamp:
- 04/18/10 02:08:29 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.MainForm/3.2
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.MainForm/3.2/Interfaces/IContentView.cs
r2961 r3389 27 27 namespace HeuristicLab.MainForm { 28 28 public interface IContentView : IView { 29 object Content { get; }29 object Content { get; set; } 30 30 bool SaveEnabled { get; } 31 31 } -
trunk/sources/HeuristicLab.MainForm/3.2/MainFormManager.cs
r3375 r3389 50 50 MainFormManager.mainform = mainForm; 51 51 IEnumerable<Type> types = 52 from t in ApplicationManager.Manager.GetTypes(typeof(I View))52 from t in ApplicationManager.Manager.GetTypes(typeof(IContentView)) 53 53 where !t.IsAbstract && !t.IsInterface && ContentAttribute.HasContentAttribute(t) 54 54 select t; … … 102 102 } 103 103 104 public static bool ViewCanViewObject(I View view, object content) {104 public static bool ViewCanViewObject(IContentView view, object content) { 105 105 return ContentAttribute.CanViewType(view.GetType(), content.GetType()); 106 106 } … … 141 141 } 142 142 143 public static I View CreateDefaultView(object content) {143 public static IContentView CreateDefaultView(object content) { 144 144 Type t = GetDefaultViewType(content.GetType()); 145 145 if (t == null) 146 146 return null; 147 147 148 return (I View)Activator.CreateInstance(t, content);149 } 150 public static I View CreateDefaultView(object content, bool readOnly) {151 I View view = CreateDefaultView(content);148 return (IContentView)Activator.CreateInstance(t, content); 149 } 150 public static IContentView CreateDefaultView(object content, bool readOnly) { 151 IContentView view = CreateDefaultView(content); 152 152 if (view != null) 153 153 view.ReadOnly = readOnly; … … 155 155 } 156 156 157 public static I View CreateView(Type viewType) {158 if (!typeof(I View).IsAssignableFrom(viewType))157 public static IContentView CreateView(Type viewType) { 158 if (!typeof(IContentView).IsAssignableFrom(viewType)) 159 159 throw new ArgumentException("View can not be created becaues given type " + viewType.ToString() + " is not of type IView."); 160 160 if (viewType.IsGenericTypeDefinition) 161 161 throw new ArgumentException("View can not be created becaues given type " + viewType.ToString() + " is a generic type definition."); 162 162 163 return (I View)Activator.CreateInstance(viewType);164 } 165 public static I View CreateView(Type viewType, bool readOnly) {166 I View view = CreateView(viewType);163 return (IContentView)Activator.CreateInstance(viewType); 164 } 165 public static IContentView CreateView(Type viewType, bool readOnly) { 166 IContentView view = CreateView(viewType); 167 167 view.ReadOnly = readOnly; 168 168 return view; 169 169 } 170 170 171 public static I View CreateView(Type viewType, object content) {172 if (!typeof(I View).IsAssignableFrom(viewType))171 public static IContentView CreateView(Type viewType, object content) { 172 if (!typeof(IContentView).IsAssignableFrom(viewType)) 173 173 throw new ArgumentException("View can not be created becaues given type " + viewType.ToString() + " is not of type IView."); 174 174 Type view = viewType; … … 176 176 view = TransformGenericTypeDefinition(view, content.GetType()); 177 177 178 return (I View)Activator.CreateInstance(view, content);179 } 180 public static I View CreateView(Type viewType, object content, bool readOnly) {181 I View view = CreateView(viewType, content);178 return (IContentView)Activator.CreateInstance(view, content); 179 } 180 public static IContentView CreateView(Type viewType, object content, bool readOnly) { 181 IContentView view = CreateView(viewType, content); 182 182 view.ReadOnly = readOnly; 183 183 return view;
Note: See TracChangeset
for help on using the changeset viewer.