Commit 3d55967b authored by 阿星Plus's avatar 阿星Plus

😭😭😭😭

parent 13f40f08
......@@ -2,6 +2,9 @@
{
public class DefaultSettings : SettingsBase
{
public string DefaultNameOrConnectionString => Config["ConnectionStrings"];
public string GetDefaultNameOrConnectionString()
{
return Config["DefaultNameOrConnectionString"];
}
}
}
\ No newline at end of file
......@@ -17,7 +17,7 @@ namespace Plus.Domain.Uow
public virtual string GetNameOrConnectionString(ConnectionStringResolveArgs args)
{
string defaultNameOrConnectionString = _configuration.DefaultSettings.DefaultNameOrConnectionString;
string defaultNameOrConnectionString = _configuration.DefaultSettings.GetDefaultNameOrConnectionString();
if (!string.IsNullOrWhiteSpace(defaultNameOrConnectionString))
{
return defaultNameOrConnectionString;
......
using Castle.Core.Logging;
using Plus.Dependency;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Plus.Event
{
public class EventPublisher : IEventPublisher, ITransientDependency
{
private readonly ISubscriptionService _subscriptionService;
public ILogger Logger
{
get;
set;
}
public EventPublisher(ISubscriptionService subscriptionService)
{
_subscriptionService = subscriptionService;
Logger = NullLogger.Instance;
}
public virtual void Publish<T>(T eventMessage)
{
IList<IConsumer<T>> subscriptions = _subscriptionService.GetSubscriptions<T>();
subscriptions.ToList().ForEach(delegate (IConsumer<T> x)
{
PublishToConsumer(x, eventMessage);
});
}
protected virtual void PublishToConsumer<T>(IConsumer<T> x, T eventMessage)
{
try
{
x.HandleEvent(eventMessage);
}
catch (Exception ex)
{
try
{
Logger.Error(ex.Message, ex);
}
catch (Exception)
{
}
}
}
}
}
\ No newline at end of file
namespace Plus.Event
{
public interface IConsumer<T>
{
void HandleEvent(T eventMessage);
}
}
\ No newline at end of file
using Plus.Dependency;
namespace Plus.Event
{
public interface IEventPublisher : ITransientDependency
{
void Publish<T>(T eventMessage);
}
}
\ No newline at end of file
using Plus.Dependency;
using System.Collections.Generic;
namespace Plus.Event
{
public interface ISubscriptionService : ITransientDependency
{
IList<IConsumer<T>> GetSubscriptions<T>();
}
}
\ No newline at end of file
using Plus.Dependency;
using System.Collections.Generic;
namespace Plus.Event
{
public class SubscriptionService : ISubscriptionService, ITransientDependency
{
public IList<IConsumer<T>> GetSubscriptions<T>()
{
return PlusEngine.Instance.IocManager.ResolveAll<IConsumer<T>>();
}
}
}
\ No newline at end of file
......@@ -17,7 +17,7 @@
<PackageLicenseUrl>https://raw.githubusercontent.com/Meowv/.netcoreplus/master/LICENSE</PackageLicenseUrl>
<PackageTags>plus;.netcoreplus;</PackageTags>
<PackageReleaseNotes>Plus</PackageReleaseNotes>
<Version>1.0.1</Version>
<Version>1.0.1.2</Version>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
......
using Castle.Core.Logging;
using Plus.Dependency;
using Plus.Event;
namespace Plus.Services
{
public abstract class ApplicationServiceBase : IApplicationService, ITransientDependency
{
public ILogger Logger
{
protected get;
set;
}
public IEventPublisher EventPublisher
{
protected get;
set;
}
protected ApplicationServiceBase()
{
Logger = NullLogger.Instance;
EventPublisher = PlusEngine.Instance.Resolve<IEventPublisher>();
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment