Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/18/10 02:08:29 (15 years ago)
Author:
mkommend
Message:

enhanced caching of views in ViewHost and adapted MainFormManager to use IContentView (ticket #972)

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  
    2727namespace HeuristicLab.MainForm {
    2828  public interface IContentView : IView {
    29     object Content { get; }
     29    object Content { get; set; }
    3030    bool SaveEnabled { get; }
    3131  }
  • trunk/sources/HeuristicLab.MainForm/3.2/MainFormManager.cs

    r3375 r3389  
    5050        MainFormManager.mainform = mainForm;
    5151        IEnumerable<Type> types =
    52           from t in ApplicationManager.Manager.GetTypes(typeof(IView))
     52          from t in ApplicationManager.Manager.GetTypes(typeof(IContentView))
    5353          where !t.IsAbstract && !t.IsInterface && ContentAttribute.HasContentAttribute(t)
    5454          select t;
     
    102102    }
    103103
    104     public static bool ViewCanViewObject(IView view, object content) {
     104    public static bool ViewCanViewObject(IContentView view, object content) {
    105105      return ContentAttribute.CanViewType(view.GetType(), content.GetType());
    106106    }
     
    141141    }
    142142
    143     public static IView CreateDefaultView(object content) {
     143    public static IContentView CreateDefaultView(object content) {
    144144      Type t = GetDefaultViewType(content.GetType());
    145145      if (t == null)
    146146        return null;
    147147
    148       return (IView)Activator.CreateInstance(t, content);
    149     }
    150     public static IView CreateDefaultView(object content, bool readOnly) {
    151       IView 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);
    152152      if (view != null)
    153153        view.ReadOnly = readOnly;
     
    155155    }
    156156
    157     public static IView CreateView(Type viewType) {
    158       if (!typeof(IView).IsAssignableFrom(viewType))
     157    public static IContentView CreateView(Type viewType) {
     158      if (!typeof(IContentView).IsAssignableFrom(viewType))
    159159        throw new ArgumentException("View can not be created becaues given type " + viewType.ToString() + " is not of type IView.");
    160160      if (viewType.IsGenericTypeDefinition)
    161161        throw new ArgumentException("View can not be created becaues given type " + viewType.ToString() + " is a generic type definition.");
    162162
    163       return (IView)Activator.CreateInstance(viewType);
    164     }
    165     public static IView CreateView(Type viewType, bool readOnly) {
    166       IView view = CreateView(viewType);
     163      return (IContentView)Activator.CreateInstance(viewType);
     164    }
     165    public static IContentView CreateView(Type viewType, bool readOnly) {
     166      IContentView view = CreateView(viewType);
    167167      view.ReadOnly = readOnly;
    168168      return view;
    169169    }
    170170
    171     public static IView CreateView(Type viewType, object content) {
    172       if (!typeof(IView).IsAssignableFrom(viewType))
     171    public static IContentView CreateView(Type viewType, object content) {
     172      if (!typeof(IContentView).IsAssignableFrom(viewType))
    173173        throw new ArgumentException("View can not be created becaues given type " + viewType.ToString() + " is not of type IView.");
    174174      Type view = viewType;
     
    176176        view = TransformGenericTypeDefinition(view, content.GetType());
    177177
    178       return (IView)Activator.CreateInstance(view, content);
    179     }
    180     public static IView CreateView(Type viewType, object content, bool readOnly) {
    181       IView 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);
    182182      view.ReadOnly = readOnly;
    183183      return view;
Note: See TracChangeset for help on using the changeset viewer.