Robotlegs-Sharp vs. Strange mediate Interfaces

38 views
Skip to first unread message

Michael Kneib

unread,
Feb 6, 2018, 3:29:07 AM2/6/18
to StrangeIoC


Hi, I have tested robotlegs for unity for a while now, but seems to be responsible for crashes in the IDE.
So I thought I'd give StrangeIOC a chance. But in the following scenario, I have a problem with the syntax:

I have a view class, that implements an interface:

public class MyView: EventView, IDoSomething {}

With robotlegs I can now easily attach multiple mediators to my view, simply by implementing the interfaces:

mediatorMap
. map<IDoSomething> (). ToMediator<DoSomethingMediator> ();
mediatorMap
. map<MyView> (). ToMediator<MyMediator> ();

i like the benefit of implementing interfaces in my view classes, that automatically will be mediated .
i have tried the same with strangeioc, but the mediator for IDoSomething is not attached to the view:

mediationBinder. Bind<IDoSomething> (). To<DoSomethingMediator> ();
mediationBinder
. Bind<MyView> (). To<MyMediator> ()

is this the wrong syntax to bind a mediator to an interface?
or is it not possible to attach a mediator to a view via interface?

greets
micha

wcorwin

unread,
Feb 6, 2018, 7:31:17 PM2/6/18
to StrangeIoC
Ahh, interesting. This is unimplemented. We're pulling view.GetType() and checking that against a dictionary of registered types. Obviously this isn't grabbing the interfaces it implements. Good catch! I'm flying out tomorrow am, but I can see what the solution would be. If anyone's curious, check out AbstractMediationBinder.MapView. 

We either need to utilize ReflectedClass (with no reflection binder currently in an abstractmediationbinder) or check it once upon Bind and instead of mapping a 1:1 of viewType : mediatorType think of it more like viewType : AllMediatorTypes. So basically iterate the interfaces when we Bind.

Thanks for the feedback! Sorry it doesn't work the way you expect, but it shouldn't be too much trouble to change.

Michael Kneib

unread,
Feb 7, 2018, 11:59:01 AM2/7/18
to wcorwin, StrangeIoC
Thank you for the quick reply. And i thought i made a beginner's mistake :). Unfortunately (or luckily) robotlegs wasn't responsible for my crashes, so i stick to the "original" for now. But with signals there are enough reasons for a later change.
 
What I also found annoying when changing was the necessity of injects with {get; set; } declaration. Robotlegs doesn't need this and that avoids annoying annotations of lower case variables in Visual Studio.

Looking forward to new versions. Great Framework!

greets
micha


--
You received this message because you are subscribed to a topic in the Google Groups "StrangeIoC" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/strangeioc/W-VrOkQGPi8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to strangeioc+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages