Example #1
0
        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));
        }
Example #2
0
 public static void DestroyMediator(IMediatorTarget target)
 {
     if (MediatorAssignments.ContainsKey(target))
     {
         MediatorAssignments [target].Unregister();
         MediatorAssignments.Remove(target);
     }
 }
Example #3
0
        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);
        }
Example #4
0
 public TestMediator(IMediatorTarget target) : base(target)
 {
     Target = target as ITestTargetInteface;
 }
 public Mediator(IMediatorTarget target)
 {
 }
Example #6
0
 public TestMediator(IMediatorTarget target)
     : base(target)
 {
     Target = target as ITestTargetInteface;
 }
 // ReSharper disable once UnusedParameter.Local
 protected Mediator(IMediatorTarget target)
 {
 }
Example #8
0
 public ContactsListViewMediator(IMediatorTarget contactsListView) : base(contactsListView)
 {
     this.View = contactsListView as IContactsListView;
 }
 public ContactDetailsViewMediator(IMediatorTarget target) : base(target)
 {
     View = target as IContactDetailsView;
 }
Example #10
0
 public Mediator(IMediatorTarget target)
 {
 }
		public ContactsListViewMediator (IMediatorTarget contactsListView):base(contactsListView)
		{
			this.View = contactsListView as IContactsListView;
		}
 // ReSharper disable once UnusedParameter.Local
 protected Mediator(IMediatorTarget target)
 {
 }
		public ContactDetailsViewMediator (IMediatorTarget target):base(target)
		{
			View = target as IContactDetailsView;
		}