Mugen Injection [Параметры]
Когда вы регистрируете зависимости, вы можете задать параметры.
Доступные типы параметров:
- ConstructorParameter - представляет аргумент конструктора.
- PropertyParameter - представляет значение свойства.
- MethodParameter - представляет аргумент метода.
Пример кода:
public class Alpha { [Inject] public string PublicField; [Inject] private string _field; [Inject] public string Property { get; set; } public Alpha(string st) { } [Inject] public void Method(string param) { } } // Create your MugenInjector. _injector = new MugenInjector(); _injector.Bind<Alpha>() .ToSelf() .WithConstructorArguments(context => new Alpha("constructorParam")) .WithPropertyValue(alpha => alpha.Property, "propertyParam") .WithMethodArguments((context, alpha) => alpha.Method("methodParam")) .WithParameter(new FieldParameter("_field", "privateFieldParam")); var alpha1 = _injector.Get<Alpha>();