public static Mediator RequestMediator(IMediatorTarget target) { if (MediatorAssignments.ContainsKey(target)) { throw(new ArgumentException("Target already has Mediator assigned to it.")); } var targetType = target.GetType(); //if we don't have this class type specifically mapped if (!ClassMediatorMappings.ContainsKey(targetType)) { //checking to see if this target has a super class that has a mediator assigned to it foreach (Type classType in ClassMediatorMappings.Keys) { //TODO: See if this would be better targetType.BaseType if (targetType.IsSubclassOf(classType) || targetType.GetInterface(classType.Name) != null) { return(CreateMediator(target, classType)); } } //if still nothing we blow an exception throw(new ArgumentException("Target type does not have mediator type mapped for it. Invoke MapMediatorToClass first.")); } return(CreateMediator(target, targetType)); }
public static void DestroyMediator(IMediatorTarget target) { if (MediatorAssignments.ContainsKey(target)) { MediatorAssignments [target].Unregister(); MediatorAssignments.Remove(target); } }
static Mediator CreateMediator(IMediatorTarget target, Type targetType) { Mediator m = (Mediator)Activator.CreateInstance(ClassMediatorMappings [targetType], target); DIUtil.InjectProps(m as IInjectingTarget); MediatorAssignments [target] = m; m.Register(); return(m); }
public TestMediator(IMediatorTarget target) : base(target) { Target = target as ITestTargetInteface; }
public Mediator(IMediatorTarget target) { }
// ReSharper disable once UnusedParameter.Local protected Mediator(IMediatorTarget target) { }
public ContactsListViewMediator(IMediatorTarget contactsListView) : base(contactsListView) { this.View = contactsListView as IContactsListView; }
public ContactDetailsViewMediator(IMediatorTarget target) : base(target) { View = target as IContactDetailsView; }
public ContactsListViewMediator (IMediatorTarget contactsListView):base(contactsListView) { this.View = contactsListView as IContactsListView; }
public ContactDetailsViewMediator (IMediatorTarget target):base(target) { View = target as IContactDetailsView; }