Skip to content

Commit

Permalink
Made CreateRegistrationCore protected internal.
Browse files Browse the repository at this point in the history
Related to #380.
  • Loading branch information
dotnetjunkie committed Feb 18, 2017
1 parent 1f1b651 commit 7873887
Show file tree
Hide file tree
Showing 14 changed files with 59 additions and 59 deletions.
Expand Up @@ -158,10 +158,10 @@ public FakeLifestyle(int length)

public override int Length { get; }

protected override Registration CreateRegistrationCore<TConcrete>(Container c) =>
protected internal override Registration CreateRegistrationCore<TConcrete>(Container c) =>
new FakeRegistration<TConcrete>(this, c);

protected override Registration CreateRegistrationCore<TService>(Func<TService> instanceCreator,
protected internal override Registration CreateRegistrationCore<TService>(Func<TService> instanceCreator,
Container container)
{
throw new NotImplementedException();
Expand Down
Expand Up @@ -470,12 +470,12 @@ protected internal override Func<Scope> CreateCurrentScopeProvider(Container con

public override int Length => this.realLifestyle.ComponentLength(null);

protected override Registration CreateRegistrationCore<TConcrete>(Container container)
protected internal override Registration CreateRegistrationCore<TConcrete>(Container container)
{
return this.realLifestyle.CreateRegistration<TConcrete>(container);
}

protected override Registration CreateRegistrationCore<TService>(Func<TService> instanceCreator,
protected internal override Registration CreateRegistrationCore<TService>(Func<TService> instanceCreator,
Container container)
{
return this.realLifestyle.CreateRegistration(instanceCreator, container);
Expand All @@ -492,10 +492,10 @@ public FakeLifestyle(string name, int length) : base("Fake " + name)

public override int Length { get; }

protected override Registration CreateRegistrationCore<TConcrete>(Container c) =>
protected internal override Registration CreateRegistrationCore<TConcrete>(Container c) =>
Transient.CreateRegistration<TConcrete>(c);

protected override Registration CreateRegistrationCore<TService>(Func<TService> creator, Container c) =>
protected internal override Registration CreateRegistrationCore<TService>(Func<TService> creator, Container c) =>
Transient.CreateRegistration(creator, c);
}
}
Expand Up @@ -263,12 +263,12 @@ public FakeLifestyle() : base("Fake")

public override int Length => Transient.Length;

protected override Registration CreateRegistrationCore<TConcrete>(Container container)
protected internal override Registration CreateRegistrationCore<TConcrete>(Container container)
{
return this.RegistrationToReturn;
}

protected override Registration CreateRegistrationCore<TService>(Func<TService> instanceCreator,
protected internal override Registration CreateRegistrationCore<TService>(Func<TService> instanceCreator,
Container container)
{
return this.RegistrationToReturn;
Expand Down
4 changes: 2 additions & 2 deletions src/SimpleInjector.Core.Tests.Unit/LifestyleTests.cs
Expand Up @@ -305,12 +305,12 @@ public override int Length
get { throw new NotImplementedException(); }
}

protected override Registration CreateRegistrationCore<TConcrete>(Container container)
protected internal override Registration CreateRegistrationCore<TConcrete>(Container container)
{
throw new NotImplementedException();
}

protected override Registration CreateRegistrationCore<TService>(Func<TService> instanceCreator,
protected internal override Registration CreateRegistrationCore<TService>(Func<TService> instanceCreator,
Container container)
{
throw new NotImplementedException();
Expand Down
Expand Up @@ -678,22 +678,22 @@ protected internal override Func<Scope> CreateCurrentScopeProvider(Container con
};
}

protected override Scope GetCurrentScopeCore(Container container)
{
this.GetCurrentScopeCoreCallCount++;
return base.GetCurrentScopeCore(container);
}

protected override Registration CreateRegistrationCore<TConcrete>(Container container)
protected internal override Registration CreateRegistrationCore<TConcrete>(Container container)
{
return this.realLifestyle.CreateRegistration<TConcrete>(container);
}

protected override Registration CreateRegistrationCore<TService>(Func<TService> instanceCreator,
protected internal override Registration CreateRegistrationCore<TService>(Func<TService> instanceCreator,
Container container)
{
return this.realLifestyle.CreateRegistration(instanceCreator, container);
}

protected override Scope GetCurrentScopeCore(Container container)
{
this.GetCurrentScopeCoreCallCount++;
return base.GetCurrentScopeCore(container);
}
}
}
}
4 changes: 2 additions & 2 deletions src/SimpleInjector/Lifestyle.cs
Expand Up @@ -750,7 +750,7 @@ internal Registration CreateRegistrationInternal<TConcrete>(Container container,
/// to create and return a new <see cref="Registration"/>. Note that you should <b>always</b> create
/// a new <see cref="Registration"/> instance. They should never be cached.
/// </remarks>
protected abstract Registration CreateRegistrationCore<TConcrete>(Container container)
protected internal abstract Registration CreateRegistrationCore<TConcrete>(Container container)
where TConcrete : class;

/// <summary>
Expand All @@ -770,7 +770,7 @@ internal Registration CreateRegistrationInternal<TConcrete>(Container container,
/// to create and return a new <see cref="Registration"/>. Note that you should <b>always</b> create
/// a new <see cref="Registration"/> instance. They should never be cached.
/// </remarks>
protected abstract Registration CreateRegistrationCore<TService>(Func<TService> instanceCreator,
protected internal abstract Registration CreateRegistrationCore<TService>(Func<TService> instanceCreator,
Container container)
where TService : class;

Expand Down
4 changes: 2 additions & 2 deletions src/SimpleInjector/Lifestyles/CustomLifestyle.cs
Expand Up @@ -46,12 +46,12 @@ public override int Length
// Ensure that this lifestyle can only be safely used with transient components/consumers.
internal override int DependencyLength(Container container) => Transient.DependencyLength(container);

protected override Registration CreateRegistrationCore<TConcrete>(Container container)
protected internal override Registration CreateRegistrationCore<TConcrete>(Container container)
{
return new CustomRegistration<TConcrete>(this.lifestyleApplierFactory, this, container);
}

protected override Registration CreateRegistrationCore<TService>(Func<TService> instanceCreator,
protected internal override Registration CreateRegistrationCore<TService>(Func<TService> instanceCreator,
Container container)
{
Requires.IsNotNull(instanceCreator, nameof(instanceCreator));
Expand Down
4 changes: 2 additions & 2 deletions src/SimpleInjector/Lifestyles/HybridLifestyle.cs
Expand Up @@ -72,7 +72,7 @@ internal static string GetHybridName(Lifestyle lifestyle)
return lifestyle.Name;
}

protected override Registration CreateRegistrationCore<TConcrete>(Container container)
protected internal override Registration CreateRegistrationCore<TConcrete>(Container container)
{
Func<bool> test = () => this.lifestyleSelector(container);

Expand All @@ -82,7 +82,7 @@ protected override Registration CreateRegistrationCore<TConcrete>(Container cont
this, container);
}

protected override Registration CreateRegistrationCore<TService>(Func<TService> instanceCreator,
protected internal override Registration CreateRegistrationCore<TService>(Func<TService> instanceCreator,
Container container)
{
Func<bool> test = () => this.lifestyleSelector(container);
Expand Down
Expand Up @@ -44,14 +44,14 @@ public override int Length
get { throw new NotImplementedException(); }
}

protected override Registration CreateRegistrationCore<TConcrete>(Container container)
protected internal override Registration CreateRegistrationCore<TConcrete>(Container container)
{
Lifestyle lifestyle = this.options.SelectLifestyle(typeof(TConcrete));

return lifestyle.CreateRegistration<TConcrete>(container);
}

protected override Registration CreateRegistrationCore<TService>(Func<TService> instanceCreator,
protected internal override Registration CreateRegistrationCore<TService>(Func<TService> instanceCreator,
Container container)
{
Lifestyle lifestyle = this.options.SelectLifestyle(typeof(TService));
Expand Down
10 changes: 5 additions & 5 deletions src/SimpleInjector/Lifestyles/ScopedProxyLifestyle.cs
Expand Up @@ -39,15 +39,15 @@ public ScopedProxyLifestyle() : base("Scoped")
protected internal override Func<Scope> CreateCurrentScopeProvider(Container container) =>
GetDefaultScopedLifestyle(container).CreateCurrentScopeProvider(container);

protected override Scope GetCurrentScopeCore(Container container) =>
GetDefaultScopedLifestyle(container).GetCurrentScope(container);

protected override Registration CreateRegistrationCore<TConcrete>(Container container) =>
protected internal override Registration CreateRegistrationCore<TConcrete>(Container container) =>
GetDefaultScopedLifestyle(container).CreateRegistration<TConcrete>(container);

protected override Registration CreateRegistrationCore<TService>(Func<TService> creator, Container c) =>
protected internal override Registration CreateRegistrationCore<TService>(Func<TService> creator, Container c) =>
GetDefaultScopedLifestyle(c).CreateRegistration<TService>(creator, c);

protected override Scope GetCurrentScopeCore(Container container) =>
GetDefaultScopedLifestyle(container).GetCurrentScope(container);

#if !NET40
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/SimpleInjector/Lifestyles/SingletonLifestyle.cs
Expand Up @@ -75,10 +75,10 @@ internal SingletonLifestyle() : base("Singleton")
internal static bool IsSingletonInstanceRegistration(Registration registration) =>
registration is SingletonInstanceLifestyleRegistration;

protected override Registration CreateRegistrationCore<TConcrete>(Container container) =>
protected internal override Registration CreateRegistrationCore<TConcrete>(Container container) =>
new SingletonLifestyleRegistration<TConcrete>(container);

protected override Registration CreateRegistrationCore<TService>(Func<TService> instanceCreator,
protected internal override Registration CreateRegistrationCore<TService>(Func<TService> instanceCreator,
Container container)
{
Requires.IsNotNull(instanceCreator, nameof(instanceCreator));
Expand Down
4 changes: 2 additions & 2 deletions src/SimpleInjector/Lifestyles/TransientLifestyle.cs
Expand Up @@ -33,12 +33,12 @@ internal TransientLifestyle() : base("Transient")

public override int Length => 1;

protected override Registration CreateRegistrationCore<TConcrete>(Container container)
protected internal override Registration CreateRegistrationCore<TConcrete>(Container container)
{
return new TransientLifestyleRegistration<TConcrete>(this, container);
}

protected override Registration CreateRegistrationCore<TService>(Func<TService> instanceCreator,
protected internal override Registration CreateRegistrationCore<TService>(Func<TService> instanceCreator,
Container container)
{
return new TransientLifestyleRegistration<TService>(this, container, instanceCreator);
Expand Down
4 changes: 2 additions & 2 deletions src/SimpleInjector/Lifestyles/UnknownLifestyle.cs
Expand Up @@ -39,13 +39,13 @@ public override int Length

internal override int DependencyLength(Container container) => Transient.DependencyLength(container);

protected override Registration CreateRegistrationCore<TConcrete>(Container container)
protected internal override Registration CreateRegistrationCore<TConcrete>(Container container)
{
throw new InvalidOperationException(
"The unknown lifestyle does not allow creation of registrations.");
}

protected override Registration CreateRegistrationCore<TService>(Func<TService> instanceCreator,
protected internal override Registration CreateRegistrationCore<TService>(Func<TService> instanceCreator,
Container container)
{
throw new InvalidOperationException(
Expand Down
44 changes: 22 additions & 22 deletions src/SimpleInjector/ScopedLifestyle.cs
Expand Up @@ -127,26 +127,6 @@ public Scope GetCurrentScope(Container container)
/// <returns>A <see cref="Func{T}"/> delegate. This method should never return null.</returns>
protected internal abstract Func<Scope> CreateCurrentScopeProvider(Container container);

/// <summary>
/// Returns the current <see cref="Scope"/> for this lifestyle and the given
/// <paramref name="container"/>, or null when this method is executed outside the context of a scope.
/// </summary>
/// <remarks>
/// By default, this method calls the <see cref="CreateCurrentScopeProvider"/> method and invokes the
/// returned delegate. This method can be overridden to provide an optimized way for getting the
/// current scope.
/// </remarks>
/// <param name="container">The container instance that is related to the scope to return.</param>
/// <returns>A <see cref="Scope"/> instance or null when there is no scope active in this context.</returns>
protected virtual Scope GetCurrentScopeCore(Container container)
{
Requires.IsNotNull(container, nameof(container));

Func<Scope> currentScopeProvider = this.CreateCurrentScopeProvider(container);

return currentScopeProvider.Invoke();
}

/// <summary>
/// Creates a new <see cref="Registration"/> instance defining the creation of the
/// specified <typeparamref name="TService"/> using the supplied <paramref name="instanceCreator"/>
Expand All @@ -158,7 +138,7 @@ protected virtual Scope GetCurrentScopeCore(Container container)
/// <param name="container">The <see cref="Container"/> instance for which a
/// <see cref="Registration"/> must be created.</param>
/// <returns>A new <see cref="Registration"/> instance.</returns>
protected override Registration CreateRegistrationCore<TService>(Func<TService> instanceCreator,
protected internal override Registration CreateRegistrationCore<TService>(Func<TService> instanceCreator,
Container container)
{
Requires.IsNotNull(instanceCreator, nameof(instanceCreator));
Expand All @@ -175,13 +155,33 @@ protected virtual Scope GetCurrentScopeCore(Container container)
/// <param name="container">The <see cref="Container"/> instance for which a
/// <see cref="Registration"/> must be created.</param>
/// <returns>A new <see cref="Registration"/> instance.</returns>
protected override Registration CreateRegistrationCore<TConcrete>(Container container)
protected internal override Registration CreateRegistrationCore<TConcrete>(Container container)
{
Requires.IsNotNull(container, nameof(container));

return new ScopedRegistration<TConcrete>(this, container);
}

/// <summary>
/// Returns the current <see cref="Scope"/> for this lifestyle and the given
/// <paramref name="container"/>, or null when this method is executed outside the context of a scope.
/// </summary>
/// <remarks>
/// By default, this method calls the <see cref="CreateCurrentScopeProvider"/> method and invokes the
/// returned delegate. This method can be overridden to provide an optimized way for getting the
/// current scope.
/// </remarks>
/// <param name="container">The container instance that is related to the scope to return.</param>
/// <returns>A <see cref="Scope"/> instance or null when there is no scope active in this context.</returns>
protected virtual Scope GetCurrentScopeCore(Container container)
{
Requires.IsNotNull(container, nameof(container));

Func<Scope> currentScopeProvider = this.CreateCurrentScopeProvider(container);

return currentScopeProvider.Invoke();
}

#if !NET40
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
#endif
Expand Down

0 comments on commit 7873887

Please sign in to comment.