Inheritance: System.PageData
        protected override IPresenter CreatePresenterInstance(Type presenterType, TypedPageData pageData, Type viewType, IEPiView view)
        {
            // Unfortunately, Ninject needs the bloody names of the parameters,
            // so we need to figure them out by reflecting.
            string pageDataParameterName = null;
            string viewParameterName = null;
            foreach (var constructor in presenterType.GetConstructors())
            {
                var constructorParameters = constructor.GetParameters();
                foreach (var parameter in constructorParameters)
                {
                    if (parameter.ParameterType.IsAssignableFrom(pageData.GetType()))
                        pageDataParameterName = parameter.Name;

                    if (parameter.ParameterType.IsAssignableFrom(view.GetType()))
                        viewParameterName = parameter.Name;
                }
            }
            var parameters = new IParameter[]
                                 {
                                     new ConstructorArgument(viewParameterName, view),
                                     new ConstructorArgument(pageDataParameterName, pageData)
                                 };
            return (IPresenter)Kernel.Get(presenterType, parameters);
        }
 protected override IPresenter CreatePageDataPresenterInstance(Type presenterType, TypedPageData pageData, Type viewType, IEPiView view)
 {
     if (presenterType == (Type) null)
         throw new ArgumentNullException("presenterType");
     if (viewType == (Type) null)
         throw new ArgumentNullException("viewType");
     if (view == null)
         throw new ArgumentNullException("view");
     Dictionary<string, object> dictionary = new Dictionary<string, object>()
                                                 {
                                                     {
                                                         "view",
                                                         (object) view
                                                         },
                                                     {
                                                         "pageData",
                                                         (object) pageData
                                                         }
                                                 };
     return (IPresenter) this.presenterKernel.Resolve(presenterType, (IDictionary) dictionary);
 }
        protected override IPresenter CreatePresenterInstance(Type presenterType, TypedPageData pageData, Type viewType, IEPiView view)
        {
            ConstructorInfo constructorToUse = null;
            var constructors = presenterType.GetConstructors();
            foreach (var constructor in constructors)
            {
                if (CanUseConstructor(constructor, viewType, GetPageDataType(view)))
                {
                    constructorToUse = constructor;
                    break;
                }
            }

            ParameterInfo[] parameters = constructorToUse.GetParameters();
            object[] constructorParametersToUse = new object[parameters.Length];
            constructorParametersToUse[0] = view;
            constructorParametersToUse[1] = view.CurrentPage;
            for (int i = 2; i < constructorParametersToUse.Length; i++)
            {
                constructorParametersToUse[i] = ResolveParameter(parameters[i].ParameterType, i, view);
            }
            return (IPresenter)Activator.CreateInstance(presenterType, constructorParametersToUse);
        }
 internal static void PopuplateInstance(PageData source, TypedPageData destination)
 {
     destination.ShallowCopy(source);
 }
 internal static void PopuplateInstance(PageData source, TypedPageData destination)
 {
     destination.ShallowCopy(source);
 }
 /// <summary>
 /// This is the actual method that creates the instance. 
 /// Called by Create. It can be 
 /// overridden in case you need to do more stuff to the Presenter
 /// when creating it (injecting services using an IOC container, for instance).
 /// </summary>
 protected virtual IPresenter CreatePageDataPresenterInstance(Type presenterType, TypedPageData pageData, Type viewType, IEPiView view)
 {
     return (IPresenter)Activator.CreateInstance(presenterType, new object[] { view, pageData });
 }
        private void SetupTabBasedPropertiesAndPropertyGroupPageDataProperties(TypedPageData typedPageData)
        {
            TabDefinitionCollection tabDefinitions = new FakeTabDefinitionRepository().List();
            Type type = typedPageData.GetType();

            foreach (PropertyInfo property in AttributedTypesUtility.GetPublicOrPrivateProperties(type)
                .Where(AttributedTypesUtility.PropertyHasAttribute<PageTypePropertyAttribute>))
            {
                int tabDefinitionId = -1;
                PageTypePropertyAttribute pageTypePropertyAttribute = AttributedTypesUtility.GetAttributesFromProperty<PageTypePropertyAttribute>(property).First();
                
                if (pageTypePropertyAttribute.Tab != null)
                {
                    Tab tab = Activator.CreateInstance(pageTypePropertyAttribute.Tab) as Tab;
                    TabDefinition tabDefinition = tabDefinitions.FirstOrDefault(t => t.Name == tab.Name);

                    if (tabDefinition != null)
                        tabDefinitionId = tabDefinition.ID;
                }

                typedPageData.Property.Add(new PropertyString { Name = property.Name, OwnerTab = tabDefinitionId });
            }

            foreach (PropertyInfo propertyGroupProperty in AttributedTypesUtility.GetPublicOrPrivateProperties(type)
                .Where(AttributedTypesUtility.PropertyHasAttribute<PageTypePropertyGroupAttribute>))
            {
                foreach (PropertyInfo property in AttributedTypesUtility.GetPublicOrPrivateProperties(propertyGroupProperty.PropertyType)
                    .Where(AttributedTypesUtility.PropertyHasAttribute<PageTypePropertyAttribute>))
                    {
                        int tabDefinitionId = -1;
                        PageTypePropertyGroupAttribute pageTypePropertyGroupAttribute = AttributedTypesUtility.GetAttributesFromProperty<PageTypePropertyGroupAttribute>(propertyGroupProperty).First();

                        if (pageTypePropertyGroupAttribute.Tab != null)
                        {
                            Tab tab = Activator.CreateInstance(pageTypePropertyGroupAttribute.Tab) as Tab;
                            TabDefinition tabDefinition = tabDefinitions.FirstOrDefault(t => t.Name == tab.Name);

                            if (tabDefinition != null)
                                tabDefinitionId = tabDefinition.ID;
                        }

                        typedPageData.Property.Add(new PropertyString
                                                       {
                                                           Name = string.Format("{0}-{1}", propertyGroupProperty.Name, property.Name),
                                                           OwnerTab = tabDefinitionId
                                                       });
                    }
            }
        }