示例#1
0
 protected static Action CreatePreOperation(DependencyHandler dependency, List <Type> typeList) =>
 () => dependency.OnRegister += type => typeList.Add(type);
示例#2
0
 protected static Action CreatePostOperation(DependencyHandler dependency, List <Type> typeList) =>
 () => typeList.Each(type => dependency.Unregister(type));
示例#3
0
 /// <summary> Creates a scope which removes all dependencies that are registered within the scope from the dependency map when the scope ends. </summary>
 /// <remarks> Types registered inside the scope are not removed if they had already been registered to the shared dependency map outside the scope. </remarks>
 /// <param name="dependency"> The handler of shared dependencies. </param>
 public DependencyScope(DependencyHandler dependency)
     : base(new List <Type>().Into(typeList => new ScopedOperation(
                                       DependencyScope.CreatePreOperation(dependency, typeList),
                                       DependencyScope.CreatePostOperation(dependency, typeList))))
 {
 }