Esempio n. 1
0
 public void ClearCurrentPresenter()
 {
     if (currentPresenter != null)
     {
         currentPresenter.DetachFromModel();
     }
 }
Esempio n. 2
0
        public void ShowPresenter(IModelObject obj)
        {
            currentPresenter = null;
            if (obj == null)
            {
                return;
            }

            // Find the first type in the list of types the presenter handles that the obj is an instance of.
            // This means that if an object implements two displayable interfaces, the first one we find will
            // be used.
            object o     = obj;
            Type   first = Presenters.Keys.FirstOrDefault(k => k.IsInstanceOfType(o));

            //if (obj is CollectionPlaceholder)
            //{
            //    CollectionPlaceholder placeholder = (CollectionPlaceholder) obj;
            //    if (placeholder.ItemType == typeof(ITable))
            //        first = typeof (ITableContainer);
            //    else if (placeholder.ItemType == typeof(IKey))
            //        first = typeof(IKeyContainer);
            //    else if (placeholder.ItemType == typeof(IIndex))
            //        first = typeof(IIndexContainer);
            //    else if (placeholder.ItemType == typeof(IColumn))
            //        first = typeof(IColumnContainer);
            //    obj = placeholder.Entity;
            //}

            if (first == null)
            {
                log.InfoFormat("We are not handling model objects of type {0} in PresenterController.ShowPresenter()", obj.GetType());
                return;
            }

            currentPresenter = Presenters[first];

            currentPresenter.DetachFromModel();
            currentPresenter.AttachToModel(obj);

            currentPresenter.Show();
        }