I assume that your objects do not have a direct dependency, for example:
public class SomeType
{
public event EventHandler Input;
public void Raise()
{
if (Input != null)
{
Input(this, new EventArgs());
}
}
}
public class SomeOtherType
{
public void Output(object source, EventArgs handler)
{
Console.WriteLine("Handled");
}
}
You can use the Activate or link delegate:
Activated:
ContainerBuilder cb = new ContainerBuilder();
cb.RegisterType<SomeOtherType>();
cb.RegisterType<SomeType>()
.OnActivated(act =>
{
var other = act.Context.Resolve<SomeOtherType>();
act.Instance.Input += other.Output;
});
var container = cb.Build();
var obj2 = container.Resolve<SomeType>();
obj2.Raise();
, :
cb.Register(ctx =>
{
var other = ctx.Resolve<SomeOtherType>();
var obj = new SomeType();
obj.Input += other.Output;
return obj;
}).As<SomeType>();
, ( ) .
, IDisposable , , .
, xml-, , , , , xml.