mirror of https://github.com/abpframework/abp.git
1063 changed files with 8541 additions and 57999 deletions
|
After Width: | Height: | Size: 4.9 KiB |
@ -0,0 +1,18 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
using Volo.Abp.AspNetCore.Mvc.UI.Bundling; |
||||
|
using Volo.Abp.AspNetCore.Mvc.UI.Packages.JQuery; |
||||
|
using Volo.Abp.Modularity; |
||||
|
|
||||
|
namespace Volo.Abp.AspNetCore.Mvc.UI.Packages.Anchor |
||||
|
{ |
||||
|
[DependsOn(typeof(JQueryScriptContributor))] |
||||
|
public class AnchorJsScriptBundleContributor : BundleContributor |
||||
|
{ |
||||
|
public override void ConfigureBundle(BundleConfigurationContext context) |
||||
|
{ |
||||
|
context.Files.AddIfNotContains("/libs/anchor-js/anchor.js"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,15 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
using Volo.Abp.AspNetCore.Mvc.UI.Bundling; |
||||
|
|
||||
|
namespace Volo.Abp.AspNetCore.Mvc.UI.Packages.Clipboard |
||||
|
{ |
||||
|
public class ClipboardScriptBundleContributor : BundleContributor |
||||
|
{ |
||||
|
public override void ConfigureBundle(BundleConfigurationContext context) |
||||
|
{ |
||||
|
context.Files.AddIfNotContains("/libs/clipboard/clipboard.js"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,15 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
using Volo.Abp.AspNetCore.Mvc.UI.Bundling; |
||||
|
|
||||
|
namespace Volo.Abp.AspNetCore.Mvc.UI.Packages.MalihuCustomScrollbar |
||||
|
{ |
||||
|
public class MalihuCustomScrollbarPluginScriptBundleContributor : BundleContributor |
||||
|
{ |
||||
|
public override void ConfigureBundle(BundleConfigurationContext context) |
||||
|
{ |
||||
|
context.Files.AddIfNotContains("/libs/malihu-custom-scrollbar-plugin/jquery.mCustomScrollbar.concat.min.js"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,15 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
using Volo.Abp.AspNetCore.Mvc.UI.Bundling; |
||||
|
|
||||
|
namespace Volo.Abp.AspNetCore.Mvc.UI.Packages.MalihuCustomScrollbar |
||||
|
{ |
||||
|
public class MalihuCustomScrollbarPluginStyleBundleContributor : BundleContributor |
||||
|
{ |
||||
|
public override void ConfigureBundle(BundleConfigurationContext context) |
||||
|
{ |
||||
|
context.Files.AddIfNotContains("/libs/malihu-custom-scrollbar-plugin/jquery.mCustomScrollbar.css"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,15 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
using Volo.Abp.AspNetCore.Mvc.UI.Bundling; |
||||
|
|
||||
|
namespace Volo.Abp.AspNetCore.Mvc.UI.Packages.Popper |
||||
|
{ |
||||
|
public class PopperJsScriptBundleContributor : BundleContributor |
||||
|
{ |
||||
|
public override void ConfigureBundle(BundleConfigurationContext context) |
||||
|
{ |
||||
|
context.Files.AddIfNotContains("/libs/popper.js/popper.min.js"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,53 @@ |
|||||
|
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,23 +1,32 @@ |
|||||
using Microsoft.Extensions.Options; |
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Microsoft.Extensions.Options; |
||||
|
|
||||
namespace Volo.Abp.BackgroundJobs.Hangfire |
namespace Volo.Abp.BackgroundJobs.Hangfire |
||||
{ |
{ |
||||
public class HangfireJobExecutionAdapter<TArgs> |
public class HangfireJobExecutionAdapter<TArgs> |
||||
{ |
{ |
||||
protected BackgroundJobOptions Options { get; } |
protected BackgroundJobOptions Options { get; } |
||||
|
protected IServiceScopeFactory ServiceScopeFactory { get; } |
||||
protected IBackgroundJobExecuter JobExecuter { get; } |
protected IBackgroundJobExecuter JobExecuter { get; } |
||||
|
|
||||
public HangfireJobExecutionAdapter(IOptions<BackgroundJobOptions> options, IBackgroundJobExecuter jobExecuter) |
public HangfireJobExecutionAdapter( |
||||
|
IOptions<BackgroundJobOptions> options, |
||||
|
IBackgroundJobExecuter jobExecuter, |
||||
|
IServiceScopeFactory serviceScopeFactory) |
||||
{ |
{ |
||||
JobExecuter = jobExecuter; |
JobExecuter = jobExecuter; |
||||
|
ServiceScopeFactory = serviceScopeFactory; |
||||
Options = options.Value; |
Options = options.Value; |
||||
} |
} |
||||
|
|
||||
public void Execute(TArgs args) |
public void Execute(TArgs args) |
||||
{ |
{ |
||||
var jobType = Options.GetJob(typeof(TArgs)).JobType; |
using (var scope = ServiceScopeFactory.CreateScope()) |
||||
var context = new JobExecutionContext(jobType, args); |
{ |
||||
JobExecuter.Execute(context); |
var jobType = Options.GetJob(typeof(TArgs)).JobType; |
||||
|
var context = new JobExecutionContext(scope.ServiceProvider, jobType, args); |
||||
|
JobExecuter.Execute(context); |
||||
|
} |
||||
} |
} |
||||
} |
} |
||||
} |
} |
||||
|
|||||
@ -0,0 +1,23 @@ |
|||||
|
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(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,9 @@ |
|||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
|
||||
|
namespace Volo.Abp.DependencyInjection |
||||
|
{ |
||||
|
public interface IHybridServiceScopeFactory : IServiceScopeFactory |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
} |
||||
@ -1,7 +1,16 @@ |
|||||
namespace Volo.Abp.EventBus.Distributed |
using System; |
||||
|
|
||||
|
namespace Volo.Abp.EventBus.Distributed |
||||
{ |
{ |
||||
public interface IDistributedEventBus : IEventBus |
public interface IDistributedEventBus : IEventBus |
||||
{ |
{ |
||||
|
/// <summary>
|
||||
|
/// Registers to an event.
|
||||
|
/// Same (given) instance of the handler is used for all event occurrences.
|
||||
|
/// </summary>
|
||||
|
/// <typeparam name="TEvent">Event type</typeparam>
|
||||
|
/// <param name="handler">Object to handle the event</param>
|
||||
|
IDisposable Subscribe<TEvent>(IDistributedEventHandler<TEvent> handler) |
||||
|
where TEvent : class; |
||||
} |
} |
||||
} |
} |
||||
|
|||||
@ -1,7 +1,119 @@ |
|||||
|
using System; |
||||
|
using System.Threading.Tasks; |
||||
|
|
||||
namespace Volo.Abp.EventBus |
namespace Volo.Abp.EventBus |
||||
{ |
{ |
||||
public interface IEventBus : IEventSubscriber, IEventPublisher |
public interface IEventBus |
||||
{ |
{ |
||||
|
/// <summary>
|
||||
|
/// Triggers an event asynchronously.
|
||||
|
/// </summary>
|
||||
|
/// <typeparam name="TEvent">Event type</typeparam>
|
||||
|
/// <param name="eventData">Related data for the event</param>
|
||||
|
/// <returns>The task to handle async operation</returns>
|
||||
|
Task PublishAsync<TEvent>(TEvent eventData) |
||||
|
where TEvent : class; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Triggers an event asynchronously.
|
||||
|
/// </summary>
|
||||
|
/// <param name="eventType">Event type</param>
|
||||
|
/// <param name="eventData">Related data for the event</param>
|
||||
|
/// <returns>The task to handle async operation</returns>
|
||||
|
Task PublishAsync(Type eventType, object eventData); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Registers to an event.
|
||||
|
/// Given action is called for all event occurrences.
|
||||
|
/// </summary>
|
||||
|
/// <param name="action">Action to handle events</param>
|
||||
|
/// <typeparam name="TEvent">Event type</typeparam>
|
||||
|
IDisposable Subscribe<TEvent>(Func<TEvent, Task> action) |
||||
|
where TEvent : class; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Registers to an event.
|
||||
|
/// A new instance of <see cref="THandler"/> object is created for every event occurrence.
|
||||
|
/// </summary>
|
||||
|
/// <typeparam name="TEvent">Event type</typeparam>
|
||||
|
/// <typeparam name="THandler">Type of the event handler</typeparam>
|
||||
|
IDisposable Subscribe<TEvent, THandler>() |
||||
|
where TEvent : class |
||||
|
where THandler : IEventHandler, new(); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Registers to an event.
|
||||
|
/// Same (given) instance of the handler is used for all event occurrences.
|
||||
|
/// </summary>
|
||||
|
/// <param name="eventType">Event type</param>
|
||||
|
/// <param name="handler">Object to handle the event</param>
|
||||
|
IDisposable Subscribe(Type eventType, IEventHandler handler); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Registers to an event.
|
||||
|
/// Given factory is used to create/release handlers
|
||||
|
/// </summary>
|
||||
|
/// <typeparam name="TEvent">Event type</typeparam>
|
||||
|
/// <param name="factory">A factory to create/release handlers</param>
|
||||
|
IDisposable Subscribe<TEvent>(IEventHandlerFactory factory) |
||||
|
where TEvent : class; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Registers to an event.
|
||||
|
/// </summary>
|
||||
|
/// <param name="eventType">Event type</param>
|
||||
|
/// <param name="factory">A factory to create/release handlers</param>
|
||||
|
IDisposable Subscribe(Type eventType, IEventHandlerFactory factory); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Unregisters from an event.
|
||||
|
/// </summary>
|
||||
|
/// <typeparam name="TEvent">Event type</typeparam>
|
||||
|
/// <param name="action"></param>
|
||||
|
void Unsubscribe<TEvent>(Func<TEvent, Task> action) |
||||
|
where TEvent : class; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Unregisters from an event.
|
||||
|
/// </summary>
|
||||
|
/// <typeparam name="TEvent">Event type</typeparam>
|
||||
|
/// <param name="handler">Handler object that is registered before</param>
|
||||
|
void Unsubscribe<TEvent>(ILocalEventHandler<TEvent> handler) |
||||
|
where TEvent : class; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Unregisters from an event.
|
||||
|
/// </summary>
|
||||
|
/// <param name="eventType">Event type</param>
|
||||
|
/// <param name="handler">Handler object that is registered before</param>
|
||||
|
void Unsubscribe(Type eventType, IEventHandler handler); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Unregisters from an event.
|
||||
|
/// </summary>
|
||||
|
/// <typeparam name="TEvent">Event type</typeparam>
|
||||
|
/// <param name="factory">Factory object that is registered before</param>
|
||||
|
void Unsubscribe<TEvent>(IEventHandlerFactory factory) |
||||
|
where TEvent : class; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Unregisters from an event.
|
||||
|
/// </summary>
|
||||
|
/// <param name="eventType">Event type</param>
|
||||
|
/// <param name="factory">Factory object that is registered before</param>
|
||||
|
void Unsubscribe(Type eventType, IEventHandlerFactory factory); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Unregisters all event handlers of given event type.
|
||||
|
/// </summary>
|
||||
|
/// <typeparam name="TEvent">Event type</typeparam>
|
||||
|
void UnsubscribeAll<TEvent>() |
||||
|
where TEvent : class; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Unregisters all event handlers of given event type.
|
||||
|
/// </summary>
|
||||
|
/// <param name="eventType">Event type</param>
|
||||
|
void UnsubscribeAll(Type eventType); |
||||
} |
} |
||||
} |
} |
||||
@ -1,26 +1,13 @@ |
|||||
using System.Threading.Tasks; |
using Volo.Abp.EventBus.Distributed; |
||||
|
|
||||
namespace Volo.Abp.EventBus |
namespace Volo.Abp.EventBus |
||||
{ |
{ |
||||
/// <summary>
|
/// <summary>
|
||||
/// Undirect base interface for all event handlers.
|
/// Undirect base interface for all event handlers.
|
||||
/// Implement <see cref="IEventHandler{TEvent}"/> instead of this one.
|
/// Implement <see cref="ILocalEventHandler{TEvent}"/> or <see cref="IDistributedEventHandler{TEvent}"/> instead of this one.
|
||||
/// </summary>
|
/// </summary>
|
||||
public interface IEventHandler |
public interface IEventHandler |
||||
{ |
{ |
||||
|
|
||||
} |
} |
||||
|
|
||||
/// <summary>
|
|
||||
/// Defines an interface of a class that handles events asynchrounously of type <see cref="IEventHandler{TEvent}"/>.
|
|
||||
/// </summary>
|
|
||||
/// <typeparam name="TEvent">Event type to handle</typeparam>
|
|
||||
public interface IEventHandler<in TEvent> : IEventHandler |
|
||||
{ |
|
||||
/// <summary>
|
|
||||
/// Handler handles the event by implementing this method.
|
|
||||
/// </summary>
|
|
||||
/// <param name="eventData">Event data</param>
|
|
||||
Task HandleEventAsync(TEvent eventData); |
|
||||
} |
|
||||
} |
} |
||||
@ -1,25 +0,0 @@ |
|||||
using System; |
|
||||
using System.Threading.Tasks; |
|
||||
|
|
||||
namespace Volo.Abp.EventBus |
|
||||
{ |
|
||||
public interface IEventPublisher |
|
||||
{ |
|
||||
/// <summary>
|
|
||||
/// Triggers an event asynchronously.
|
|
||||
/// </summary>
|
|
||||
/// <typeparam name="TEvent">Event type</typeparam>
|
|
||||
/// <param name="eventData">Related data for the event</param>
|
|
||||
/// <returns>The task to handle async operation</returns>
|
|
||||
Task PublishAsync<TEvent>(TEvent eventData) |
|
||||
where TEvent : class; |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// Triggers an event asynchronously.
|
|
||||
/// </summary>
|
|
||||
/// <param name="eventType">Event type</param>
|
|
||||
/// <param name="eventData">Related data for the event</param>
|
|
||||
/// <returns>The task to handle async operation</returns>
|
|
||||
Task PublishAsync(Type eventType, object eventData); |
|
||||
} |
|
||||
} |
|
||||
@ -1,111 +0,0 @@ |
|||||
using System; |
|
||||
using System.Threading.Tasks; |
|
||||
|
|
||||
namespace Volo.Abp.EventBus |
|
||||
{ |
|
||||
public interface IEventSubscriber |
|
||||
{ |
|
||||
/// <summary>
|
|
||||
/// Registers to an event.
|
|
||||
/// Given action is called for all event occurrences.
|
|
||||
/// </summary>
|
|
||||
/// <param name="action">Action to handle events</param>
|
|
||||
/// <typeparam name="TEvent">Event type</typeparam>
|
|
||||
IDisposable Subscribe<TEvent>(Func<TEvent, Task> action) |
|
||||
where TEvent : class; |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// Registers to an event.
|
|
||||
/// Same (given) instance of the handler is used for all event occurrences.
|
|
||||
/// </summary>
|
|
||||
/// <typeparam name="TEvent">Event type</typeparam>
|
|
||||
/// <param name="handler">Object to handle the event</param>
|
|
||||
IDisposable Subscribe<TEvent>(IEventHandler<TEvent> handler) |
|
||||
where TEvent : class; |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// Registers to an event.
|
|
||||
/// A new instance of <see cref="THandler"/> object is created for every event occurrence.
|
|
||||
/// </summary>
|
|
||||
/// <typeparam name="TEvent">Event type</typeparam>
|
|
||||
/// <typeparam name="THandler">Type of the event handler</typeparam>
|
|
||||
IDisposable Subscribe<TEvent, THandler>() |
|
||||
where TEvent : class |
|
||||
where THandler : IEventHandler, new(); |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// Registers to an event.
|
|
||||
/// Same (given) instance of the handler is used for all event occurrences.
|
|
||||
/// </summary>
|
|
||||
/// <param name="eventType">Event type</param>
|
|
||||
/// <param name="handler">Object to handle the event</param>
|
|
||||
IDisposable Subscribe(Type eventType, IEventHandler handler); |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// Registers to an event.
|
|
||||
/// Given factory is used to create/release handlers
|
|
||||
/// </summary>
|
|
||||
/// <typeparam name="TEvent">Event type</typeparam>
|
|
||||
/// <param name="factory">A factory to create/release handlers</param>
|
|
||||
IDisposable Subscribe<TEvent>(IEventHandlerFactory factory) |
|
||||
where TEvent : class; |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// Registers to an event.
|
|
||||
/// </summary>
|
|
||||
/// <param name="eventType">Event type</param>
|
|
||||
/// <param name="factory">A factory to create/release handlers</param>
|
|
||||
IDisposable Subscribe(Type eventType, IEventHandlerFactory factory); |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// Unregisters from an event.
|
|
||||
/// </summary>
|
|
||||
/// <typeparam name="TEvent">Event type</typeparam>
|
|
||||
/// <param name="action"></param>
|
|
||||
void Unsubscribe<TEvent>(Func<TEvent, Task> action) |
|
||||
where TEvent : class; |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// Unregisters from an event.
|
|
||||
/// </summary>
|
|
||||
/// <typeparam name="TEvent">Event type</typeparam>
|
|
||||
/// <param name="handler">Handler object that is registered before</param>
|
|
||||
void Unsubscribe<TEvent>(IEventHandler<TEvent> handler) |
|
||||
where TEvent : class; |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// Unregisters from an event.
|
|
||||
/// </summary>
|
|
||||
/// <param name="eventType">Event type</param>
|
|
||||
/// <param name="handler">Handler object that is registered before</param>
|
|
||||
void Unsubscribe(Type eventType, IEventHandler handler); |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// Unregisters from an event.
|
|
||||
/// </summary>
|
|
||||
/// <typeparam name="TEvent">Event type</typeparam>
|
|
||||
/// <param name="factory">Factory object that is registered before</param>
|
|
||||
void Unsubscribe<TEvent>(IEventHandlerFactory factory) |
|
||||
where TEvent : class; |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// Unregisters from an event.
|
|
||||
/// </summary>
|
|
||||
/// <param name="eventType">Event type</param>
|
|
||||
/// <param name="factory">Factory object that is registered before</param>
|
|
||||
void Unsubscribe(Type eventType, IEventHandlerFactory factory); |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// Unregisters all event handlers of given event type.
|
|
||||
/// </summary>
|
|
||||
/// <typeparam name="TEvent">Event type</typeparam>
|
|
||||
void UnsubscribeAll<TEvent>() |
|
||||
where TEvent : class; |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// Unregisters all event handlers of given event type.
|
|
||||
/// </summary>
|
|
||||
/// <param name="eventType">Event type</param>
|
|
||||
void UnsubscribeAll(Type eventType); |
|
||||
} |
|
||||
} |
|
||||
@ -0,0 +1,13 @@ |
|||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace Volo.Abp.EventBus |
||||
|
{ |
||||
|
public interface ILocalEventHandler<in TEvent> : IEventHandler |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Handler handles the event by implementing this method.
|
||||
|
/// </summary>
|
||||
|
/// <param name="eventData">Event data</param>
|
||||
|
Task HandleEventAsync(TEvent eventData); |
||||
|
} |
||||
|
} |
||||
@ -1,13 +1,9 @@ |
|||||
using Microsoft.Extensions.DependencyInjection; |
using Volo.Abp.Modularity; |
||||
using Volo.Abp.Modularity; |
|
||||
|
|
||||
namespace Volo.Abp |
namespace Volo.Abp |
||||
{ |
{ |
||||
public class AbpTestBaseModule : AbpModule |
public class AbpTestBaseModule : AbpModule |
||||
{ |
{ |
||||
public override void ConfigureServices(ServiceConfigurationContext context) |
|
||||
{ |
|
||||
|
|
||||
} |
|
||||
} |
} |
||||
} |
} |
||||
|
|||||
@ -0,0 +1,13 @@ |
|||||
|
namespace Volo.Abp.Testing.Utils |
||||
|
{ |
||||
|
public interface ITestCounter |
||||
|
{ |
||||
|
int Add(string name, int count); |
||||
|
|
||||
|
int Decrement(string name); |
||||
|
|
||||
|
int Increment(string name); |
||||
|
|
||||
|
int GetValue(string name); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,43 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
|
||||
|
namespace Volo.Abp.Testing.Utils |
||||
|
{ |
||||
|
public class TestCounter : ITestCounter, ISingletonDependency |
||||
|
{ |
||||
|
private readonly Dictionary<string, int> _values; |
||||
|
|
||||
|
public TestCounter() |
||||
|
{ |
||||
|
_values = new Dictionary<string, int>(); |
||||
|
} |
||||
|
|
||||
|
public int Increment(string name) |
||||
|
{ |
||||
|
return Add(name, 1); |
||||
|
} |
||||
|
|
||||
|
public int Decrement(string name) |
||||
|
{ |
||||
|
return Add(name, -1); |
||||
|
} |
||||
|
|
||||
|
public int Add(string name, int count) |
||||
|
{ |
||||
|
lock (_values) |
||||
|
{ |
||||
|
var newValue = _values.GetOrDefault(name) + count; |
||||
|
_values[name] = newValue; |
||||
|
return newValue; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public int GetValue(string name) |
||||
|
{ |
||||
|
lock (_values) |
||||
|
{ |
||||
|
return _values.GetOrDefault(name); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1,6 +1,7 @@ |
|||||
{ |
{ |
||||
"culture": "en", |
"culture": "en", |
||||
"texts": { |
"texts": { |
||||
"BirthDate": "Birth date" |
"BirthDate": "Birth date", |
||||
|
"Value1": "Value One" |
||||
} |
} |
||||
} |
} |
||||
@ -1,6 +1,7 @@ |
|||||
{ |
{ |
||||
"culture": "tr", |
"culture": "tr", |
||||
"texts": { |
"texts": { |
||||
"BirthDate": "Dogum gunu" |
"BirthDate": "Dogum gunu", |
||||
|
"Value1": "Değer Bir" |
||||
} |
} |
||||
} |
} |
||||
@ -1,3 +1,3 @@ |
|||||
{ |
{ |
||||
|
"app_offline.htm": {} |
||||
} |
} |
||||
@ -0,0 +1,41 @@ |
|||||
|
using System; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Shouldly; |
||||
|
using Volo.Abp.Modularity; |
||||
|
using Xunit; |
||||
|
|
||||
|
namespace Volo.Abp.DependencyInjection |
||||
|
{ |
||||
|
public class HybridServiceScopeFactory_Tests |
||||
|
{ |
||||
|
[Fact] |
||||
|
public void Should_Use_Default_ServiceScopeFactory_By_Default() |
||||
|
{ |
||||
|
using (var application = AbpApplicationFactory.Create<IndependentEmptyModule>()) |
||||
|
{ |
||||
|
application.Services.AddType(typeof(MyService)); |
||||
|
|
||||
|
application.Initialize(); |
||||
|
|
||||
|
var serviceScopeFactory = application.ServiceProvider.GetRequiredService<IHybridServiceScopeFactory>(); |
||||
|
|
||||
|
using (var scope = serviceScopeFactory.CreateScope()) |
||||
|
{ |
||||
|
scope.ServiceProvider.GetRequiredService<MyService>(); |
||||
|
} |
||||
|
|
||||
|
MyService.DisposeCount.ShouldBe(1); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private class MyService : ITransientDependency, IDisposable |
||||
|
{ |
||||
|
public static int DisposeCount { get; private set; } |
||||
|
|
||||
|
public void Dispose() |
||||
|
{ |
||||
|
++DisposeCount; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,15 @@ |
|||||
|
using Shouldly; |
||||
|
using Xunit; |
||||
|
|
||||
|
namespace Volo.Abp.IO |
||||
|
{ |
||||
|
public class FileHelper_Tests |
||||
|
{ |
||||
|
[Fact] |
||||
|
public void GetExtension() |
||||
|
{ |
||||
|
FileHelper.GetExtension("test").ShouldBeNull(); |
||||
|
FileHelper.GetExtension("te.st").ShouldBe("st"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,9 @@ |
|||||
|
using Volo.Abp.TestApp.Testing; |
||||
|
|
||||
|
namespace Volo.Abp.EntityFrameworkCore.Uow |
||||
|
{ |
||||
|
public class Uow_Completed_Tests : Uow_Completed_Tests<AbpEntityFrameworkCoreTestModule> |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
} |
||||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue