Refactor namings.

pull/96/head
Halil İbrahim Kalkan 8 years ago
parent 3054dbf572
commit bec0f6bec2

@ -21,9 +21,9 @@ namespace Autofac.Builder
return registrationBuilder;
}
var serviceRegistredArgs = new OnServiceRegistredArgs(serviceType);
var serviceRegistredArgs = new OnServiceRegistredContext(serviceType);
foreach (var registrationAction in services.GetServiceRegistrationActionList())
foreach (var registrationAction in services.GetRegistrationActionList())
{
registrationAction.Invoke(serviceRegistredArgs);
}

@ -4,7 +4,7 @@ using Volo.Abp.DynamicProxy;
namespace Microsoft.Extensions.DependencyInjection
{
public interface IOnServiceRegistredArgs
public interface IOnServiceRegistredContext
{
ITypeList<IAbpInterceptor> Interceptors { get; }

@ -6,13 +6,13 @@ using Volo.Abp.DynamicProxy;
namespace Microsoft.Extensions.DependencyInjection
{
public class OnServiceRegistredArgs : IOnServiceRegistredArgs
public class OnServiceRegistredContext : IOnServiceRegistredContext
{
public virtual ITypeList<IAbpInterceptor> Interceptors { get; }
public virtual Type ImplementationType { get; }
public OnServiceRegistredArgs([NotNull] Type implementationType)
public OnServiceRegistredContext([NotNull] Type implementationType)
{
ImplementationType = Check.NotNull(implementationType, nameof(implementationType));

@ -5,17 +5,17 @@ namespace Microsoft.Extensions.DependencyInjection
{
public static class ServiceCollectionRegistrationActionExtensions
{
public static void OnServiceRegistred(this IServiceCollection services, Action<IOnServiceRegistredArgs> registrationAction)
public static void OnRegistred(this IServiceCollection services, Action<IOnServiceRegistredContext> registrationAction)
{
GetOrCreateServiceActionList(services).Add(registrationAction);
GetOrCreateRegistrationActionList(services).Add(registrationAction);
}
public static ServiceRegistrationActionList GetServiceRegistrationActionList(this IServiceCollection services)
public static ServiceRegistrationActionList GetRegistrationActionList(this IServiceCollection services)
{
return GetOrCreateServiceActionList(services);
return GetOrCreateRegistrationActionList(services);
}
private static ServiceRegistrationActionList GetOrCreateServiceActionList(IServiceCollection services)
private static ServiceRegistrationActionList GetOrCreateRegistrationActionList(IServiceCollection services)
{
var actionList = services.GetSingletonInstanceOrNull<IObjectAccessor<ServiceRegistrationActionList>>()?.Value;
if (actionList == null)
@ -27,17 +27,17 @@ namespace Microsoft.Extensions.DependencyInjection
return actionList;
}
public static void OnServiceExposing(this IServiceCollection services, Action<IOnServiceExposingArgs> exposeAction)
public static void OnExposing(this IServiceCollection services, Action<IOnServiceExposingContext> exposeAction)
{
GetOrCreateOnServiceExposingList(services).Add(exposeAction);
GetOrCreateExposingList(services).Add(exposeAction);
}
public static ServiceExposingActionList GetServiceExposingActionList(this IServiceCollection services)
public static ServiceExposingActionList GetExposingActionList(this IServiceCollection services)
{
return GetOrCreateOnServiceExposingList(services);
return GetOrCreateExposingList(services);
}
private static ServiceExposingActionList GetOrCreateOnServiceExposingList(IServiceCollection services)
private static ServiceExposingActionList GetOrCreateExposingList(IServiceCollection services)
{
var actionList = services.GetSingletonInstanceOrNull<IObjectAccessor<ServiceExposingActionList>>()?.Value;
if (actionList == null)

@ -1,7 +1,5 @@
using System;
using System.Reflection;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Application.Services;
using Volo.Abp.Modularity;
using Volo.Abp.ObjectMapping;
using Volo.Abp.Reflection;
@ -14,17 +12,10 @@ namespace Volo.Abp
{
public override void PreConfigureServices(IServiceCollection services)
{
//TODO: Move these to dedicated class(es)
services.OnServiceRegistred(registration =>
{
if (typeof(IApplicationService).GetTypeInfo().IsAssignableFrom(registration.ImplementationType))
{
registration.Interceptors.Add<UnitOfWorkInterceptor>();
}
});
services.OnServiceExposing(context =>
services.OnRegistred(UnitOfWorkInterceptorRegistrar.RegisterIfNeeded);
//TODO: Move to a dedicated class
services.OnExposing(context =>
{
context.ExposedTypes.AddRange(
ReflectionHelper.GetImplementedGenericTypes(

@ -0,0 +1,15 @@
using System;
namespace Volo.Abp.Uow
{
/// <summary>
/// Used to indicate that declaring method (or all methods of the class) is atomic and should be considered as a unit of work (UOW).
/// </summary>
/// <remarks>
/// This attribute has no effect if there is already a unit of work before calling this method. It uses the ambient UOW in this case.
/// </remarks>
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Interface)]
public class UnitOfWorkAttribute : Attribute
{
}
}

@ -1,9 +1,23 @@
using System.Threading.Tasks;
using System.Reflection;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Application.Services;
using Volo.Abp.DynamicProxy;
using Volo.DependencyInjection;
namespace Volo.Abp.Uow
{
public static class UnitOfWorkInterceptorRegistrar
{
public static void RegisterIfNeeded(IOnServiceRegistredContext context)
{
if (typeof(IApplicationService).GetTypeInfo().IsAssignableFrom(context.ImplementationType))
{
context.Interceptors.Add<UnitOfWorkInterceptor>();
}
}
}
public class UnitOfWorkInterceptor : AbpInterceptor, ITransientDependency
{
private readonly IUnitOfWorkManager _unitOfWorkManager;

@ -48,11 +48,11 @@ namespace Volo.DependencyInjection
}
}
var exposeActions = services.GetServiceExposingActionList();
var exposeActions = services.GetExposingActionList();
if (exposeActions.Any())
{
var args = new OnServiceExposingArgs(type, serviceTypes);
foreach (var action in services.GetServiceExposingActionList())
var args = new OnServiceExposingContext(type, serviceTypes);
foreach (var action in services.GetExposingActionList())
{
action(args);
}

@ -3,7 +3,7 @@ using System.Collections.Generic;
namespace Volo.DependencyInjection
{
public interface IOnServiceExposingArgs
public interface IOnServiceExposingContext
{
Type ImplementationType { get; }

@ -4,13 +4,13 @@ using JetBrains.Annotations;
namespace Volo.DependencyInjection
{
public class OnServiceExposingArgs : IOnServiceExposingArgs
public class OnServiceExposingContext : IOnServiceExposingContext
{
public Type ImplementationType { get; }
public List<Type> ExposedTypes { get; }
public OnServiceExposingArgs([NotNull] Type implementationType, List<Type> exposedTypes)
public OnServiceExposingContext([NotNull] Type implementationType, List<Type> exposedTypes)
{
ImplementationType = Check.NotNull(implementationType, nameof(implementationType));
ExposedTypes = Check.NotNull(exposedTypes, nameof(exposedTypes));

@ -3,7 +3,7 @@ using System.Collections.Generic;
namespace Volo.DependencyInjection
{
public class ServiceExposingActionList : List<Action<IOnServiceExposingArgs>>
public class ServiceExposingActionList : List<Action<IOnServiceExposingContext>>
{
}

@ -4,7 +4,7 @@ using Microsoft.Extensions.DependencyInjection;
namespace Volo.DependencyInjection
{
public class ServiceRegistrationActionList : List<Action<IOnServiceRegistredArgs>>
public class ServiceRegistrationActionList : List<Action<IOnServiceRegistredContext>>
{
}

@ -20,7 +20,7 @@ namespace Volo.Abp.DynamicProxy
services.AddTransient<SimpleResultCacheTestInterceptor>();
services.AddTransient<CachedTestObject>();
services.OnServiceRegistred(registration =>
services.OnRegistred(registration =>
{
if (typeof(SimpleInterceptionTargetClass) == registration.ImplementationType)
{

Loading…
Cancel
Save