Add project files.
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
using PoweredSoft.CQRS.Abstractions.Attributes;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
namespace PoweredSoft.CQRS.Abstractions.Discovery
|
||||
{
|
||||
public class CommandMeta : ICommandMeta
|
||||
{
|
||||
public CommandMeta(Type commandType, Type serviceType, Type commandResultType)
|
||||
{
|
||||
CommandType = commandType;
|
||||
ServiceType = serviceType;
|
||||
CommandResultType = commandResultType;
|
||||
}
|
||||
|
||||
public CommandMeta(Type commandType, Type serviceType)
|
||||
{
|
||||
CommandType = commandType;
|
||||
ServiceType = serviceType;
|
||||
}
|
||||
|
||||
protected virtual CommandNameAttribute NameAttribute => CommandType.GetCustomAttribute<CommandNameAttribute>();
|
||||
|
||||
public virtual string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
var name = NameAttribute?.Name ?? CommandType.Name.Replace("Command", string.Empty);
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual Type CommandType { get; }
|
||||
public virtual Type ServiceType { get; }
|
||||
public virtual Type CommandResultType { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
|
||||
namespace PoweredSoft.CQRS.Abstractions.Discovery
|
||||
{
|
||||
public interface ICommandMeta
|
||||
{
|
||||
string Name { get; }
|
||||
Type CommandType { get; }
|
||||
Type ServiceType { get; }
|
||||
Type CommandResultType { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace PoweredSoft.CQRS.Abstractions.Discovery
|
||||
{
|
||||
public interface IQueryDiscovery
|
||||
{
|
||||
IQueryMeta FindQuery(string name);
|
||||
IQueryMeta FindQuery(Type queryType);
|
||||
IEnumerable<IQueryMeta> GetQueries();
|
||||
bool QueryExists(string name);
|
||||
bool QueryExists(Type queryType);
|
||||
}
|
||||
|
||||
public interface ICommandDiscovery
|
||||
{
|
||||
bool CommandExists(string name);
|
||||
bool CommandExists(Type commandType);
|
||||
ICommandMeta FindCommand(string name);
|
||||
ICommandMeta FindCommand(Type commandType);
|
||||
IEnumerable<ICommandMeta> GetCommands();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
|
||||
namespace PoweredSoft.CQRS.Abstractions.Discovery
|
||||
{
|
||||
public interface IQueryMeta
|
||||
{
|
||||
string Name { get; }
|
||||
Type QueryType { get; }
|
||||
Type ServiceType { get; }
|
||||
Type QueryResultType { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
using PoweredSoft.CQRS.Abstractions.Attributes;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
namespace PoweredSoft.CQRS.Abstractions.Discovery
|
||||
{
|
||||
public class QueryMeta : IQueryMeta
|
||||
{
|
||||
public QueryMeta(Type queryType, Type serviceType, Type queryResultType)
|
||||
{
|
||||
QueryType = queryType;
|
||||
ServiceType = serviceType;
|
||||
QueryResultType = queryResultType;
|
||||
}
|
||||
|
||||
protected virtual QueryNameAttribute NameAttribute => QueryType.GetCustomAttribute<QueryNameAttribute>();
|
||||
|
||||
public virtual string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
var name = NameAttribute?.Name ?? QueryType.Name.Replace("Query", string.Empty);
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual Type QueryType { get; }
|
||||
public virtual Type ServiceType { get; }
|
||||
public virtual Type QueryResultType { get; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user