chore:目录重构
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Infrastructure.Ddd.Entities
|
||||
{
|
||||
public class AggregateRoot : IEntity, IAggregateRoot
|
||||
{
|
||||
}
|
||||
public class AggregateRoot<TKey> : Entity<TKey>, IEntity<TKey>
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Principal;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Infrastructure.Ddd.Entities
|
||||
{
|
||||
[Serializable]
|
||||
public abstract class Entity : IEntity
|
||||
{
|
||||
protected Entity()
|
||||
{
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "[ENTITY: " + GetType().Name + "] Keys = " + GetKeys();
|
||||
}
|
||||
|
||||
public abstract object[] GetKeys();
|
||||
|
||||
//实体比较简化
|
||||
//public bool EntityEquals(IEntity other)
|
||||
//{
|
||||
// return this.GetKeys().Equals(other.GetKeys());
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public abstract class Entity<TKey> : Entity, IEntity<TKey>, IEntity
|
||||
{
|
||||
public virtual TKey Id { get; set; }
|
||||
|
||||
protected Entity()
|
||||
{
|
||||
}
|
||||
|
||||
protected Entity(TKey id)
|
||||
{
|
||||
Id = id;
|
||||
}
|
||||
|
||||
public override object[] GetKeys()
|
||||
{
|
||||
return new object[1] { Id };
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"[ENTITY: {GetType().Name}] Id = {Id}";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using Microsoft.AspNetCore.DataProtection.KeyManagement;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Infrastructure.Ddd.Entities
|
||||
{
|
||||
public interface IAggregateRoot : IEntity
|
||||
{
|
||||
}
|
||||
public interface IAggregateRoot<TKey> : IEntity<TKey>
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Infrastructure.Ddd.Entities
|
||||
{
|
||||
public interface IEntity
|
||||
{
|
||||
//
|
||||
// 摘要:
|
||||
// Returns an array of ordered keys for this entity.
|
||||
|
||||
}
|
||||
public interface IEntity<TKey> : IEntity
|
||||
{
|
||||
//
|
||||
// 摘要:
|
||||
// Unique identifier for this entity.
|
||||
TKey Id { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user