mirror of https://github.com/abpframework/abp.git
17 changed files with 322 additions and 9 deletions
@ -0,0 +1,23 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>netstandard1.6</TargetFramework> |
|||
<AssemblyName>Volo.Abp.Castle.Core</AssemblyName> |
|||
<PackageId>Volo.Abp.Castle.Core</PackageId> |
|||
<NetStandardImplicitPackageVersion>1.6.1</NetStandardImplicitPackageVersion> |
|||
<PackageTargetFallback>$(PackageTargetFallback);dnxcore50</PackageTargetFallback> |
|||
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute> |
|||
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute> |
|||
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute> |
|||
<RootNamespace /> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Castle.Core" Version="4.0.0" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\Volo.Abp\Volo.Abp.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,20 @@ |
|||
using Castle.DynamicProxy; |
|||
using Volo.Abp.DynamicProxy; |
|||
|
|||
namespace Volo.Abp.Castle.DynamicProxy |
|||
{ |
|||
public class CastleAbpInterceptorAdapter : IInterceptor |
|||
{ |
|||
private readonly IAbpInterceptor _abpInterceptor; |
|||
|
|||
public CastleAbpInterceptorAdapter(IAbpInterceptor abpInterceptor) |
|||
{ |
|||
_abpInterceptor = abpInterceptor; |
|||
} |
|||
|
|||
public void Intercept(IInvocation invocation) |
|||
{ |
|||
_abpInterceptor.Intercept(new CastleAbpMethodInvocationAdapter(invocation)); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,36 @@ |
|||
using System; |
|||
using System.Reflection; |
|||
using Castle.DynamicProxy; |
|||
using Volo.Abp.DynamicProxy; |
|||
|
|||
namespace Volo.Abp.Castle.DynamicProxy |
|||
{ |
|||
public class CastleAbpMethodInvocationAdapter : IAbpMethodInvocation |
|||
{ |
|||
public object[] Arguments => _invocation.Arguments; |
|||
|
|||
public Type[] GenericArguments => _invocation.GenericArguments; |
|||
|
|||
public object TargetObject => _invocation.InvocationTarget; |
|||
|
|||
public MethodInfo Method => _invocation.MethodInvocationTarget; |
|||
|
|||
public object ReturnValue |
|||
{ |
|||
get => _invocation.ReturnValue; |
|||
set => _invocation.ReturnValue = value; |
|||
} |
|||
|
|||
private readonly IInvocation _invocation; |
|||
|
|||
public CastleAbpMethodInvocationAdapter(IInvocation invocation) |
|||
{ |
|||
_invocation = invocation; |
|||
} |
|||
|
|||
public void Proceed() |
|||
{ |
|||
_invocation.Proceed(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,13 @@ |
|||
using System; |
|||
using Volo.Abp.Collections; |
|||
using Volo.Abp.DynamicProxy; |
|||
|
|||
namespace Microsoft.Extensions.DependencyInjection |
|||
{ |
|||
public interface IOnServiceRegistredArgs |
|||
{ |
|||
ITypeList<IAbpInterceptor> Interceptors { get; } |
|||
|
|||
Type ImplementationType { get; } |
|||
} |
|||
} |
|||
@ -0,0 +1,21 @@ |
|||
using System; |
|||
using Volo; |
|||
using Volo.Abp.Collections; |
|||
using Volo.Abp.DynamicProxy; |
|||
|
|||
namespace Microsoft.Extensions.DependencyInjection |
|||
{ |
|||
public class OnServiceRegistredArgs : IOnServiceRegistredArgs |
|||
{ |
|||
public virtual ITypeList<IAbpInterceptor> Interceptors { get; } |
|||
|
|||
public virtual Type ImplementationType { get; } |
|||
|
|||
public OnServiceRegistredArgs(Type implementationType) |
|||
{ |
|||
ImplementationType = Check.NotNull(implementationType, nameof(implementationType)); |
|||
|
|||
Interceptors = new TypeList<IAbpInterceptor>(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,30 @@ |
|||
using System; |
|||
using Volo.DependencyInjection; |
|||
|
|||
namespace Microsoft.Extensions.DependencyInjection |
|||
{ |
|||
public static class ServiceCollectionRegistrationActionExtensions |
|||
{ |
|||
public static void OnServiceRegistred(this IServiceCollection services, Action<IOnServiceRegistredArgs> registrationAction) |
|||
{ |
|||
GetOrCreateServiceActionList(services).Add(registrationAction); |
|||
} |
|||
|
|||
public static ServiceRegistrationActionList GetServiceRegistrationActionList(this IServiceCollection services) |
|||
{ |
|||
return GetOrCreateServiceActionList(services); |
|||
} |
|||
|
|||
private static ServiceRegistrationActionList GetOrCreateServiceActionList(IServiceCollection services) |
|||
{ |
|||
var registrationActionList = services.GetSingletonInstanceOrNull<IObjectAccessor<ServiceRegistrationActionList>>()?.Value; |
|||
if (registrationActionList == null) |
|||
{ |
|||
registrationActionList = new ServiceRegistrationActionList(); |
|||
services.AddObjectAccessor(registrationActionList); |
|||
} |
|||
|
|||
return registrationActionList; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,13 @@ |
|||
using Volo.Abp.DynamicProxy; |
|||
using Volo.DependencyInjection; |
|||
|
|||
namespace Volo.Abp.Uow |
|||
{ |
|||
public class UnitOfWorkInterceptor : IAbpInterceptor, ITransientDependency |
|||
{ |
|||
public void Intercept(IAbpMethodInvocation invocation) |
|||
{ |
|||
invocation.Proceed(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
|
|||
namespace Volo.DependencyInjection |
|||
{ |
|||
public class ServiceRegistrationActionList : List<Action<IOnServiceRegistredArgs>> |
|||
{ |
|||
|
|||
} |
|||
} |
|||
Loading…
Reference in new issue