mirror of https://github.com/abpframework/abp
commit
71a8e2451d
@ -1,52 +0,0 @@
|
||||
using System;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
|
||||
namespace Volo.Abp.AspNetCore.DependencyInjection;
|
||||
|
||||
[ExposeServices(
|
||||
typeof(IHybridServiceScopeFactory),
|
||||
typeof(HttpContextServiceScopeFactory)
|
||||
)]
|
||||
[Dependency(ReplaceServices = true)]
|
||||
public class HttpContextServiceScopeFactory : IHybridServiceScopeFactory, ITransientDependency
|
||||
{
|
||||
protected IHttpContextAccessor HttpContextAccessor { get; }
|
||||
|
||||
protected IServiceScopeFactory ServiceScopeFactory { get; }
|
||||
|
||||
public HttpContextServiceScopeFactory(
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
IServiceScopeFactory serviceScopeFactory)
|
||||
{
|
||||
HttpContextAccessor = httpContextAccessor;
|
||||
ServiceScopeFactory = serviceScopeFactory;
|
||||
}
|
||||
|
||||
public virtual IServiceScope CreateScope()
|
||||
{
|
||||
var httpContext = HttpContextAccessor.HttpContext;
|
||||
if (httpContext == null)
|
||||
{
|
||||
return ServiceScopeFactory.CreateScope();
|
||||
}
|
||||
|
||||
return new NonDisposedHttpContextServiceScope(httpContext.RequestServices);
|
||||
}
|
||||
|
||||
protected class NonDisposedHttpContextServiceScope : IServiceScope
|
||||
{
|
||||
public IServiceProvider ServiceProvider { get; }
|
||||
|
||||
public NonDisposedHttpContextServiceScope(IServiceProvider serviceProvider)
|
||||
{
|
||||
ServiceProvider = serviceProvider;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,22 +0,0 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Volo.Abp.DependencyInjection;
|
||||
|
||||
[ExposeServices(
|
||||
typeof(IHybridServiceScopeFactory),
|
||||
typeof(DefaultServiceScopeFactory)
|
||||
)]
|
||||
public class DefaultServiceScopeFactory : IHybridServiceScopeFactory, ITransientDependency
|
||||
{
|
||||
protected IServiceScopeFactory Factory { get; }
|
||||
|
||||
public DefaultServiceScopeFactory(IServiceScopeFactory factory)
|
||||
{
|
||||
Factory = factory;
|
||||
}
|
||||
|
||||
public IServiceScope CreateScope()
|
||||
{
|
||||
return Factory.CreateScope();
|
||||
}
|
||||
}
|
||||
@ -1,8 +0,0 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Volo.Abp.DependencyInjection;
|
||||
|
||||
public interface IHybridServiceScopeFactory : IServiceScopeFactory
|
||||
{
|
||||
|
||||
}
|
||||
@ -1,23 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace Volo.Abp.Domain.Entities.Events;
|
||||
|
||||
/// <summary>
|
||||
/// Used to pass data for an event when an entity (<see cref="IEntity"/>) is being changed (creating, updating or deleting).
|
||||
/// See <see cref="EntityCreatingEventData{TEntity}"/>, <see cref="EntityDeletingEventData{TEntity}"/> and <see cref="EntityUpdatingEventData{TEntity}"/> classes.
|
||||
/// </summary>
|
||||
/// <typeparam name="TEntity">Entity type</typeparam>
|
||||
[Serializable]
|
||||
[Obsolete("This event is no longer needed and identical to EntityChangedEventData. Please use EntityChangedEventData instead.")]
|
||||
public class EntityChangingEventData<TEntity> : EntityEventData<TEntity>
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructor.
|
||||
/// </summary>
|
||||
/// <param name="entity">Changing entity in this event</param>
|
||||
public EntityChangingEventData(TEntity entity)
|
||||
: base(entity)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,22 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace Volo.Abp.Domain.Entities.Events;
|
||||
|
||||
/// <summary>
|
||||
/// This type of event is used to notify just before creation of an Entity.
|
||||
/// </summary>
|
||||
/// <typeparam name="TEntity">Entity type</typeparam>
|
||||
[Serializable]
|
||||
[Obsolete("This event is no longer needed and identical to EntityCreatedEventData. Please use EntityCreatedEventData instead.")]
|
||||
public class EntityCreatingEventData<TEntity> : EntityChangingEventData<TEntity>
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructor.
|
||||
/// </summary>
|
||||
/// <param name="entity">The entity which is being created</param>
|
||||
public EntityCreatingEventData(TEntity entity)
|
||||
: base(entity)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,22 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace Volo.Abp.Domain.Entities.Events;
|
||||
|
||||
/// <summary>
|
||||
/// This type of event is used to notify just before deletion of an Entity.
|
||||
/// </summary>
|
||||
/// <typeparam name="TEntity">Entity type</typeparam>
|
||||
[Serializable]
|
||||
[Obsolete("This event is no longer needed and identical to EntityDeletedEventData. Please use EntityDeletedEventData instead.")]
|
||||
public class EntityDeletingEventData<TEntity> : EntityChangingEventData<TEntity>
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructor.
|
||||
/// </summary>
|
||||
/// <param name="entity">The entity which is being deleted</param>
|
||||
public EntityDeletingEventData(TEntity entity)
|
||||
: base(entity)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,22 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace Volo.Abp.Domain.Entities.Events;
|
||||
|
||||
/// <summary>
|
||||
/// This type of event is used to notify just before update of an Entity.
|
||||
/// </summary>
|
||||
/// <typeparam name="TEntity">Entity type</typeparam>
|
||||
[Serializable]
|
||||
[Obsolete("This event is no longer needed and identical to EntityUpdatedEventData. Please use EntityUpdatedEventData instead.")]
|
||||
public class EntityUpdatingEventData<TEntity> : EntityChangingEventData<TEntity>
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructor.
|
||||
/// </summary>
|
||||
/// <param name="entity">The entity which is being updated</param>
|
||||
public EntityUpdatingEventData(TEntity entity)
|
||||
: base(entity)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Reference in new issue