strangeioc / strangeioc

The IoC/Binding Framework for Unity3D and C#
1.61k stars 444 forks source link

Mediate Base View Class #221

Open crazybaz opened 8 years ago

crazybaz commented 8 years ago

Hi everyone! I had face up with problem of base view mediation:

Base Class public class Pawn : EventView, IPawn

Inherit Classes public class Enemy1 : Pawn public class Enemy2 : Pawn ...

So, when this inherit classes are instantiated, non of this mediations are working mediationBinder.Bind<Pawn>().To<PawnMediator>(); mediationBinder.Bind<Pawn>().ToAbstraction<IPawn>().To<PawnMediator>();

When i try to bind exact classes, it works fine mediationBinder.Bind<Enemy1>().ToAbstraction<IPawn>.To<PawnMediator>(); mediationBinder.Bind<Enemy2>().ToAbstraction<IPawn>.To<PawnMediator>(); ...

But it takes me to write Binding on every new inherit class, so Is it possible to have only one binding on base class?

WillzZz commented 8 years ago

Which version of strange are you using?

I have a PR I made quite some time ago to address roughly this issue. I'm glad you posted what you wanted to work. I think that's probably a reasonable expectation.

https://github.com/strangeioc/strangeioc/pull/168

crazybaz commented 8 years ago

i'm using StrangeIoC v0.51a thx, i'll take a look on your feature