Skip to content

Commit 917cff9

Browse files
committed
Add XML docs
1 parent c8b7f47 commit 917cff9

3 files changed

Lines changed: 47 additions & 5 deletions

File tree

src/UnityContainerAttributeRegistration/Populator/FactoryPopulator.cs

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,17 @@
1313

1414
namespace UnityContainerAttributeRegistration.Populator
1515
{
16+
/// <summary>
17+
/// Populator for the <see cref="UnityContainerAttributeRegistration.Attribute.RegisterFactoryAttribute" />.
18+
/// </summary>
1619
internal class FactoryPopulator : Populator
1720
{
21+
/// <inheritdoc cref="Populator.Populate" />
22+
/// <exception cref="InvalidOperationException">Invalid factory method.</exception>
1823
public override IUnityContainer Populate(IUnityContainer container, IList<Type> typesWithAttribute)
1924
{
2025
IEnumerable<FactoryToRegister> factoriesToRegister =
21-
typesWithAttribute.SelectMany(providerClassType => GetInstancesToRegisterFor(container, providerClassType));
26+
typesWithAttribute.SelectMany(providerClassType => GetFactoryToRegisterFor(container, providerClassType));
2227

2328
foreach(FactoryToRegister factoryToRegister in factoriesToRegister)
2429
{
@@ -32,7 +37,14 @@ public override IUnityContainer Populate(IUnityContainer container, IList<Type>
3237
return container;
3338
}
3439

35-
private IEnumerable<FactoryToRegister> GetInstancesToRegisterFor(IUnityContainer container, Type providerClassType)
40+
/// <summary>
41+
/// Get all candidates to register.
42+
/// </summary>
43+
/// <param name="container"><see cref="IUnityContainer" /> to instantiate the provider class</param>
44+
/// <param name="providerClassType">Factory provider class</param>
45+
/// <returns>List of candidates to register</returns>
46+
/// <exception cref="InvalidOperationException">Invalid factory method.</exception>
47+
private IEnumerable<FactoryToRegister> GetFactoryToRegisterFor(IUnityContainer container, Type providerClassType)
3648
{
3749
object providerClassInstance = container.Resolve(providerClassType);
3850
MethodInfo[] methodInfos = providerClassType.GetMethods();
@@ -43,6 +55,13 @@ private IEnumerable<FactoryToRegister> GetInstancesToRegisterFor(IUnityContainer
4355
.ToList();
4456
}
4557

58+
/// <summary>
59+
/// Transform a <see cref="MethodInfo" /> and an instance to a <see cref="FactoryToRegister" /> object.
60+
/// </summary>
61+
/// <param name="info"><see cref="MethodInfo" /> of the factory method.</param>
62+
/// <param name="instance">Instance of the factory method.</param>
63+
/// <returns>Wrapper for easy registration.</returns>
64+
/// <exception cref="InvalidOperationException">Invalid factory method.</exception>
4665
private FactoryToRegister CreateFactoryToRegisterFrom(MethodInfo info, object instance)
4766
{
4867
RegisterFactoryAttribute attribute = info.GetCustomAttribute<RegisterFactoryAttribute>();
@@ -66,6 +85,11 @@ private FactoryToRegister CreateFactoryToRegisterFrom(MethodInfo info, object in
6685
return new FactoryToRegister(returnType, GetFactoryMethodFor(info, instance), lifetimeManager);
6786
}
6887

88+
/// <summary>
89+
/// Verify that the parameters matches the requirements of Unity
90+
/// </summary>
91+
/// <param name="methodInfo"><see cref="MethodInfo" /> to check.</param>
92+
/// <returns>Whether <paramref name="methodInfo" /> matches the requirements or not.</returns>
6993
private bool IsUnityFactorySignature(MethodInfo methodInfo)
7094
{
7195
ParameterInfo[] parameters = methodInfo.GetParameters();
@@ -88,6 +112,12 @@ private bool IsUnityFactorySignature(MethodInfo methodInfo)
88112
}
89113
}
90114

115+
/// <summary>
116+
/// Create a wrapper function for a factory method.
117+
/// </summary>
118+
/// <param name="methodInfo"><see cref="MethodInfo" /> of the factory method.</param>
119+
/// <param name="instance">Instance of the factory method.</param>
120+
/// <returns><see cref="Func{TResult}" /> to call the factory method.</returns>
91121
private Func<IUnityContainer, Type, string, object> GetFactoryMethodFor(MethodInfo methodInfo, object instance)
92122
{
93123
return (container, typeValue, stringValue) =>
@@ -105,6 +135,9 @@ private Func<IUnityContainer, Type, string, object> GetFactoryMethodFor(MethodIn
105135
};
106136
}
107137

138+
/// <summary>
139+
/// Wrapper to register factories
140+
/// </summary>
108141
private sealed class FactoryToRegister
109142
{
110143
public FactoryToRegister([NotNull] Type returnType,
@@ -116,12 +149,21 @@ public FactoryToRegister([NotNull] Type
116149
LifetimeManager = lifetimeManager;
117150
}
118151

152+
/// <summary>
153+
/// Requested type as return type of the factory
154+
/// </summary>
119155
[NotNull]
120156
public Type ReturnType { get; }
121157

158+
/// <summary>
159+
/// Factory method
160+
/// </summary>
122161
[NotNull]
123162
public Func<IUnityContainer, Type, string, object> Factory { get; }
124163

164+
/// <summary>
165+
/// Used lifetime manager
166+
/// </summary>
125167
[CanBeNull]
126168
public IFactoryLifetimeManager LifetimeManager { get; }
127169
}

src/UnityContainerAttributeRegistration/Populator/InstancePopulator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace UnityContainerAttributeRegistration.Populator
1818
/// </summary>
1919
internal class InstancePopulator : Populator
2020
{
21-
/// <inheritdoc cref="Populator" />
21+
/// <inheritdoc cref="Populator.Populate" />
2222
/// <exception cref="InvalidOperationException">Class type must not be static or abstract.</exception>
2323
public override IUnityContainer Populate(IUnityContainer container, IList<Type> typesWithAttribute)
2424
{
@@ -66,7 +66,7 @@ private IEnumerable<InstanceToRegister> GetInstancesToRegisterFor(IUnityContaine
6666
}
6767

6868
/// <summary>
69-
/// Wrapper to regsiter isntances
69+
/// Wrapper to register isntances
7070
/// </summary>
7171
private sealed class InstanceToRegister
7272
{

src/UnityContainerAttributeRegistration/Populator/TypePopulator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace UnityContainerAttributeRegistration.Populator
1515
/// </summary>
1616
internal class TypePopulator : Populator
1717
{
18-
/// <inheritdoc cref="Populator" />
18+
/// <inheritdoc cref="Populator.Populate" />
1919
/// <exception cref="InvalidOperationException">Class type must not be static or abstract.</exception>
2020
public override IUnityContainer Populate(IUnityContainer container, IList<Type> typesWithAttribute)
2121
{

0 commit comments

Comments
 (0)