Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/29/10 15:10:17 (14 years ago)
Author:
mkommend
Message:

changed logic of showing new views (ticket #972)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.MainForm/3.3/MainFormManager.cs

    r3437 r3557  
    105105    }
    106106
    107     public static bool ViewCanViewObject(IContentView view, IContent content) {
     107    public static bool ViewCanViewContent(IContentView view, IContent content) {
    108108      return ContentAttribute.CanViewType(view.GetType(), content.GetType());
    109109    }
     
    145145    }
    146146
    147     public static IContentView CreateDefaultView(object content) {
    148       Type t = GetDefaultViewType(content.GetType());
     147    public static IContentView CreateDefaultView(Type contentType) {
     148      CheckForContentType(contentType);
     149      Type t = GetDefaultViewType(contentType);
    149150      if (t == null)
    150151        return null;
    151152
    152       return (IContentView)Activator.CreateInstance(t, content);
     153      return (IContentView)Activator.CreateInstance(t);
    153154    }
    154155    public static IContentView CreateView(Type viewType) {
    155       if (!typeof(IView).IsAssignableFrom(viewType))
    156         throw new ArgumentException("View can not be created becaues given type " + viewType.ToString() + " is not of type IView.");
     156      CheckForContentViewType(viewType);
    157157      if (viewType.IsGenericTypeDefinition)
    158158        throw new ArgumentException("View can not be created becaues given type " + viewType.ToString() + " is a generic type definition.");
    159159
    160160      return (IContentView)Activator.CreateInstance(viewType);
    161     }
    162     public static IContentView CreateView(Type viewType, object content) {
    163       CheckForContentType(content.GetType());
    164       CheckForContentViewType(viewType);
    165 
    166       Type view = viewType;
    167       if (view.IsGenericTypeDefinition)
    168         view = TransformGenericTypeDefinition(view, content.GetType());
    169 
    170       return (IContentView)Activator.CreateInstance(view, content);
    171161    }
    172162
Note: See TracChangeset for help on using the changeset viewer.