Skip to content

Commit 82891e4

Browse files
committed
Updating and refactoring
1 parent 55fb274 commit 82891e4

File tree

7 files changed

+36
-19
lines changed

7 files changed

+36
-19
lines changed

src/Builder/IBuilderContext.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ public static object NewBuildUp(this IBuilderContext context, INamedType newBuil
157157
.NewBuildUp(newBuildKey?.Type, newBuildKey?.Name, childCustomizationBlock);
158158
}
159159

160-
161160
/// <summary>
162161
/// Start a recursive build up operation to retrieve the default
163162
/// value for the given <typeparamref name="TResult"/> type.

src/Builder/Selection/SelectedProperty.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public SelectedProperty(PropertyInfo property, IResolverPolicy resolver)
3232
public PropertyInfo Property { get; }
3333

3434
/// <summary>
35-
/// IDependencyResolverPolicy for this property
35+
/// IResolverPolicy for this property
3636
/// </summary>
3737
public IResolverPolicy Resolver { get; }
3838
}

src/Extension/ExtensionContext.cs

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,40 +16,58 @@ namespace Unity.Extension
1616
/// </summary>
1717
public abstract class ExtensionContext
1818
{
19+
#region Container
20+
1921
/// <summary>
2022
/// The container that this context is associated with.
2123
/// </summary>
2224
/// <value>The <see cref="IUnityContainer"/> object.</value>
2325
public abstract IUnityContainer Container { get; }
2426

27+
/// <summary>
28+
/// The <see cref="ILifetimeContainer"/> that this container uses.
29+
/// </summary>
30+
/// <value>The <see cref="ILifetimeContainer"/> is used to manage <see cref="IDisposable"/> objects that the container is managing.</value>
31+
public abstract ILifetimeContainer Lifetime { get; }
32+
33+
#endregion
34+
35+
36+
#region Strategies
37+
2538
/// <summary>
2639
/// The strategies this container uses.
2740
/// </summary>
2841
/// <value>The <see cref="IStagedStrategyChain{TStrategyType,TStageEnum}"/> that the container uses to build objects.</value>
29-
public abstract IStagedStrategyChain<IBuilderStrategy,UnityBuildStage> Strategies { get; }
30-
42+
public abstract IStagedStrategyChain<IBuilderStrategy, UnityBuildStage> Strategies { get; }
43+
3144
/// <summary>
3245
/// The strategies this container uses to construct build plans.
3346
/// </summary>
3447
/// <value>The <see cref="IStagedStrategyChain{TStrategyType,TStageEnum}"/> that this container uses when creating
3548
/// build plans.</value>
3649
public abstract IStagedStrategyChain<IBuilderStrategy, BuilderStage> BuildPlanStrategies { get; }
3750

51+
#endregion
52+
53+
54+
#region Policy Lists
55+
3856
/// <summary>
3957
/// The policies this container uses.
4058
/// </summary>
4159
/// <remarks>The <see cref="IPolicyList"/> the that container uses to build objects.</remarks>
4260
public abstract IPolicyList Policies { get; }
4361

44-
/// <summary>
45-
/// The <see cref="ILifetimeContainer"/> that this container uses.
46-
/// </summary>
47-
/// <value>The <see cref="ILifetimeContainer"/> is used to manage <see cref="IDisposable"/> objects that the container is managing.</value>
48-
public abstract ILifetimeContainer Lifetime { get; }
62+
#endregion
63+
64+
65+
#region Events
4966

5067
/// <summary>
51-
/// This event is raised when the <see cref="IUnityContainer.RegisterType(Type,Type,string,LifetimeManager, Unity.Registration.InjectionMember[])"/> method,
52-
/// or one of its overloads, is called.
68+
/// This event is raised when the
69+
/// <see cref="IUnityContainer.RegisterType(Type,Type,string,LifetimeManager, Unity.Registration.InjectionMember[])"/>
70+
/// method, or one of its overloads, is called.
5371
/// </summary>
5472
public abstract event EventHandler<RegisterEventArgs> Registering;
5573

@@ -64,5 +82,7 @@ public abstract class ExtensionContext
6482
/// the newly created child container to extensions to act on as they see fit.
6583
/// </summary>
6684
public abstract event EventHandler<ChildContainerCreatedEventArgs> ChildContainerCreated;
85+
86+
#endregion
6787
}
6888
}

src/Injection/InjectionFactory.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ public void BuildUp(IBuilderContext context)
6969
{
7070
if ((context ?? throw new ArgumentNullException(nameof(context))).Existing == null)
7171
{
72-
var currentContainer = context.NewBuildUp<IUnityContainer>();
73-
context.Existing = _factoryFunc(currentContainer, context.BuildKey.Type, context.BuildKey.Name);
72+
context.Existing = _factoryFunc(context.Container, context.BuildKey.Type, context.BuildKey.Name);
7473
context.SetPerBuildSingleton();
7574
}
7675
}

src/ResolverPolicy/FixedTypeResolverPolicy.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public FixedTypeResolverPolicy(Type typeToBuild)
2424
_keyToBuild = new NamedTypeBuildKey(typeToBuild);
2525
}
2626

27-
#region IDependencyResolverPolicy Members
27+
#region IResolverPolicy Members
2828

2929
/// <summary>
3030
/// GetOrDefault the value for a dependency.
@@ -33,7 +33,7 @@ public FixedTypeResolverPolicy(Type typeToBuild)
3333
/// <returns>The value for the dependency.</returns>
3434
public object Resolve(IBuilderContext context)
3535
{
36-
return (context ?? throw new ArgumentNullException(nameof(context))).NewBuildUp(_keyToBuild);
36+
return (context ?? throw new ArgumentNullException(nameof(context))).NewBuildUp(_keyToBuild.Type, _keyToBuild.Name);
3737
}
3838

3939
#endregion

src/ResolverPolicy/NamedTypeDependencyResolverPolicy.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public NamedTypeDependencyResolverPolicy(Type type, string name)
3333
public object Resolve(IBuilderContext context)
3434
{
3535
return (context ?? throw new ArgumentNullException(nameof(context)))
36-
.NewBuildUp(new NamedTypeBuildKey(Type, Name));
36+
.NewBuildUp(Type, Name);
3737
}
3838

3939
/// <summary>

src/ResolverPolicy/OptionalDependencyResolverPolicy.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public OptionalDependencyResolverPolicy(Type type)
5454
/// </summary>
5555
public string Name { get; }
5656

57-
#region IDependencyResolverPolicy Members
57+
#region IResolverPolicy Members
5858

5959
/// <summary>
6060
/// GetOrDefault the value for a dependency.
@@ -63,10 +63,9 @@ public OptionalDependencyResolverPolicy(Type type)
6363
/// <returns>The value for the dependency.</returns>
6464
public object Resolve(IBuilderContext context)
6565
{
66-
var newKey = new NamedTypeBuildKey(DependencyType, Name);
6766
try
6867
{
69-
return (context ?? throw new ArgumentNullException(nameof(context))).NewBuildUp(newKey);
68+
return (context ?? throw new ArgumentNullException(nameof(context))).NewBuildUp(DependencyType, Name);
7069
}
7170
catch (Exception)
7271
{

0 commit comments

Comments
 (0)