diff --git a/src/ServiceAnt.IocInstaller.Autofac/IocResolver.cs b/src/ServiceAnt.IocInstaller.Autofac/IocResolver.cs
index ba3fa19..5d430f2 100644
--- a/src/ServiceAnt.IocInstaller.Autofac/IocResolver.cs
+++ b/src/ServiceAnt.IocInstaller.Autofac/IocResolver.cs
@@ -15,6 +15,10 @@ public class IocResolver : IIocResolver
{
private readonly IComponentContext _componentContext;
+ ///
+ /// Constructor
+ ///
+ ///
public IocResolver(IComponentContext componentContext)
{
_componentContext = componentContext;
diff --git a/src/ServiceAnt.IocInstaller.Autofac/ServiceAntModule.cs b/src/ServiceAnt.IocInstaller.Autofac/ServiceAntModule.cs
index 65d1f96..184d700 100644
--- a/src/ServiceAnt.IocInstaller.Autofac/ServiceAntModule.cs
+++ b/src/ServiceAnt.IocInstaller.Autofac/ServiceAntModule.cs
@@ -44,6 +44,10 @@ public static void RegisterHandlers(IComponentContext container)
}
}
+ ///
+ /// Intall dependenies and register handler function
+ ///
+ ///
protected override void Load(ContainerBuilder builder)
{
var serviceBus = InProcessServiceBus.Default;
diff --git a/src/ServiceAnt.IocInstaller.Castle/ServiceAntInstaller.cs b/src/ServiceAnt.IocInstaller.Castle/ServiceAntInstaller.cs
index 0b67229..25aa493 100644
--- a/src/ServiceAnt.IocInstaller.Castle/ServiceAntInstaller.cs
+++ b/src/ServiceAnt.IocInstaller.Castle/ServiceAntInstaller.cs
@@ -32,6 +32,11 @@ public ServiceAntInstaller(params Assembly[] handlerAssemblies)
_handlerAssemblies = handlerAssemblies;
}
+ ///
+ /// Intall dependenies and register handler function
+ ///
+ ///
+ ///
public void Install(IWindsorContainer container, IConfigurationStore store)
{
_container = container;
diff --git a/src/ServiceAnt/IServiceBus.cs b/src/ServiceAnt/IServiceBus.cs
index 8a9e1a5..6ba5c65 100644
--- a/src/ServiceAnt/IServiceBus.cs
+++ b/src/ServiceAnt/IServiceBus.cs
@@ -6,6 +6,9 @@
namespace ServiceAnt
{
+ ///
+ /// It used to publish event or send a request
+ ///
public interface IServiceBus : IAddSubscription, IAddRequestHandler
{
///
diff --git a/src/ServiceAnt/InProcessServiceBus.cs b/src/ServiceAnt/InProcessServiceBus.cs
index 998ef5d..bf8e6f5 100644
--- a/src/ServiceAnt/InProcessServiceBus.cs
+++ b/src/ServiceAnt/InProcessServiceBus.cs
@@ -11,22 +11,40 @@
namespace ServiceAnt
{
+ ///
+ /// The implement that work in-process
+ ///
public class InProcessServiceBus : IServiceBus
{
private ISubscriptionManager _subcriptionManager;
private IRequestHandlerManager _requestHandlerManager;
+ ///
+ /// Use to log message of bus
+ ///
public event Action OnLogBusMessage;
private static Lazy _defaultInstance = new Lazy();
+
+ ///
+ /// Default Instance
+ ///
public static InProcessServiceBus Default => _defaultInstance.Value;
+ ///
+ /// Constructor
+ ///
public InProcessServiceBus()
{
_subcriptionManager = new InMemorySubscriptionsManager();
_requestHandlerManager = new InMemoryRequestHandlerManager();
}
+ ///
+ /// It used to inject mock object
+ ///
+ ///
+ ///
public InProcessServiceBus(ISubscriptionManager subcriptionManager, IRequestHandlerManager requestHandlerManager)
{
_subcriptionManager = subcriptionManager;
@@ -35,37 +53,72 @@ public InProcessServiceBus(ISubscriptionManager subcriptionManager, IRequestHand
#region Pub/Sub
+ ///
+ /// Add Subscription for event by delegate with dynamic parameter
+ ///
+ /// the name of event(the class name of event type)
+ /// Handler delegate
public void AddDynamicSubscription(string eventName, Func action)
{
_subcriptionManager.AddDynamicSubscription(eventName, action);
}
-
+ ///
+ /// Add Subscription for event by factory
+ ///
+ /// The type of event must inherit TransportTray
+ /// The factory of handler
public void AddSubscription(Type eventType, IHandlerFactory factory)
{
_subcriptionManager.AddSubscription(eventType, factory);
}
+ ///
+ /// Add Subscription for event by delegate
+ ///
+ /// The event must inherit TransportTray
+ /// Handler delegate
public void AddSubscription(Func action) where TEvent : TransportTray
{
_subcriptionManager.AddSubscription(action);
}
+ ///
+ /// Add Subscription for event by factory
+ ///
+ /// The event must inherit TransportTray
+ /// s
public void AddSubscription(IHandlerFactory factory) where TEvent : TransportTray
{
_subcriptionManager.AddSubscription(factory);
}
+
+ ///
+ /// Remove subscription from servicebus
+ ///
+ /// the name of event(the class name of event type)
+ /// Handler delegate
public void RemoveDynamicSubscription(string eventName, Func action)
{
_subcriptionManager.RemoveDynamicSubscription(eventName, action);
}
+ ///
+ /// Remove subscription from servicebus
+ ///
+ /// The event must inherit TransportTray
+ /// Handler delegate
public void RemoveSubscription(Func action) where TEvent : TransportTray
{
_subcriptionManager.RemoveSubscription(action);
}
+ ///
+ /// Publish a event
+ ///
+ ///
+ ///
public Task Publish(TransportTray @event)
{
var asyncTask = ProcessEvent(_subcriptionManager.GetEventName(@event.GetType()), JsonConvert.SerializeObject(@event));
@@ -73,7 +126,7 @@ public Task Publish(TransportTray @event)
}
///
- /// It's for Unit test
+ /// Publish a event sync
///
///
public void PublishSync(TransportTray @event)
@@ -115,43 +168,79 @@ private async Task ProcessEvent(string eventName, string message)
}
}
-#endregion
+ #endregion
-#region Req/Resp
+ #region Req/Resp
+ ///
+ /// Register handler with handler factory
+ ///
+ ///
+ ///
public void AddRequestHandler(Type eventType, IHandlerFactory factory)
{
_requestHandlerManager.AddRequestHandler(eventType, factory);
}
+ ///
+ /// Register handler with handler factory
+ ///
+ ///
+ ///
public void AddRequestHandler(IHandlerFactory factory)
where TEvent : TransportTray
{
_requestHandlerManager.AddRequestHandler(factory);
}
+ ///
+ /// Register handler with delegate
+ ///
+ ///
+ ///
public void AddRequestHandler(Func action)
where TEvent : TransportTray
{
_requestHandlerManager.AddRequestHandler(action);
}
+ ///
+ /// Register dynamic handler with delegate
+ ///
+ ///
+ ///
public void AddDynamicRequestHandler(string eventName, Func action)
{
_requestHandlerManager.AddDynamicRequestHandler(eventName, action);
}
-
+ ///
+ /// Remove handler by event type
+ ///
+ ///
+ ///
public void RemoveRequestHandler(Func action)
where TEvent : TransportTray
{
_requestHandlerManager.RemoveRequestHandler(action);
}
+
+ ///
+ /// Remove dynamic handler by eventName
+ ///
+ ///
+ ///
public void RemoveDynamicRequestHandler(string eventName, Func action)
{
_requestHandlerManager.RemoveDynamicRequestHandler(eventName, action);
}
+ ///
+ /// Send a request sync
+ ///
+ ///
+ ///
+ ///
public T Send(TransportTray @event)
{
var asyncTask = ProcessRequest(_requestHandlerManager.GetRequestName(@event.GetType()), JsonConvert.SerializeObject(@event));
@@ -159,6 +248,12 @@ public T Send(TransportTray @event)
return asyncTask.Result;
}
+ ///
+ /// Send a request async
+ ///
+ ///
+ ///
+ ///
public async Task SendAsync(TransportTray @event)
{
return await ProcessRequest(_requestHandlerManager.GetRequestName(@event.GetType()), JsonConvert.SerializeObject(@event));
diff --git a/src/ServiceAnt/Request/IRequestHandlerManager.cs b/src/ServiceAnt/Request/IRequestHandlerManager.cs
index 8533d4f..7d9d5b7 100644
--- a/src/ServiceAnt/Request/IRequestHandlerManager.cs
+++ b/src/ServiceAnt/Request/IRequestHandlerManager.cs
@@ -6,11 +6,30 @@
namespace ServiceAnt.Handler.Request
{
+ ///
+ /// It used to manage request handle function
+ ///
public interface IRequestHandlerManager : IAddRequestHandler
{
+ ///
+ /// Get the all handler factory of a request
+ ///
+ /// request name
+ ///
List GetHandlerFactoriesForRequest(string requestName);
+
+ ///
+ /// Get the all handler factory of a request
+ ///
+ /// request object
+ ///
List GetHandlerFactoriesForRequest(TransportTray @request);
+ ///
+ /// Get the request name by TransportTray type
+ ///
+ /// the class inherited TransportTray
+ ///
string GetRequestName(Type aType);
}
}
diff --git a/src/ServiceAnt/Request/InMemoryRequestHandlerManager.cs b/src/ServiceAnt/Request/InMemoryRequestHandlerManager.cs
index bbcb4eb..bcb874f 100644
--- a/src/ServiceAnt/Request/InMemoryRequestHandlerManager.cs
+++ b/src/ServiceAnt/Request/InMemoryRequestHandlerManager.cs
@@ -8,15 +8,26 @@
namespace ServiceAnt.Handler.Request
{
+ ///
+ /// It save the handlers in memory
+ ///
public class InMemoryRequestHandlerManager : IRequestHandlerManager
{
private readonly ConcurrentDictionary> _handlerFactories;
+ ///
+ /// Constructor
+ ///
public InMemoryRequestHandlerManager()
{
_handlerFactories = new ConcurrentDictionary>();
}
+ ///
+ /// Register dynamic handler with delegate
+ ///
+ ///
+ ///
public void AddDynamicRequestHandler(string eventName, Func action)
{
var eventHandler = new ActionRequestHandler(action);
@@ -24,11 +35,21 @@ public void AddDynamicRequestHandler(string eventName, Func
+ /// Register handler with handler factory
+ ///
+ ///
+ ///
public void AddRequestHandler(Type eventType, IHandlerFactory factory)
{
DoAddRequestHandler(factory, eventType);
}
+ ///
+ /// Register handler with delegate
+ ///
+ ///
+ ///
public void AddRequestHandler(Func action) where TEvent : TransportTray
{
var eventHandler = new ActionRequestHandler(action);
@@ -36,21 +57,41 @@ public void AddRequestHandler(Type eventType, IHandlerFactory factory)
AddRequestHandler(new SingletonHandlerFactory(eventHandler, typeof(TEvent)));
}
+ ///
+ /// Register handler with handler factory
+ ///
+ ///
+ ///
public void AddRequestHandler(IHandlerFactory factory) where TEvent : TransportTray
{
DoAddRequestHandler(factory, typeof(TEvent));
}
+ ///
+ /// Get the all handler factory of a request
+ ///
+ /// request object
+ ///
public List GetHandlerFactoriesForRequest(TransportTray request)
{
return GetOrCreateHandlerFactories(GetRequestName(request.GetType()));
}
+ ///
+ /// Get the all handler factory of a request
+ ///
+ /// request name
+ ///
public List GetHandlerFactoriesForRequest(string requestName)
{
return GetOrCreateHandlerFactories(requestName);
}
+ ///
+ /// Get the request name by TransportTray type
+ ///
+ /// the class inherited TransportTray
+ ///
public string GetRequestName(Type aType)
{
if (aType.IsGenericType)
@@ -63,6 +104,11 @@ public string GetRequestName(Type aType)
}
}
+ ///
+ /// Register dynamic handler with delegate
+ ///
+ ///
+ ///
public void RemoveDynamicRequestHandler(string eventName, Func action)
{
GetOrCreateHandlerFactories(eventName)
@@ -87,6 +133,11 @@ public void RemoveDynamicRequestHandler(string eventName, Func
+ /// Remove handler by event type
+ ///
+ ///
+ ///
public void RemoveRequestHandler(Func action) where TEvent : TransportTray
{
GetOrCreateHandlerFactories(typeof(TEvent).Name)
diff --git a/tools/nupkg/ServiceAnt.1.0.0.zip b/tools/nupkg/ServiceAnt.1.0.0.zip
new file mode 100644
index 0000000..67c8440
Binary files /dev/null and b/tools/nupkg/ServiceAnt.1.0.0.zip differ