Mugen Injection [Circular dependencies]
This is when you have one class (Alpha) that takes a dependency of a second type (Beta) and the second type (Beta) has a dependency of the first type (Alpha). In this case you can write behavior to resolve circular dependencies.
This code shows how it works:
public class Alpha { public Bravo Bravo { get; set; } public Alpha(Bravo bravo) { Bravo = bravo; } } public class Bravo { public Alpha Alpha { get; set; } public Bravo(Alpha alpha) { Alpha = alpha; } } public class CycleDependencyResolver : ICycleDependencyBehavior { #region Implementation of ICycleDependencyBehavior public bool Resolve(IBindingContext bindingContext, out object result) { if (bindingContext.Service == typeof(Bravo) && bindingContext.TypeInto == typeof(Alpha)) { result = new Bravo(null); return true; } result = null; return false; } #endregion } // Create your MugenInjector. _injector = new MugenInjector(); _injector.Components .Get<IBehaviorManagerComponent>() .Add<ICycleDependencyBehavior>(new CycleDependencyResolver()); var bravo = _injector.Get<Bravo>();