Refactored. Added IAbpInterceptor.

pull/81/head
Halil İbrahim Kalkan 9 years ago
parent b6eb00da45
commit a3a86faa40

@ -1,19 +1,13 @@
using System;
using Autofac;
using JetBrains.Annotations;
using Microsoft.Extensions.DependencyInjection;
using Volo;
using Volo.Abp;
namespace Volo.Abp
namespace Microsoft.Extensions.DependencyInjection
{
public static class AbpAutofacExtensions
public static class AbpAutofacServiceCollectionExtensions
{
public static void UseAutofac(this AbpApplicationCreationOptions options)
{
var builder = new ContainerBuilder();
options.Services.AddObjectAccessor(builder);
options.Services.AddSingleton((IServiceProviderFactory<ContainerBuilder>) new AbpAutofacServiceProviderFactory(builder));
}
[NotNull]
public static ContainerBuilder GetContainerBuilder([NotNull] this IServiceCollection services)
{
@ -22,7 +16,7 @@ namespace Volo.Abp
var builder = services.GetObjectOrNull<ContainerBuilder>();
if (builder == null)
{
throw new AbpException($"Could not find ContainerBuilder. Be sure that you have called {nameof(UseAutofac)} method before!");
throw new AbpException($"Could not find ContainerBuilder. Be sure that you have called {nameof(AbpAutofacAbpApplicationCreationOptionsExtensions.UseAutofac)} method before!");
}
return builder;
@ -35,7 +29,7 @@ namespace Volo.Abp
var serviceProviderFactory = services.GetSingletonInstanceOrNull<IServiceProviderFactory<ContainerBuilder>>();
if (serviceProviderFactory == null)
{
throw new AbpException($"Could not find {typeof(IServiceProviderFactory<ContainerBuilder>).FullName} in {services}. Use {nameof(UseAutofac)} before!");
throw new AbpException($"Could not find {typeof(IServiceProviderFactory<ContainerBuilder>).FullName} in {services}. Use {nameof(AbpAutofacAbpApplicationCreationOptionsExtensions.UseAutofac)} before!");
}
var builder = serviceProviderFactory.CreateBuilder(services);

@ -0,0 +1,16 @@
using Autofac;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Autofac;
namespace Volo.Abp
{
public static class AbpAutofacAbpApplicationCreationOptionsExtensions
{
public static void UseAutofac(this AbpApplicationCreationOptions options)
{
var builder = new ContainerBuilder();
options.Services.AddObjectAccessor(builder);
options.Services.AddSingleton((IServiceProviderFactory<ContainerBuilder>) new AbpAutofacServiceProviderFactory(builder));
}
}
}

@ -3,7 +3,7 @@ using Autofac;
using Autofac.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
namespace Volo.Abp
namespace Volo.Abp.Autofac
{
/// <summary>
/// A factory for creating a <see cref="T:Autofac.ContainerBuilder" /> and an <see cref="T:System.IServiceProvider" />.

@ -0,0 +1,7 @@
namespace Volo.Abp.DynamicProxy
{
public interface IAbpInterceptor
{
void Intercept(IAbpMethodInvocation invocation);
}
}

@ -0,0 +1,20 @@
using System;
using System.Reflection;
namespace Volo.Abp.DynamicProxy
{
public interface IAbpMethodInvocation
{
object[] Arguments { get; }
Type[] GenericArguments { get; }
object InvocationTarget { get; }
MethodInfo MethodInvocationTarget { get; }
object ReturnValue { get; set; }
void Proceed();
}
}
Loading…
Cancel
Save