Skip to content

Commit

Permalink
De-nest ServiceCharacteristics
Browse files Browse the repository at this point in the history
  • Loading branch information
ajcvickers committed Apr 7, 2020
1 parent 2eff34d commit 2215c3b
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ public EntityFrameworkRelationalServicesBuilder([NotNull] IServiceCollection ser
}

/// <summary>
/// Gets the <see cref="EntityFrameworkServicesBuilder.ServiceCharacteristics" /> for the given service type.
/// Gets the <see cref="ServiceCharacteristics" /> for the given service type.
/// </summary>
/// <param name="serviceType"> The type that defines the service API. </param>
/// <returns> The <see cref="EntityFrameworkServicesBuilder.ServiceCharacteristics" /> for the type. </returns>
/// <returns> The <see cref="ServiceCharacteristics" /> for the type. </returns>
/// <exception cref="InvalidOperationException"> when the type is not an EF service. </exception>
protected override ServiceCharacteristics GetServiceCharacteristics(Type serviceType)
=> RelationalServices.TryGetValue(serviceType, out var characteristics)
Expand Down
27 changes: 0 additions & 27 deletions src/EFCore/Infrastructure/EntityFrameworkServicesBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -451,32 +451,5 @@ public virtual EntityFrameworkServicesBuilder TryAdd(

return this;
}

/// <summary>
/// Characteristics of a given EF service.
/// </summary>
public readonly struct ServiceCharacteristics
{
/// <summary>
/// Creates a new <see cref="ServiceCharacteristics" /> struct.
/// </summary>
/// <param name="lifetime"> The service lifetime. </param>
/// <param name="multipleRegistrations"> True if multiple registrations of the service is allowed; false otherwise. </param>
public ServiceCharacteristics(ServiceLifetime lifetime, bool multipleRegistrations = false)
{
Lifetime = lifetime;
MultipleRegistrations = multipleRegistrations;
}

/// <summary>
/// The service lifetime.
/// </summary>
public ServiceLifetime Lifetime { get; }

/// <summary>
/// True if multiple registrations of the service is allowed; false otherwise.
/// </summary>
public bool MultipleRegistrations { get; }
}
}
}
34 changes: 34 additions & 0 deletions src/EFCore/Infrastructure/ServiceCharacteristics.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using Microsoft.Extensions.DependencyInjection;

namespace Microsoft.EntityFrameworkCore.Infrastructure
{
/// <summary>
/// Characteristics of a given EF service.
/// </summary>
public readonly struct ServiceCharacteristics
{
/// <summary>
/// Creates a new <see cref="ServiceCharacteristics" /> struct.
/// </summary>
/// <param name="lifetime"> The service lifetime. </param>
/// <param name="multipleRegistrations"> True if multiple registrations of the service is allowed; false otherwise. </param>
public ServiceCharacteristics(ServiceLifetime lifetime, bool multipleRegistrations = false)
{
Lifetime = lifetime;
MultipleRegistrations = multipleRegistrations;
}

/// <summary>
/// The service lifetime.
/// </summary>
public ServiceLifetime Lifetime { get; }

/// <summary>
/// True if multiple registrations of the service is allowed; false otherwise.
/// </summary>
public bool MultipleRegistrations { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public virtual void Required_services_are_registered_with_expected_lifetimes()
}

protected virtual void LifetimeTest(
params IDictionary<Type, EntityFrameworkServicesBuilder.ServiceCharacteristics>[] serviceDefinitions)
params IDictionary<Type, ServiceCharacteristics>[] serviceDefinitions)
{
var services = AddServices(new ServiceCollection());

Expand Down

0 comments on commit 2215c3b

Please sign in to comment.