private static PresenterInfo InternalAdd(Type viewType, Type presenterType) { var constructor = presenterType.GetConstructor(new Type[] { viewType }); if (constructor == null) { throw new PresentationResolverException("There is no public constructor in '{0}' with an argument for the requested view type '{1}'", presenterType.FullName, viewType.FullName); } var temp = new PresenterInfo(); temp.Type = presenterType; temp.Constructor = constructor; _viewTypes.Add(viewType, temp); return(temp); }
internal static ConstructorInfo GetConstructor(Type viewType) { ConstructorInfo ci = null; PresenterInfo pi = null; if (_viewTypes.ContainsKey(viewType)) { pi = _viewTypes[viewType]; } if (pi == null) { var args = new ResolvePresenterEventArgs(viewType); Type presenterType = null; if (ResolvePresenter != null) { foreach (var resolver in ResolvePresenter.GetInvocationList()) { ((ResolvePresenterEventHandler)resolver).Invoke(null, args); if (args.PresenterType != null) { presenterType = args.PresenterType; break; } } } if (presenterType != null) { pi = InternalAdd(viewType, presenterType); } } if (pi != null) { ci = pi.Constructor; } return(ci); }