我对使用装饰器简单注入器的 IoC 有问题。
如何在 Ioc Simple 注入器中注册它?
var data = new Data();
var test = new Data2Decorator (data,
new Data1Decorator(data, new XxxData(data)))
我这样尝试过。
_container.Register<Ixxx1>();
_container.Register<Ixxx2>();
_container.Register<Ixxx, Data>();
_container.Register<IData, XxxData>();
container.RegisterDecorator<IData, Data1Decorator>();
_container.RegisterDecorator<IData, Data2Decorator>():
public interface Ixxx1
{
public IEnumerable<...> x1 { get; set; }
}
public class Data1Decorator : DataDecorator
{
public readonly Ixxx1 _xxx1;
public Data1Decorator(Ixxx1 xxx1, IData data) : base(data)
{
_xxx1 = xxx1;
}
public override Task Load()
{
return Task.WhenAll(new List<Task>() { ..., base.Load() })
.ContinueWith((b) =>
{
_xxx1.x1 = ...
});
}
}
常用存储数据
public interface Ixxx :
Ixxx1,
Ixxx2
{
}
public class Data: Ixxx
{
public IEnumerable<...> x1 { get; set; }
public IEnumerable<...> x2 { get; set; }
}
qq_遁去的一_1
相关分类