This commit is contained in:
CortexCore
2024-03-19 20:16:48 +08:00
parent 0da2773ea6
commit c8f8c3c8df
112 changed files with 682250 additions and 8960 deletions

View File

@@ -66,16 +66,31 @@ namespace BITKit.Modification
public class ModifyManager : IModifyManager
{
public virtual IDictionary<IModifyElement, object> Modifies { get; } =new Dictionary<IModifyElement,object>();
public virtual IDictionary<IModifyElement, object> Modified => new Dictionary<IModifyElement, object>(Modifies.Where(x=>x.Value is not null));
public virtual IDictionary<IModifyElement, object> Modified { get; } = new Dictionary<IModifyElement, object>();
public virtual void Add(IModifyElement modify, object obj)
{
if(Modified.ContainsKey(modify))
throw new NotSupportModifyException(new[]{modify});
var list = new List<IModifyElement>();
list.AddRange(Modified.Keys);
list.Add(modify);
if(list.All(x=>x.Require?.Any(y=>list.Contains(y)) is false))
throw new NotRequireModifyException(list.ToArray());
foreach (var x in list)
{
if(x.Require is null or {Length:0})continue;
foreach (var _x in x.Require)
{
if (list.Contains(_x) is false)
throw new NotRequireModifyException(x.Require);
}
}
//你知道怎么做,帮我做一下
var incompatible = list.Where(x=>x.Incompatible is not null).SelectMany(x => x.Incompatible).ToArray();
if(MathE.Contains(incompatible,list))