Commit e39e6615 authored by 阿星Plus's avatar 阿星Plus

v1.0.5

parent 9acef28e
namespace Plus
{
/// <summary>
/// 输出 <see cref="T"/>
/// ActionOutput
/// </summary>
/// <typeparam name="T"></typeparam>
public class ActionOutput<T> : ActionOutput
......
......@@ -7,8 +7,15 @@ namespace Plus.CodeAnnotations
/// </summary>
public class EnumAliasAttribute : Attribute
{
/// <summary>
/// 别名
/// </summary>
public string Alias { get; set; }
/// <summary>
/// 枚举别名属性
/// </summary>
/// <param name="alias"></param>
public EnumAliasAttribute(string alias)
{
Alias = alias;
......
......@@ -15,20 +15,20 @@ namespace Plus.CodeAnnotations
/// <returns></returns>
public static string ToAlias(this Enum _enum)
{
Type type = _enum.GetType();
FieldInfo field = type.GetField(_enum.ToString());
var type = _enum.GetType();
var field = type.GetField(_enum.ToString());
if (field == null)
{
return string.Empty;
}
string result = string.Empty;
var result = string.Empty;
object[] customAttributes = field.GetCustomAttributes(typeof(EnumAliasAttribute), inherit: false);
object[] array = customAttributes;
var customAttributes = field.GetCustomAttributes(typeof(EnumAliasAttribute), inherit: false);
var array = customAttributes;
for (int i = 0; i < array.Length; i++)
{
EnumAliasAttribute enumAliasAttribute = (EnumAliasAttribute)array[i];
var enumAliasAttribute = (EnumAliasAttribute)array[i];
result = enumAliasAttribute.Alias;
}
return result;
......
......@@ -53,67 +53,124 @@ namespace Plus.Collections
_typeList = new List<Type>();
}
/// <summary>
/// Add
/// </summary>
/// <typeparam name="T"></typeparam>
public void Add<T>() where T : TBaseType
{
_typeList.Add(typeof(T));
}
/// <summary>
/// Add
/// </summary>
/// <param name="item"></param>
public void Add(Type item)
{
CheckType(item);
_typeList.Add(item);
}
/// <summary>
/// Insert
/// </summary>
/// <param name="index"></param>
/// <param name="item"></param>
public void Insert(int index, Type item)
{
_typeList.Insert(index, item);
}
/// <summary>
/// IndexOf
/// </summary>
/// <param name="item"></param>
/// <returns></returns>
public int IndexOf(Type item)
{
return _typeList.IndexOf(item);
}
/// <summary>
/// Contains
/// </summary>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public bool Contains<T>() where T : TBaseType
{
return Contains(typeof(T));
}
/// <summary>
/// Contains
/// </summary>
/// <param name="item"></param>
/// <returns></returns>
public bool Contains(Type item)
{
return _typeList.Contains(item);
}
/// <summary>
/// Remove
/// </summary>
/// <typeparam name="T"></typeparam>
public void Remove<T>() where T : TBaseType
{
_typeList.Remove(typeof(T));
}
/// <summary>
/// Remove
/// </summary>
/// <param name="item"></param>
/// <returns></returns>
public bool Remove(Type item)
{
return _typeList.Remove(item);
}
/// <summary>
/// RemoveAt
/// </summary>
/// <param name="index"></param>
public void RemoveAt(int index)
{
_typeList.RemoveAt(index);
}
/// <summary>
/// Clear
/// </summary>
public void Clear()
{
_typeList.Clear();
}
/// <summary>
/// CopyTo
/// </summary>
/// <param name="array"></param>
/// <param name="arrayIndex"></param>
public void CopyTo(Type[] array, int arrayIndex)
{
_typeList.CopyTo(array, arrayIndex);
}
/// <summary>
/// GetEnumerator
/// </summary>
/// <returns></returns>
public IEnumerator<Type> GetEnumerator()
{
return _typeList.GetEnumerator();
}
/// <summary>
/// GetEnumerator
/// </summary>
/// <returns></returns>
IEnumerator IEnumerable.GetEnumerator()
{
return _typeList.GetEnumerator();
......
namespace Plus.Configuration
{
/// <summary>
/// DefaultSettings
/// </summary>
public class DefaultSettings : SettingsBase
{
/// <summary>
/// GetDefaultNameOrConnectionString
/// </summary>
/// <returns></returns>
public string GetDefaultNameOrConnectionString()
{
return Config["DefaultNameOrConnectionString"];
......
using Plus.Dependency;
using Plus.Event.Bus;
namespace Plus.Configuration.Startup
{
......
using System.Reflection;
namespace Plus.Dependency
{
public class ConventionalRegistrationContext : IRegistrationContext
{
public Assembly Assembly
{
get;
private set;
}
public IIocManager IocManager
{
get;
private set;
}
internal ConventionalRegistrationContext(Assembly assembly, IIocManager iocManager)
{
Assembly = assembly;
IocManager = iocManager;
}
}
}
\ No newline at end of file
......@@ -21,5 +21,20 @@ namespace Plus.Dependency
{
return new DisposableDependencyObjectWrapper(iocResolver, iocResolver.Resolve(type));
}
public static IDisposableDependencyObjectWrapper<T> ResolveAsDisposable<T>(this IIocResolver iocResolver, object argumentsAsAnonymousType)
{
return new DisposableDependencyObjectWrapper<T>(iocResolver, iocResolver.Resolve<T>(argumentsAsAnonymousType));
}
public static IDisposableDependencyObjectWrapper<T> ResolveAsDisposable<T>(this IIocResolver iocResolver, Type type, object argumentsAsAnonymousType)
{
return new DisposableDependencyObjectWrapper<T>(iocResolver, (T)iocResolver.Resolve(type, argumentsAsAnonymousType));
}
public static IDisposableDependencyObjectWrapper ResolveAsDisposable(this IIocResolver iocResolver, Type type, object argumentsAsAnonymousType)
{
return new DisposableDependencyObjectWrapper(iocResolver, iocResolver.Resolve(type, argumentsAsAnonymousType));
}
}
}
\ No newline at end of file
using System;
using System.ComponentModel.DataAnnotations.Schema;
namespace Plus.Domain.Entities.Auditing
{
[Serializable]
public abstract class AuditedEntity : AuditedEntity<int>
{
}
[Serializable]
public abstract class AuditedEntity<TPrimaryKey> : CreationAuditedEntity<TPrimaryKey>, IAudited, ICreationAudited, IHasCreationTime, IModificationAudited, IHasModificationTime
{
public virtual DateTime? LastModificationTime { get; set; }
public virtual long? LastModifierUserId { get; set; }
}
[Serializable]
public abstract class AuditedEntity<TPrimaryKey, TUser> : AuditedEntity<TPrimaryKey>, IAudited<TUser>, IAudited, ICreationAudited, IHasCreationTime, IModificationAudited, IHasModificationTime, ICreationAudited<TUser>, IModificationAudited<TUser> where TUser : IEntity<long>
{
[ForeignKey("CreatorUserId")]
public virtual TUser CreatorUser { get; set; }
[ForeignKey("LastModifierUserId")]
public virtual TUser LastModifierUser { get; set; }
}
}
\ No newline at end of file
using System;
using System.ComponentModel.DataAnnotations.Schema;
namespace Plus.Domain.Entities.Auditing
{
[Serializable]
public abstract class CreationAuditedEntity : CreationAuditedEntity<int>
{
}
[Serializable]
public abstract class CreationAuditedEntity<TPrimaryKey> : Entity<TPrimaryKey>, ICreationAudited, IHasCreationTime
{
public virtual DateTime CreationTime { get; set; }
public virtual long? CreatorUserId { get; set; }
protected CreationAuditedEntity()
{
CreationTime = DateTime.Now;
}
}
[Serializable]
public abstract class CreationAuditedEntity<TPrimaryKey, TUser> : CreationAuditedEntity<TPrimaryKey>, ICreationAudited<TUser>, ICreationAudited, IHasCreationTime where TUser : IEntity<long>
{
[ForeignKey("CreatorUserId")]
public virtual TUser CreatorUser { get; set; }
}
}
\ No newline at end of file
......@@ -6,12 +6,11 @@ namespace Plus.Domain.Entities.Auditing
{
public static void SetCreationAuditProperties(object entityAsObj, long? userId)
{
IHasCreationTime hasCreationTime = entityAsObj as IHasCreationTime;
if (hasCreationTime == null)
if (!(entityAsObj is IHasCreationTime hasCreationTime))
{
return;
}
if (hasCreationTime.CreationTime == default(DateTime))
if (hasCreationTime.CreationTime == default)
{
hasCreationTime.CreationTime = DateTime.Now;
}
......
using System;
using System.ComponentModel.DataAnnotations.Schema;
namespace Plus.Domain.Entities.Auditing
{
[Serializable]
public abstract class FullAuditedEntity : FullAuditedEntity<int>
{
}
[Serializable]
public abstract class FullAuditedEntity<TPrimaryKey> : AuditedEntity<TPrimaryKey>, IFullAudited, IAudited, ICreationAudited, IHasCreationTime, IModificationAudited, IHasModificationTime, IDeletionAudited, IHasDeletionTime, ISoftDelete
{
public virtual bool IsDeleted { get; set; }
public virtual long? DeleterUserId { get; set; }
public virtual DateTime? DeletionTime { get; set; }
}
[Serializable]
public abstract class FullAuditedEntity<TPrimaryKey, TUser> : AuditedEntity<TPrimaryKey, TUser>, IFullAudited<TUser>, IAudited<TUser>, IAudited, ICreationAudited, IHasCreationTime, IModificationAudited, IHasModificationTime, ICreationAudited<TUser>, IModificationAudited<TUser>, IFullAudited, IDeletionAudited, IHasDeletionTime, ISoftDelete, IDeletionAudited<TUser> where TUser : IEntity<long>
{
public virtual bool IsDeleted { get; set; }
[ForeignKey("DeleterUserId")]
public virtual TUser DeleterUser { get; set; }
public virtual long? DeleterUserId { get; set; }
public virtual DateTime? DeletionTime { get; set; }
}
}
\ No newline at end of file
namespace Plus.Domain.Entities.Auditing
{
/// <summary>
/// IAudited
/// </summary>
public interface IAudited : ICreationAudited, IHasCreationTime, IModificationAudited, IHasModificationTime
{
}
/// <summary>
/// IAudited
/// </summary>
/// <typeparam name="TUser"></typeparam>
public interface IAudited<TUser> : IAudited, ICreationAudited, IHasCreationTime, IModificationAudited, IHasModificationTime, ICreationAudited<TUser>, IModificationAudited<TUser> where TUser : IEntity<long>
{
}
}
\ No newline at end of file
namespace Plus.Domain.Entities.Auditing
{
/// <summary>
/// ICreationAudited
/// </summary>
public interface ICreationAudited : IHasCreationTime
{
long? CreatorUserId
{
get;
set;
}
long? CreatorUserId { get; set; }
}
/// <summary>
/// ICreationAudited
/// </summary>
/// <typeparam name="TUser"></typeparam>
public interface ICreationAudited<TUser> : ICreationAudited, IHasCreationTime where TUser : IEntity<long>
{
TUser CreatorUser
{
get;
set;
}
TUser CreatorUser { get; set; }
}
}
\ No newline at end of file
namespace Plus.Domain.Entities.Auditing
{
/// <summary>
/// IDeletionAudited
/// </summary>
public interface IDeletionAudited : IHasDeletionTime, ISoftDelete
{
long? DeleterUserId
{
get;
set;
}
long? DeleterUserId { get; set; }
}
/// <summary>
/// IDeletionAudited
/// </summary>
/// <typeparam name="TUser"></typeparam>
public interface IDeletionAudited<TUser> : IDeletionAudited, IHasDeletionTime, ISoftDelete where TUser : IEntity<long>
{
TUser DeleterUser
{
get;
set;
}
TUser DeleterUser { get; set; }
}
}
\ No newline at end of file
namespace Plus.Domain.Entities.Auditing
{
/// <summary>
/// IFullAudited
/// </summary>
public interface IFullAudited : IAudited, ICreationAudited, IHasCreationTime, IModificationAudited, IHasModificationTime, IDeletionAudited, IHasDeletionTime, ISoftDelete
{
}
/// <summary>
/// IFullAudited
/// </summary>
/// <typeparam name="TUser"></typeparam>
public interface IFullAudited<TUser> : IAudited<TUser>, IAudited, ICreationAudited, IHasCreationTime, IModificationAudited, IHasModificationTime, ICreationAudited<TUser>, IModificationAudited<TUser>, IFullAudited, IDeletionAudited, IHasDeletionTime, ISoftDelete, IDeletionAudited<TUser> where TUser : IEntity<long>
{
}
}
\ No newline at end of file
......@@ -2,12 +2,11 @@
namespace Plus.Domain.Entities.Auditing
{
/// <summary>
/// IHasCreationTime
/// </summary>
public interface IHasCreationTime
{
DateTime CreationTime
{
get;
set;
}
DateTime CreationTime { get; set; }
}
}
}
\ No newline at end of file
......@@ -2,12 +2,11 @@
namespace Plus.Domain.Entities.Auditing
{
/// <summary>
/// IHasDeletionTime
/// </summary>
public interface IHasDeletionTime : ISoftDelete
{
DateTime? DeletionTime
{
get;
set;
}
DateTime? DeletionTime { get; set; }
}
}
\ No newline at end of file
......@@ -2,12 +2,11 @@
namespace Plus.Domain.Entities.Auditing
{
/// <summary>
/// IHasModificationTime
/// </summary>
public interface IHasModificationTime
{
DateTime? LastModificationTime
{
get;
set;
}
DateTime? LastModificationTime { get; set; }
}
}
\ No newline at end of file
namespace Plus.Domain.Entities.Auditing
{
/// <summary>
/// IModificationAudited
/// </summary>
public interface IModificationAudited : IHasModificationTime
{
long? LastModifierUserId
{
get;
set;
}
long? LastModifierUserId { get; set; }
}
/// <summary>
/// IModificationAudited
/// </summary>
/// <typeparam name="TUser"></typeparam>
public interface IModificationAudited<TUser> : IModificationAudited, IHasModificationTime where TUser : IEntity<long>
{
TUser LastModifierUser
{
get;
set;
}
TUser LastModifierUser { get; set; }
}
}
\ No newline at end of file
......@@ -29,6 +29,12 @@ namespace Plus.Domain.Entities.Caching
}
}
/// <summary>
/// EntityCache
/// </summary>
/// <typeparam name="TEntity"></typeparam>
/// <typeparam name="TCacheItem"></typeparam>
/// <typeparam name="TPrimaryKey"></typeparam>
public class EntityCache<TEntity, TCacheItem, TPrimaryKey> :
IEventHandler<EntityChangedEventData<TEntity>>, IEntityCache<TCacheItem, TPrimaryKey>
where TEntity : class, IEntity<TPrimaryKey>
......
namespace Plus.Domain.Entities
{
/// <summary>
/// IAggregateRoot
/// </summary>
public interface IAggregateRoot : IAggregateRoot<int>, IEntity<int>, IGeneratesDomainEvents, IEntity
{
}
/// <summary>
/// IAggregateRoot
/// </summary>
/// <typeparam name="TPrimaryKey"></typeparam>
public interface IAggregateRoot<TPrimaryKey> : IEntity<TPrimaryKey>, IGeneratesDomainEvents
{
}
}
\ No newline at end of file
......@@ -8,9 +8,6 @@ namespace Plus.Domain.Entities
/// </summary>
public interface IGeneratesDomainEvents
{
ICollection<IEventData> DomainEvents
{
get;
}
ICollection<IEventData> DomainEvents { get; }
}
}
\ No newline at end of file
......@@ -2,10 +2,6 @@
{
public interface ISoftDelete
{
bool IsDeleted
{
get;
set;
}
bool IsDeleted { get; set; }
}
}
\ No newline at end of file
namespace Plus.Domain.Events
{
public class EntityDeleted<T>
{
public T Entity { get; private set; }
public EntityDeleted(T entity)
{
Entity = entity;
}
}
}
\ No newline at end of file
namespace Plus.Domain.Events
{
public class EntityInserted<T>
{
public T Entity { get; private set; }
public EntityInserted(T entity)
{
Entity = entity;
}
}
}
\ No newline at end of file
namespace Plus.Domain.Events
{
public class EntityUpdated<T>
{
public T Entity { get; private set; }
public EntityUpdated(T entity)
{
Entity = entity;
}
}
}
\ No newline at end of file
using Plus.Domain.Entities;
using Plus.Domain.Uow;
using System;
using System.Collections.Generic;
using System.Linq;
......
......@@ -96,30 +96,30 @@ namespace Plus.Domain.Uow
/// <param name="value">Value of the parameter to be set</param>
IDisposable SetFilterParameter(string filterName, string parameterName, object value);
/// <summary>
/// Sets/Changes Tenant's Id for this UOW.
/// </summary>
/// <param name="tenantId">The tenant id.</param>
/// <returns>A disposable object to restore old TenantId value when you dispose it</returns>
IDisposable SetTenantId(int? tenantId);
/// <summary>
/// Sets/Changes Tenant's Id for this UOW.
/// </summary>
/// <param name="tenantId">The tenant id</param>
/// <param name="switchMustHaveTenantEnableDisable">
/// True to enable/disable <see cref="IMustHaveTenant"/> based on given tenantId.
/// Enables <see cref="IMustHaveTenant"/> filter if tenantId is not null.
/// Disables <see cref="IMustHaveTenant"/> filter if tenantId is null.
/// This value is true for <see cref="SetTenantId(int?)"/> method.
/// </param>
/// <returns>A disposable object to restore old TenantId value when you dispose it</returns>
IDisposable SetTenantId(int? tenantId, bool switchMustHaveTenantEnableDisable);
/// <summary>
/// Gets Tenant Id for this UOW.
/// </summary>
/// <returns></returns>
int? GetTenantId();
///// <summary>
///// Sets/Changes Tenant's Id for this UOW.
///// </summary>
///// <param name="tenantId">The tenant id.</param>
///// <returns>A disposable object to restore old TenantId value when you dispose it</returns>
//IDisposable SetTenantId(int? tenantId);
///// <summary>
///// Sets/Changes Tenant's Id for this UOW.
///// </summary>
///// <param name="tenantId">The tenant id</param>
///// <param name="switchMustHaveTenantEnableDisable">
///// True to enable/disable <see cref="IMustHaveTenant"/> based on given tenantId.
///// Enables <see cref="IMustHaveTenant"/> filter if tenantId is not null.
///// Disables <see cref="IMustHaveTenant"/> filter if tenantId is null.
///// This value is true for <see cref="SetTenantId(int?)"/> method.
///// </param>
///// <returns>A disposable object to restore old TenantId value when you dispose it</returns>
//IDisposable SetTenantId(int? tenantId, bool switchMustHaveTenantEnableDisable);
///// <summary>
///// Gets Tenant Id for this UOW.
///// </summary>
///// <returns></returns>
//int? GetTenantId();
}
}
\ No newline at end of file
namespace Plus.Domain.Uow
using System;
namespace Plus.Domain.Uow
{
/// <summary>
/// 工作单元接口
/// </summary>
public interface IUnitOfWork : IActiveUnitOfWork, IUnitOfWorkCompleteHandle
public interface IUnitOfWork : IActiveUnitOfWork, IUnitOfWorkCompleteHandle, IDisposable
{
string Id { get; }
......
......@@ -15,6 +15,7 @@ namespace Plus.Domain.Uow
public const string DidNotCallCompleteMethodExceptionMessage = "未调用完整方法的工作单元";
private volatile bool _isCompleteCalled;
private volatile bool _isDisposed;
public void Complete()
......@@ -30,21 +31,13 @@ namespace Plus.Domain.Uow
public void Dispose()
{
if (_isDisposed)
{
return;
}
_isDisposed = true;
if (!_isCompleteCalled)
if (!_isDisposed)
{
if (HasException())
_isDisposed = true;
if (!_isCompleteCalled && !HasException())
{
return;
throw new PlusException("Did not call Complete method of a unit of work.");
}
throw new PlusException(DidNotCallCompleteMethodExceptionMessage);
}
}
......
namespace Plus.Domain.Uow
using Plus.Domain.Entities;
namespace Plus.Domain.Uow
{
/// <summary>
/// Standard filters of Plus.
......@@ -12,35 +14,5 @@
/// See <see cref="ISoftDelete"/> interface.
/// </summary>
public const string SoftDelete = "SoftDelete";
/// <summary>
/// "MustHaveTenant".
/// Tenant filter to prevent getting data that is
/// not belong to current tenant.
/// </summary>
public const string MustHaveTenant = "MustHaveTenant";
/// <summary>
/// "MayHaveTenant".
/// Tenant filter to prevent getting data that is
/// not belong to current tenant.
/// </summary>
public const string MayHaveTenant = "MayHaveTenant";
/// <summary>
/// Standard parameters of Plus.
/// </summary>
public static class Parameters
{
/// <summary>
/// "tenantId".
/// </summary>
public const string TenantId = "tenantId";
/// <summary>
/// "isDeleted".
/// </summary>
public const string IsDeleted = "isDeleted";
}
}
}
\ No newline at end of file
......@@ -22,8 +22,6 @@ namespace Plus.Domain.Uow
private Exception _exception;
private int? _tenantId;
public string Id { get; }
[DoNotWire]
......@@ -41,7 +39,7 @@ namespace Plus.Domain.Uow
public bool IsDisposed { get; private set; }
protected IUnitOfWorkFilterExecuter FilterExecuter{ get; }
protected IUnitOfWorkFilterExecuter FilterExecuter { get; }
public event EventHandler Completed;
......@@ -148,7 +146,7 @@ namespace Plus.Domain.Uow
catch (Exception exception)
{
Exception ex = _exception = exception;
throw;
throw ex;
}
}
......@@ -164,7 +162,7 @@ namespace Plus.Domain.Uow
catch (Exception exception)
{
Exception ex = _exception = exception;
throw;
throw ex;
}
}
......@@ -282,44 +280,5 @@ namespace Plus.Domain.Uow
{
return "[UnitOfWork " + Id + "]";
}
public virtual IDisposable SetTenantId(int? tenantId)
{
return SetTenantId(tenantId, true);
}
public virtual IDisposable SetTenantId(int? tenantId, bool switchMustHaveTenantEnableDisable)
{
var oldTenantId = _tenantId;
_tenantId = tenantId;
IDisposable mustHaveTenantEnableChange;
if (switchMustHaveTenantEnableDisable)
{
mustHaveTenantEnableChange = tenantId == null
? DisableFilter(PlusDataFilters.MustHaveTenant)
: EnableFilter(PlusDataFilters.MustHaveTenant);
}
else
{
mustHaveTenantEnableChange = NullDisposable.Instance;
}
var mayHaveTenantChange = SetFilterParameter(PlusDataFilters.MayHaveTenant, PlusDataFilters.Parameters.TenantId, tenantId);
var mustHaveTenantChange = SetFilterParameter(PlusDataFilters.MustHaveTenant, PlusDataFilters.Parameters.TenantId, tenantId ?? 0);
return new DisposeAction(() =>
{
mayHaveTenantChange.Dispose();
mustHaveTenantChange.Dispose();
mustHaveTenantEnableChange.Dispose();
_tenantId = oldTenantId;
});
}
public int? GetTenantId()
{
return _tenantId;
}
}
}
\ No newline at end of file
......@@ -5,15 +5,9 @@ namespace Plus.Event.Bus.Entities
[Serializable]
public class DomainEventEntry
{
public object SourceEntity
{
get;
}
public object SourceEntity { get; }
public IEventData EventData
{
get;
}
public IEventData EventData { get; }
public DomainEventEntry(object sourceEntity, IEventData eventData)
{
......
......@@ -5,17 +5,9 @@ namespace Plus.Event.Bus.Entities
[Serializable]
public class EntityChangeEntry
{
public object Entity
{
get;
set;
}
public object Entity { get; set; }
public EntityChangeType ChangeType
{
get;
set;
}
public EntityChangeType ChangeType { get; set; }
public EntityChangeEntry(object entity, EntityChangeType changeType)
{
......
......@@ -10,11 +10,7 @@ namespace Plus.Event.Bus.Entities
{
private readonly IUnitOfWorkManager _unitOfWorkManager;
public IEventBus EventBus
{
get;
set;
}
public IEventBus EventBus { get; set; }
public EntityChangeEventHelper(IUnitOfWorkManager unitOfWorkManager)
{
......
......@@ -4,15 +4,9 @@ namespace Plus.Event.Bus.Entities
{
public class EntityChangeReport
{
public List<EntityChangeEntry> ChangedEntities
{
get;
}
public List<EntityChangeEntry> ChangedEntities { get; }
public List<DomainEventEntry> DomainEvents
{
get;
}
public List<DomainEventEntry> DomainEvents { get; }
public EntityChangeReport()
{
......
using System;
using Plus.Domain.Entities;
using System;
namespace Plus.Event.Bus.Entities
{
......
using System;
using Plus.Domain.Entities;
using System;
namespace Plus.Event.Bus.Entities
{
......
This diff is collapsed.
......@@ -4,11 +4,7 @@ namespace Plus.Event.Bus.Exceptions
{
public class ExceptionData : EventData
{
public Exception Exception
{
get;
private set;
}
public Exception Exception { get; private set; }
public ExceptionData(Exception exception)
{
......
......@@ -10,204 +10,46 @@ namespace Plus.Event.Bus
/// </summary>
public interface IEventBus
{
#region Register
/// <summary>
/// Registers to an event.
/// Given action is called for all event occurrences.
/// </summary>
/// <param name="action">Action to handle events</param>
/// <typeparam name="TEventData">Event type</typeparam>
IDisposable Register<TEventData>(Action<TEventData> action) where TEventData : IEventData;
/// <summary>
/// Registers to an event.
/// Given action is called for all event occurrences.
/// </summary>
/// <param name="action">Action to handle events</param>
/// <typeparam name="TEventData">Event type</typeparam>
IDisposable AsyncRegister<TEventData>(Func<TEventData, Task> action) where TEventData : IEventData;
/// <summary>
/// Registers to an event.
/// Same (given) instance of the handler is used for all event occurrences.
/// </summary>
/// <typeparam name="TEventData">Event type</typeparam>
/// <param name="handler">Object to handle the event</param>
IDisposable Register<TEventData>(IEventHandler<TEventData> handler) where TEventData : IEventData;
/// <summary>
/// Registers to an event.
/// Same (given) instance of the async handler is used for all event occurrences.
/// </summary>
/// <typeparam name="TEventData">Event type</typeparam>
/// <param name="handler">Object to handle the event</param>
IDisposable AsyncRegister<TEventData>(IAsyncEventHandler<TEventData> handler) where TEventData : IEventData;
/// <summary>
/// Registers to an event.
/// A new instance of <see cref="THandler"/> object is created for every event occurrence.
/// </summary>
/// <typeparam name="TEventData">Event type</typeparam>
/// <typeparam name="THandler">Type of the event handler</typeparam>
IDisposable Register<TEventData, THandler>() where TEventData : IEventData 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 Register<TEventData, THandler>() where TEventData : IEventData where THandler : IEventHandler<TEventData>, new();
IDisposable Register(Type eventType, IEventHandler handler);
/// <summary>
/// Registers to an event.
/// Given factory is used to create/release handlers
/// </summary>
/// <typeparam name="TEventData">Event type</typeparam>
/// <param name="factory">A factory to create/release handlers</param>
IDisposable Register<TEventData>(IEventHandlerFactory factory) where TEventData : IEventData;
/// <summary>
/// Registers to an event.
/// </summary>
/// <param name="eventType">Event type</param>
/// <param name="factory">A factory to create/release handlers</param>
IDisposable Register(Type eventType, IEventHandlerFactory factory);
#endregion
#region Unregister
/// <summary>
/// Unregisters from an event.
/// </summary>
/// <typeparam name="TEventData">Event type</typeparam>
/// <param name="action"></param>
IDisposable Register<TEventData>(IEventHandlerFactory handlerFactory) where TEventData : IEventData;
IDisposable Register(Type eventType, IEventHandlerFactory handlerFactory);
void Unregister<TEventData>(Action<TEventData> action) where TEventData : IEventData;
/// <summary>
/// Unregisters from an event.
/// </summary>
/// <typeparam name="TEventData">Event type</typeparam>
/// <param name="action"></param>
void AsyncUnregister<TEventData>(Func<TEventData, Task> action) where TEventData : IEventData;
/// <summary>
/// Unregisters from an event.
/// </summary>
/// <typeparam name="TEventData">Event type</typeparam>
/// <param name="handler">Handler object that is registered before</param>
void Unregister<TEventData>(IEventHandler<TEventData> handler) where TEventData : IEventData;
/// <summary>
/// Unregisters from an event.
/// </summary>
/// <typeparam name="TEventData">Event type</typeparam>
/// <param name="handler">Handler object that is registered before</param>
void AsyncUnregister<TEventData>(IAsyncEventHandler<TEventData> handler) where TEventData : IEventData;
/// <summary>
/// Unregisters from an event.
/// </summary>
/// <param name="eventType">Event type</param>
/// <param name="handler">Handler object that is registered before</param>
void Unregister(Type eventType, IEventHandler handler);
/// <summary>
/// Unregisters from an event.
/// </summary>
/// <typeparam name="TEventData">Event type</typeparam>
/// <param name="factory">Factory object that is registered before</param>
void Unregister<TEventData>(IEventHandlerFactory factory) where TEventData : IEventData;
/// <summary>
/// Unregisters from an event.
/// </summary>
/// <param name="eventType">Event type</param>
/// <param name="factory">Factory object that is registered before</param>
void Unregister(Type eventType, IEventHandlerFactory factory);
/// <summary>
/// Unregisters all event handlers of given event type.
/// </summary>
/// <typeparam name="TEventData">Event type</typeparam>
void UnregisterAll<TEventData>() where TEventData : IEventData;
/// <summary>
/// Unregisters all event handlers of given event type.
/// </summary>
/// <param name="eventType">Event type</param>
void UnregisterAll(Type eventType);
#endregion
#region Trigger
/// <summary>
/// Triggers an event.
/// </summary>
/// <typeparam name="TEventData">Event type</typeparam>
/// <param name="eventData">Related data for the event</param>
void Trigger<TEventData>(TEventData eventData) where TEventData : IEventData;
/// <summary>
/// Triggers an event.
/// </summary>
/// <typeparam name="TEventData">Event type</typeparam>
/// <param name="eventSource">The object which triggers the event</param>
/// <param name="eventData">Related data for the event</param>
void Trigger<TEventData>(object eventSource, TEventData eventData) where TEventData : IEventData;
/// <summary>
/// Triggers an event.
/// </summary>
/// <param name="eventType">Event type</param>
/// <param name="eventData">Related data for the event</param>
void Trigger(Type eventType, IEventData eventData);
/// <summary>
/// Triggers an event.
/// </summary>
/// <param name="eventType">Event type</param>
/// <param name="eventSource">The object which triggers the event</param>
/// <param name="eventData">Related data for the event</param>
void Trigger(Type eventType, object eventSource, IEventData eventData);
/// <summary>
/// Triggers an event asynchronously.
/// </summary>
/// <typeparam name="TEventData">Event type</typeparam>
/// <param name="eventData">Related data for the event</param>
/// <returns>The task to handle async operation</returns>
Task TriggerAsync<TEventData>(TEventData eventData) where TEventData : IEventData;
/// <summary>
/// Triggers an event asynchronously.
/// </summary>
/// <typeparam name="TEventData">Event type</typeparam>
/// <param name="eventSource">The object which triggers the event</param>
/// <param name="eventData">Related data for the event</param>
/// <returns>The task to handle async operation</returns>
Task TriggerAsync<TEventData>(object eventSource, TEventData eventData) where TEventData : IEventData;
/// <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 TriggerAsync(Type eventType, IEventData eventData);
/// <summary>
/// Triggers an event asynchronously.
/// </summary>
/// <param name="eventType">Event type</param>
/// <param name="eventSource">The object which triggers the event</param>
/// <param name="eventData">Related data for the event</param>
/// <returns>The task to handle async operation</returns>
Task TriggerAsync(Type eventType, object eventSource, IEventData eventData);
#endregion
}
}
\ No newline at end of file
......@@ -10,14 +10,10 @@ namespace Plus.Event.Bus
/// </summary>
public sealed class NullEventBus : IEventBus
{
/// <summary>
/// 获取 <see cref="NullEventBus"/> 实例
/// </summary>
public static NullEventBus Instance { get; } = new NullEventBus();
private NullEventBus()
{
}
public IDisposable Register<TEventData>(Action<TEventData> action) where TEventData : IEventData
......@@ -25,24 +21,12 @@ namespace Plus.Event.Bus
return NullDisposable.Instance;
}
public IDisposable AsyncRegister<TEventData>(Func<TEventData, Task> action) where TEventData : IEventData
{
return NullDisposable.Instance;
}
public IDisposable Register<TEventData>(IEventHandler<TEventData> handler) where TEventData : IEventData
{
return NullDisposable.Instance;
}
public IDisposable AsyncRegister<TEventData>(IAsyncEventHandler<TEventData> handler) where TEventData : IEventData
{
return NullDisposable.Instance;
}
public IDisposable Register<TEventData, THandler>()
where TEventData : IEventData
where THandler : IEventHandler, new()
public IDisposable Register<TEventData, THandler>() where TEventData : IEventData where THandler : IEventHandler<TEventData>, new()
{
return NullDisposable.Instance;
}
......@@ -64,22 +48,10 @@ namespace Plus.Event.Bus
public void Unregister<TEventData>(Action<TEventData> action) where TEventData : IEventData
{
}
public void AsyncUnregister<TEventData>(Func<TEventData, Task> action) where TEventData : IEventData
{
}
public void Unregister<TEventData>(IEventHandler<TEventData> handler) where TEventData : IEventData
{
}
public void AsyncUnregister<TEventData>(IAsyncEventHandler<TEventData> handler) where TEventData : IEventData
{
}
public void Unregister(Type eventType, IEventHandler handler)
......@@ -88,62 +60,62 @@ namespace Plus.Event.Bus
public void Unregister<TEventData>(IEventHandlerFactory factory) where TEventData : IEventData
{
}
public void Unregister(Type eventType, IEventHandlerFactory factory)
{
}
public void UnregisterAll<TEventData>() where TEventData : IEventData
{
}
public void UnregisterAll(Type eventType)
{
}
public void Trigger<TEventData>(TEventData eventData) where TEventData : IEventData
{
}
public void Trigger<TEventData>(object eventSource, TEventData eventData) where TEventData : IEventData
{
}
public void Trigger(Type eventType, IEventData eventData)
{
}
public void Trigger(Type eventType, object eventSource, IEventData eventData)
{
}
public Task TriggerAsync<TEventData>(TEventData eventData) where TEventData : IEventData
{
return Task.CompletedTask;
return new Task(delegate
{
});
}
public Task TriggerAsync<TEventData>(object eventSource, TEventData eventData) where TEventData : IEventData
{
return Task.CompletedTask;
return new Task(delegate
{
});
}
public Task TriggerAsync(Type eventType, IEventData eventData)
{
return Task.CompletedTask;
return new Task(delegate
{
});
}
public Task TriggerAsync(Type eventType, object eventSource, IEventData eventData)
{
return Task.CompletedTask;
return new Task(delegate
{
});
}
}
}
\ No newline at end of file
......@@ -5,6 +5,7 @@ namespace Plus.Modules
/// <summary>
/// 用于定义模块间的依赖关系
/// </summary>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
public class DependsOnAttribute : Attribute
{
public Type[] DependedModuleTypes { get; private set; }
......
......@@ -28,46 +28,39 @@ namespace Plus.Modules
public List<PlusModuleInfo> GetSortedModuleListByDependency()
{
var sortedModules = this.SortByDependencies(x => x.Dependencies);
EnsureKernelModuleToBeFirst(sortedModules);
EnsureStartupModuleToBeLast(sortedModules, StartupModuleType);
return sortedModules;
return this.SortByDependencies((PlusModuleInfo x) => x.Dependencies);
}
public static void EnsureKernelModuleToBeFirst(List<PlusModuleInfo> modules)
public void EnsureLeadershipToBeFirst()
{
var kernelModuleIndex = modules.FindIndex(m => m.Type == typeof(PlusLeadershipModule));
if (kernelModuleIndex <= 0)
{
return;
}
var kernelModule = modules[kernelModuleIndex];
modules.RemoveAt(kernelModuleIndex);
modules.Insert(0, kernelModule);
EnsureLeadershipToBeFirst(this);
}
public static void EnsureStartupModuleToBeLast(List<PlusModuleInfo> modules, Type startupModuleType)
public void EnsureStartupModuleToBeLast()
{
var startupModuleIndex = modules.FindIndex(m => m.Type == startupModuleType);
if (startupModuleIndex >= modules.Count - 1)
{
return;
}
var startupModule = modules[startupModuleIndex];
modules.RemoveAt(startupModuleIndex);
modules.Add(startupModule);
EnsureStartupModuleToBeLast(this, StartupModuleType);
}
public void EnsureKernelModuleToBeFirst()
public static void EnsureLeadershipToBeFirst(List<PlusModuleInfo> modules)
{
EnsureKernelModuleToBeFirst(this);
int num = modules.FindIndex((PlusModuleInfo x) => x.Type == typeof(PlusLeadershipModule));
if (num > 0)
{
PlusModuleInfo item = modules[num];
modules.RemoveAt(num);
modules.Insert(0, item);
}
}
public void EnsureStartupModuleToBeLast()
public static void EnsureStartupModuleToBeLast(List<PlusModuleInfo> modules, Type startupModuleType)
{
EnsureStartupModuleToBeLast(this, StartupModuleType);
int num = modules.FindIndex((PlusModuleInfo x) => x.Type == startupModuleType);
if (num < modules.Count - 1)
{
PlusModuleInfo item = modules[num];
modules.RemoveAt(num);
modules.Add(item);
}
}
}
}
\ No newline at end of file
......@@ -69,7 +69,7 @@ namespace Plus.Modules
RegisterModules(moduleTypes);
CreateModules(moduleTypes);
_modules.EnsureKernelModuleToBeFirst();
_modules.EnsureLeadershipToBeFirst();
_modules.EnsureStartupModuleToBeLast();
SetDependencies();
......
......@@ -5,21 +5,8 @@
/// </summary>
public interface IObjectMapper
{
/// <summary>
/// Converts an object to another. Creates a new object of <see cref="TDestination"/>.
/// </summary>
/// <typeparam name="TDestination">Type of the destination object</typeparam>
/// <param name="source">Source object</param>
TDestination Map<TDestination>(object source);
/// <summary>
/// Execute a mapping from the source object to the existing destination object
/// </summary>
/// <typeparam name="TSource">Source type</typeparam>
/// <typeparam name="TDestination">Destination type</typeparam>
/// <param name="source">Source object</param>
/// <param name="destination">Destination object</param>
/// <returns>Returns the same <see cref="destination"/> object after mapping operation</returns>
TDestination Map<TSource, TDestination>(TSource source, TDestination destination);
}
}
\ No newline at end of file
......@@ -14,14 +14,20 @@
<RepositoryType>git</RepositoryType>
<PackageProjectUrl>https://github.com/Meowv/.netcoreplus</PackageProjectUrl>
<PackageIconUrl>https://avatars2.githubusercontent.com/u/13010050</PackageIconUrl>
<PackageLicenseUrl>https://raw.githubusercontent.com/Meowv/.netcoreplus/master/LICENSE</PackageLicenseUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageTags>plus;.netcoreplus;</PackageTags>
<PackageReleaseNotes>Plus</PackageReleaseNotes>
<Version>1.0.3.3</Version>
<Version>1.0.5</Version>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DocumentationFile>Plus.xml</DocumentationFile>
<NoWarn>1701;1702;1591</NoWarn>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DocumentationFile>Plus\Plus.xml</DocumentationFile>
<NoWarn>1701;1702;1591</NoWarn>
</PropertyGroup>
<ItemGroup>
......
......@@ -10,36 +10,15 @@ namespace Plus.Reflection
/// </summary>
public class AssemblyFinder : IAssemblyFinder
{
//private readonly IPlusModuleManager _moduleManager;
public static AssemblyFinder Instance
{
get;
private set;
}
public static AssemblyFinder Instance { get; private set; }
static AssemblyFinder()
{
Instance = new AssemblyFinder();
}
//public AssemblyFinder(IPlusModuleManager moduleManager)
//{
// _moduleManager = moduleManager;
//}
public List<Assembly> GetAllAssemblies()
{
//var assemblies = new List<Assembly>();
//foreach (var module in _moduleManager.Modules)
//{
// assemblies.Add(module.Assembly);
// assemblies.AddRange(module.Instance.GetAdditionalAssemblies());
//}
//return assemblies.Distinct().ToList();
return AppDomain.CurrentDomain.GetAssemblies().ToList();
}
}
......
......@@ -123,14 +123,13 @@ namespace Plus.Reflection
}
/// <summary>
/// Tries to gets an of attribute defined for a class member and it's declaring type including inherited attributes.
/// Returns default value if it's not declared at all.
///
/// </summary>
/// <typeparam name="TAttribute">Type of the attribute</typeparam>
/// <param name="memberInfo">MemberInfo</param>
/// <param name="defaultValue">Default value (null as default)</param>
/// <param name="inherit">Inherit attribute from base classes</param>
public static TAttribute GetSingleAttributeOfMemberOrDeclaringTypeOrDefault<TAttribute>(MemberInfo memberInfo, TAttribute defaultValue = default, bool inherit = true)
/// <typeparam name="TAttribute"></typeparam>
/// <param name="memberInfo"></param>
/// <param name="defaultValue"></param>
/// <returns></returns>
public static TAttribute GetSingleAttributeOfMemberOrDeclaringTypeOrDefault<TAttribute>(MemberInfo memberInfo, TAttribute defaultValue = default)
where TAttribute : class
{
return memberInfo.GetCustomAttributes(true).OfType<TAttribute>().FirstOrDefault()
......@@ -146,7 +145,7 @@ namespace Plus.Reflection
/// <param name="memberInfo">MemberInfo</param>
/// <param name="defaultValue">Default value (null as default)</param>
/// <param name="inherit">Inherit attribute from base classes</param>
public static TAttribute GetSingleAttributeOrDefault<TAttribute>(MemberInfo memberInfo, TAttribute defaultValue = default(TAttribute), bool inherit = true)
public static TAttribute GetSingleAttributeOrDefault<TAttribute>(MemberInfo memberInfo, TAttribute defaultValue = default, bool inherit = true)
where TAttribute : Attribute
{
//Get attribute on the member
......
......@@ -60,7 +60,7 @@ namespace Plus.Runtime.Caching
var value = await cache.GetAsync(key.ToString(), async (keyAsString) =>
{
var v = await factory(key);
return v;
return (object)v;
});
return (TValue)value;
......@@ -73,7 +73,7 @@ namespace Plus.Runtime.Caching
return cache.GetAsync(key.ToString(), async (keyAsString) =>
{
var v = await factory(key);
return v;
return (object)v;
});
});
var values = await Task.WhenAll(tasks);
......
using System;
namespace Plus.Runtime.Caching
{
[AttributeUsage(AttributeTargets.Method)]
public class CacheKeyAttribute : Attribute
{
public string Name { get; private set; }
public string Format { get; private set; }
public string Description { get; private set; }
public CacheKeyAttribute(string name, string description)
: this(name, "", description)
{
}
public CacheKeyAttribute(string name, string format, string description)
{
Name = name;
Format = format;
Description = description;
}
public string GetLocalizedKey(params object[] args)
{
string text = Name;
if (!string.IsNullOrEmpty(Format))
{
text = text + "[" + Format;
int num = 0;
foreach (object obj in args)
{
text = text.Replace("{" + num + "}", (obj != null) ? obj.ToString() : "");
num++;
}
text += "]";
}
return text;
}
}
}
\ No newline at end of file
using System;
namespace Plus.Runtime.Caching
{
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
public class CachingAttribute : Attribute
{
public string CacheManagerProviderServiceName { get; set; }
public CachingBehavior Behavior { get; set; }
public string[] MethodNames { get; set; }
public CachingAttribute()
: this("", CachingBehavior.Get, (string[])null)
{
}
public CachingAttribute(string cacheManagerProviderServiceName, CachingBehavior behavior)
: this(cacheManagerProviderServiceName, behavior, (string[])null)
{
}
public CachingAttribute(string cacheManagerProviderServiceName, CachingBehavior behavior, params string[] methodNames)
{
Behavior = behavior;
CacheManagerProviderServiceName = cacheManagerProviderServiceName;
MethodNames = methodNames;
}
}
}
\ No newline at end of file
namespace Plus.Runtime.Caching
{
public enum CachingBehavior
{
Get,
Set,
Remove
}
}
\ No newline at end of file
using System.Reflection;
namespace Plus.Runtime.Caching
{
public class CachingHelper
{
public static bool HasCachingAttribute(MemberInfo methodInfo)
{
return methodInfo.IsDefined(typeof(CachingAttribute), inherit: true);
}
}
}
\ No newline at end of file
......@@ -10,12 +10,12 @@ namespace Plus.Runtime.Caching
{
public static TValue Get<TKey, TValue>(this ITypedCache<TKey, TValue> cache, TKey key, Func<TValue> factory)
{
return cache.Get(key, k => factory());
return cache.Get(key, (TKey k) => factory());
}
public static Task<TValue> GetAsync<TKey, TValue>(this ITypedCache<TKey, TValue> cache, TKey key, Func<Task<TValue>> factory)
{
return cache.GetAsync(key, k => factory());
return cache.GetAsync(key, (TKey k) => factory());
}
}
}
\ No newline at end of file
......@@ -6,17 +6,9 @@ namespace Plus.Services
{
public abstract class ApplicationServiceBase : IApplicationService, ITransientDependency
{
public ILogger Logger
{
protected get;
set;
}
public ILogger Logger { protected get; set; }
public IEventPublisher EventPublisher
{
protected get;
set;
}
public IEventPublisher EventPublisher { protected get; set; }
protected ApplicationServiceBase()
{
......
using Plus.Domain.Entities.Auditing;
using System;
namespace Plus.Services.Dto
{
[Serializable]
public abstract class AuditedEntityDto : AuditedEntityDto<int>
{
}
[Serializable]
public abstract class AuditedEntityDto<TPrimaryKey> : CreationAuditedEntityDto<TPrimaryKey>, IAudited, ICreationAudited, IHasCreationTime, IModificationAudited, IHasModificationTime
{
public DateTime? LastModificationTime { get; set; }
public long? LastModifierUserId { get; set; }
}
}
\ No newline at end of file
using System;
namespace Plus.Services.Dto
{
[Serializable]
public class ComboboxItemDto : IDto
{
public string Value { get; set; }
public string DisplayText { get; set; }
public bool IsSelected { get; set; }
public ComboboxItemDto()
{
}
public ComboboxItemDto(string value, string displayText)
{
Value = value;
DisplayText = displayText;
}
}
}
\ No newline at end of file
using Plus.Domain.Entities.Auditing;
using System;
namespace Plus.Services.Dto
{
[Serializable]
public abstract class CreationAuditedEntityDto : CreationAuditedEntityDto<int>
{
}
[Serializable]
public abstract class CreationAuditedEntityDto<TPrimaryKey> : EntityDto<TPrimaryKey>, ICreationAudited, IHasCreationTime
{
public DateTime CreationTime { get; set; }
public long? CreatorUserId { get; set; }
protected CreationAuditedEntityDto()
{
CreationTime = DateTime.Now;
}
}
}
\ No newline at end of file
using System;
namespace Plus.Services.Dto
{
[Serializable]
public class EntityRequestInput<TPrimaryKey> : EntityDto<TPrimaryKey>, IInputDto, IDto
{
public EntityRequestInput()
{
}
public EntityRequestInput(TPrimaryKey id)
: base(id)
{
}
}
}
\ No newline at end of file
using System;
namespace Plus.Services.Dto
{
[Serializable]
public class EntityResultOutput : EntityResultOutput<int>, IEntityDto, IEntityDto<int>, IDto
{
public EntityResultOutput()
{
}
public EntityResultOutput(int id)
: base(id)
{
}
}
[Serializable]
public class EntityResultOutput<TPrimaryKey> : EntityDto<TPrimaryKey>, IOutputDto, IDto
{
public EntityResultOutput()
{
}
public EntityResultOutput(TPrimaryKey id)
: base(id)
{
}
}
}
\ No newline at end of file
using Plus.Domain.Entities;
using Plus.Domain.Entities.Auditing;
using System;
namespace Plus.Services.Dto
{
[Serializable]
public abstract class FullAuditedEntityDto : FullAuditedEntityDto<int>
{
}
[Serializable]
public abstract class FullAuditedEntityDto<TPrimaryKey> : AuditedEntityDto<TPrimaryKey>, IFullAudited, IAudited, ICreationAudited, IHasCreationTime, IModificationAudited, IHasModificationTime, IDeletionAudited, IHasDeletionTime, ISoftDelete
{
public bool IsDeleted { get; set; }
public long? DeleterUserId { get; set; }
public DateTime? DeletionTime { get; set; }
}
}
\ No newline at end of file
namespace Plus.Services.Dto
{
public interface IDto
{
}
}
\ No newline at end of file
namespace Plus.Services.Dto
{
public interface IInputDto : IDto
{
}
}
\ No newline at end of file
namespace Plus.Services.Dto
{
public interface IOutputDto : IDto
{
}
}
\ No newline at end of file
namespace Plus.Services.Dto
{
public class IdInput : IdInput<int>
{
public IdInput()
{
}
public IdInput(int id)
: base(id)
{
}
}
public class IdInput<TId> : IInputDto, IDto
{
public TId Id { get; set; }
public IdInput()
{
}
public IdInput(TId id)
{
Id = id;
}
}
}
\ No newline at end of file
namespace Plus.Services.Dto
{
public class NullableIdInput : NullableIdInput<int>
{
public NullableIdInput()
{
}
public NullableIdInput(int? id)
: base(id)
{
}
}
public class NullableIdInput<TId> : IInputDto, IDto where TId : struct
{
public TId? Id { get; set; }
public NullableIdInput()
{
}
public NullableIdInput(TId? id)
{
Id = id;
}
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
namespace Plus.Services.Dto
{
[Serializable]
public class PagedResultOutput<T> : PagedResultDto<T>, IOutputDto, IDto
{
public PagedResultOutput()
{
}
public PagedResultOutput(int totalCount, IReadOnlyList<T> items)
: base(totalCount, items)
{
}
}
}
\ No newline at end of file
namespace Plus.Services.Dto
{
public class TypeDto<T> : IDto
{
public T Value { get; set; }
}
}
\ 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