mirror of https://github.com/EasyAbp/EShop.git
10 changed files with 199 additions and 118 deletions
@ -1,10 +0,0 @@ |
|||||
using System.Threading.Tasks; |
|
||||
using Dapr.Actors; |
|
||||
using EasyAbp.EShop.Plugins.Inventories.DaprActors; |
|
||||
|
|
||||
namespace EasyAbp.EShop.Products.DaprActorsInventory; |
|
||||
|
|
||||
public interface IInventoryActorProvider |
|
||||
{ |
|
||||
Task<IInventoryActor> GetAsync(ActorId actorId); |
|
||||
} |
|
||||
@ -1,17 +0,0 @@ |
|||||
using System.Threading.Tasks; |
|
||||
using Dapr.Actors; |
|
||||
using Dapr.Actors.Client; |
|
||||
using EasyAbp.EShop.Plugins.Inventories.DaprActors; |
|
||||
using Volo.Abp.DependencyInjection; |
|
||||
|
|
||||
namespace EasyAbp.EShop.Products.DaprActorsInventory; |
|
||||
|
|
||||
public class InventoryActorProvider : IInventoryActorProvider, ITransientDependency |
|
||||
{ |
|
||||
public static string ActorType { get; set; } = "InventoryActor"; |
|
||||
|
|
||||
public virtual Task<IInventoryActor> GetAsync(ActorId actorId) |
|
||||
{ |
|
||||
return Task.FromResult(ActorProxy.Create<IInventoryActor>(actorId, ActorType)); |
|
||||
} |
|
||||
} |
|
||||
@ -0,0 +1,50 @@ |
|||||
|
using System; |
||||
|
using Dapr.Actors; |
||||
|
using Dapr.Actors.Client; |
||||
|
using EasyAbp.EShop.Plugins.Inventories.DaprActors; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
|
||||
|
namespace EasyAbp.EShop.Products.DaprActorsInventory.Domain; |
||||
|
|
||||
|
[Dependency(ReplaceServices = true)] |
||||
|
public class TestActorProxyFactory : IActorProxyFactory, ITransientDependency |
||||
|
{ |
||||
|
private IInventoryActor Actor { get; set; } |
||||
|
|
||||
|
private readonly IServiceProvider _serviceProvider; |
||||
|
|
||||
|
public TestActorProxyFactory(IServiceProvider serviceProvider) |
||||
|
{ |
||||
|
_serviceProvider = serviceProvider; |
||||
|
} |
||||
|
|
||||
|
public TActorInterface CreateActorProxy<TActorInterface>(ActorId actorId, string actorType, |
||||
|
ActorProxyOptions options = null) where TActorInterface : IActor |
||||
|
{ |
||||
|
if (typeof(TActorInterface) != typeof(IInventoryActor)) |
||||
|
{ |
||||
|
throw new ApplicationException(); |
||||
|
} |
||||
|
|
||||
|
if (Actor is not null) |
||||
|
{ |
||||
|
return (TActorInterface)Actor; |
||||
|
} |
||||
|
|
||||
|
Actor = _serviceProvider.GetRequiredService<IInventoryActor>(); |
||||
|
|
||||
|
return (TActorInterface)Actor; |
||||
|
} |
||||
|
|
||||
|
public object CreateActorProxy(ActorId actorId, Type actorInterfaceType, string actorType, |
||||
|
ActorProxyOptions options = null) |
||||
|
{ |
||||
|
throw new NotSupportedException(); |
||||
|
} |
||||
|
|
||||
|
public ActorProxy Create(ActorId actorId, string actorType, ActorProxyOptions options = null) |
||||
|
{ |
||||
|
throw new NotSupportedException(); |
||||
|
} |
||||
|
} |
||||
@ -1,26 +0,0 @@ |
|||||
using System; |
|
||||
using System.Threading.Tasks; |
|
||||
using Dapr.Actors; |
|
||||
using EasyAbp.EShop.Plugins.Inventories.DaprActors; |
|
||||
using Microsoft.Extensions.DependencyInjection; |
|
||||
using Volo.Abp.DependencyInjection; |
|
||||
|
|
||||
namespace EasyAbp.EShop.Products.DaprActorsInventory.Domain; |
|
||||
|
|
||||
[Dependency(ReplaceServices = true)] |
|
||||
public class TestInventoryActorProvider : IInventoryActorProvider, ITransientDependency |
|
||||
{ |
|
||||
private IInventoryActor Actor { get; set; } |
|
||||
|
|
||||
private readonly IServiceProvider _serviceProvider; |
|
||||
|
|
||||
public TestInventoryActorProvider(IServiceProvider serviceProvider) |
|
||||
{ |
|
||||
_serviceProvider = serviceProvider; |
|
||||
} |
|
||||
|
|
||||
public Task<IInventoryActor> GetAsync(ActorId actorId) |
|
||||
{ |
|
||||
return Task.FromResult(Actor ??= _serviceProvider.GetRequiredService<FakeInventoryActor>()); |
|
||||
} |
|
||||
} |
|
||||
@ -1,9 +0,0 @@ |
|||||
using System.Threading.Tasks; |
|
||||
using EasyAbp.EShop.Plugins.Inventories.OrleansGrains; |
|
||||
|
|
||||
namespace EasyAbp.EShop.Products.OrleansGrainsInventory; |
|
||||
|
|
||||
public interface IInventoryGrainProvider |
|
||||
{ |
|
||||
Task<IInventoryGrain> GetAsync(string grainKey); |
|
||||
} |
|
||||
@ -1,21 +0,0 @@ |
|||||
using System.Threading.Tasks; |
|
||||
using EasyAbp.EShop.Plugins.Inventories.OrleansGrains; |
|
||||
using Orleans; |
|
||||
using Volo.Abp.DependencyInjection; |
|
||||
|
|
||||
namespace EasyAbp.EShop.Products.OrleansGrainsInventory; |
|
||||
|
|
||||
public class InventoryGrainProvider : IInventoryGrainProvider, ITransientDependency |
|
||||
{ |
|
||||
private readonly IGrainFactory _grainFactory; |
|
||||
|
|
||||
public InventoryGrainProvider(IGrainFactory grainFactory) |
|
||||
{ |
|
||||
_grainFactory = grainFactory; |
|
||||
} |
|
||||
|
|
||||
public virtual Task<IInventoryGrain> GetAsync(string grainKey) |
|
||||
{ |
|
||||
return Task.FromResult(_grainFactory.GetGrain<IInventoryGrain>(grainKey)); |
|
||||
} |
|
||||
} |
|
||||
@ -0,0 +1,136 @@ |
|||||
|
using System; |
||||
|
using System.Threading.Tasks; |
||||
|
using EasyAbp.EShop.Plugins.Inventories.OrleansGrains; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Orleans; |
||||
|
using Orleans.Runtime; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
|
||||
|
namespace EasyAbp.EShop.Products.OrleansGrainsInventory.Domain; |
||||
|
|
||||
|
[Dependency(ReplaceServices = true)] |
||||
|
public class TestGrainFactory : IGrainFactory, ITransientDependency |
||||
|
{ |
||||
|
private IInventoryGrain Grain { get; set; } |
||||
|
|
||||
|
private readonly IServiceProvider _serviceProvider; |
||||
|
|
||||
|
public TestGrainFactory(IServiceProvider serviceProvider) |
||||
|
{ |
||||
|
_serviceProvider = serviceProvider; |
||||
|
} |
||||
|
|
||||
|
public TGrainInterface GetGrain<TGrainInterface>(Guid primaryKey, string grainClassNamePrefix = null) |
||||
|
where TGrainInterface : IGrainWithGuidKey |
||||
|
{ |
||||
|
throw new NotSupportedException(); |
||||
|
} |
||||
|
|
||||
|
public TGrainInterface GetGrain<TGrainInterface>(long primaryKey, string grainClassNamePrefix = null) |
||||
|
where TGrainInterface : IGrainWithIntegerKey |
||||
|
{ |
||||
|
throw new NotSupportedException(); |
||||
|
} |
||||
|
|
||||
|
public TGrainInterface GetGrain<TGrainInterface>(string primaryKey, string grainClassNamePrefix = null) |
||||
|
where TGrainInterface : IGrainWithStringKey |
||||
|
{ |
||||
|
if (typeof(TGrainInterface) != typeof(IInventoryGrain)) |
||||
|
{ |
||||
|
throw new ApplicationException(); |
||||
|
} |
||||
|
|
||||
|
if (Grain is not null) |
||||
|
{ |
||||
|
return (TGrainInterface)Grain; |
||||
|
} |
||||
|
|
||||
|
Grain = _serviceProvider.GetRequiredService<FakeInventoryGrain>(); |
||||
|
|
||||
|
return (TGrainInterface)Grain; |
||||
|
} |
||||
|
|
||||
|
public TGrainInterface GetGrain<TGrainInterface>(Guid primaryKey, string keyExtension, |
||||
|
string grainClassNamePrefix = null) where TGrainInterface : IGrainWithGuidCompoundKey |
||||
|
{ |
||||
|
throw new NotSupportedException(); |
||||
|
} |
||||
|
|
||||
|
public TGrainInterface GetGrain<TGrainInterface>(long primaryKey, string keyExtension, |
||||
|
string grainClassNamePrefix = null) where TGrainInterface : IGrainWithIntegerCompoundKey |
||||
|
{ |
||||
|
throw new NotSupportedException(); |
||||
|
} |
||||
|
|
||||
|
public async Task<TGrainObserverInterface> CreateObjectReference<TGrainObserverInterface>(IGrainObserver obj) |
||||
|
where TGrainObserverInterface : IGrainObserver |
||||
|
{ |
||||
|
throw new NotSupportedException(); |
||||
|
} |
||||
|
|
||||
|
public async Task DeleteObjectReference<TGrainObserverInterface>(IGrainObserver obj) |
||||
|
where TGrainObserverInterface : IGrainObserver |
||||
|
{ |
||||
|
throw new NotSupportedException(); |
||||
|
} |
||||
|
|
||||
|
public void BindGrainReference(IAddressable grain) |
||||
|
{ |
||||
|
throw new NotSupportedException(); |
||||
|
} |
||||
|
|
||||
|
public TGrainInterface GetGrain<TGrainInterface>(Type grainInterfaceType, Guid grainPrimaryKey) |
||||
|
where TGrainInterface : IGrain |
||||
|
{ |
||||
|
throw new NotSupportedException(); |
||||
|
} |
||||
|
|
||||
|
public TGrainInterface GetGrain<TGrainInterface>(Type grainInterfaceType, long grainPrimaryKey) |
||||
|
where TGrainInterface : IGrain |
||||
|
{ |
||||
|
throw new NotSupportedException(); |
||||
|
} |
||||
|
|
||||
|
public TGrainInterface GetGrain<TGrainInterface>(Type grainInterfaceType, string grainPrimaryKey) |
||||
|
where TGrainInterface : IGrain |
||||
|
{ |
||||
|
throw new NotSupportedException(); |
||||
|
} |
||||
|
|
||||
|
public TGrainInterface GetGrain<TGrainInterface>(Type grainInterfaceType, Guid grainPrimaryKey, string keyExtension) |
||||
|
where TGrainInterface : IGrain |
||||
|
{ |
||||
|
throw new NotSupportedException(); |
||||
|
} |
||||
|
|
||||
|
public TGrainInterface GetGrain<TGrainInterface>(Type grainInterfaceType, long grainPrimaryKey, string keyExtension) |
||||
|
where TGrainInterface : IGrain |
||||
|
{ |
||||
|
throw new NotSupportedException(); |
||||
|
} |
||||
|
|
||||
|
public IGrain GetGrain(Type grainInterfaceType, Guid grainPrimaryKey) |
||||
|
{ |
||||
|
throw new NotSupportedException(); |
||||
|
} |
||||
|
|
||||
|
public IGrain GetGrain(Type grainInterfaceType, long grainPrimaryKey) |
||||
|
{ |
||||
|
throw new NotSupportedException(); |
||||
|
} |
||||
|
|
||||
|
public IGrain GetGrain(Type grainInterfaceType, string grainPrimaryKey) |
||||
|
{ |
||||
|
throw new NotSupportedException(); |
||||
|
} |
||||
|
|
||||
|
public IGrain GetGrain(Type grainInterfaceType, Guid grainPrimaryKey, string keyExtension) |
||||
|
{ |
||||
|
throw new NotSupportedException(); |
||||
|
} |
||||
|
|
||||
|
public IGrain GetGrain(Type grainInterfaceType, long grainPrimaryKey, string keyExtension) |
||||
|
{ |
||||
|
throw new NotSupportedException(); |
||||
|
} |
||||
|
} |
||||
@ -1,25 +0,0 @@ |
|||||
using System; |
|
||||
using System.Threading.Tasks; |
|
||||
using EasyAbp.EShop.Plugins.Inventories.OrleansGrains; |
|
||||
using Microsoft.Extensions.DependencyInjection; |
|
||||
using Volo.Abp.DependencyInjection; |
|
||||
|
|
||||
namespace EasyAbp.EShop.Products.OrleansGrainsInventory.Domain; |
|
||||
|
|
||||
[Dependency(ReplaceServices = true)] |
|
||||
public class TestInventoryGrainProvider : IInventoryGrainProvider, ITransientDependency |
|
||||
{ |
|
||||
private IInventoryGrain Grain { get; set; } |
|
||||
|
|
||||
private readonly IServiceProvider _serviceProvider; |
|
||||
|
|
||||
public TestInventoryGrainProvider(IServiceProvider serviceProvider) |
|
||||
{ |
|
||||
_serviceProvider = serviceProvider; |
|
||||
} |
|
||||
|
|
||||
public Task<IInventoryGrain> GetAsync(string grainKey) |
|
||||
{ |
|
||||
return Task.FromResult(Grain ??= _serviceProvider.GetRequiredService<FakeInventoryGrain>()); |
|
||||
} |
|
||||
} |
|
||||
Loading…
Reference in new issue