定义容器节点辅助方法

This commit is contained in:
zengwenjie
2025-09-16 10:44:53 +08:00
parent 35447c65d9
commit da4a17be40
11 changed files with 44 additions and 57 deletions

View File

@@ -56,22 +56,6 @@ namespace Deedy.Activity
OnPropertyChanged(propertyName); OnPropertyChanged(propertyName);
return true; return true;
} }
public void InsertToFore(IElement element)
{
throw new NotImplementedException();
}
public void InsertAtRear(IElement element)
{
throw new NotImplementedException();
}
public void SwapIndex(IElement element)
{
throw new NotImplementedException();
}
public void ReadyToWorking(IElement? element = null, Output? output = null) public void ReadyToWorking(IElement? element = null, Output? output = null)
{ {
throw new NotImplementedException(); throw new NotImplementedException();

View File

@@ -8,10 +8,10 @@ using System.Threading.Tasks;
namespace Deedy.Activity namespace Deedy.Activity
{ {
public class DeedyElementCollection : ObservableCollection<IElement> public class ElementCollection : ObservableCollection<IElement>
{ {
public DeedyElementCollection() : this(false) { } public ElementCollection() : this(false) { }
public DeedyElementCollection(bool needDistinct = false) public ElementCollection(bool needDistinct = false)
{ {
this._needDistinct = needDistinct; this._needDistinct = needDistinct;
} }

View File

@@ -9,6 +9,6 @@ namespace Deedy.Activity
{ {
public interface ICombinedElement : IElement public interface ICombinedElement : IElement
{ {
public DeedyElementCollection Elements { get; set; } public ElementCollection Elements { get; set; }
} }
} }

View File

@@ -8,7 +8,13 @@ namespace Deedy.Activity
{ {
public interface IContainerElement : ICombinedElement public interface IContainerElement : ICombinedElement
{ {
public void Append(IElement element); public void Append(IElement element) => this.Elements.Add(element);
public void Remove(IElement element); public void Remove(IElement element) => this.Elements.Remove(element);
public void Insert(IElement element, uint index)
{
if (element == null) return;
if (index < this.Elements.Count) this.Elements.Insert((int)index, element);
if (index >= this.Elements.Count) this.Elements.Add(element);
}
} }
} }

View File

@@ -10,6 +10,6 @@ namespace Deedy.Activity
{ {
public CombinedLogical() { } public CombinedLogical() { }
public DeedyElementCollection Elements { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } public ElementCollection Elements { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
} }
} }

View File

@@ -10,16 +10,6 @@ namespace Deedy.Activity
{ {
public ContainerLogical() { } public ContainerLogical() { }
public DeedyElementCollection Elements { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } public ElementCollection Elements { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public void Append(IElement deedyElement)
{
throw new NotImplementedException();
}
public void Remove(IElement deedyElement)
{
throw new NotImplementedException();
}
} }
} }

View File

@@ -10,6 +10,6 @@ namespace Deedy.Activity
{ {
public CombinedFunction() { } public CombinedFunction() { }
public DeedyElementCollection Elements { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } public ElementCollection Elements { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
} }
} }

View File

@@ -10,7 +10,7 @@ namespace Deedy.Activity
{ {
public ContainerFunction() { } public ContainerFunction() { }
public DeedyElementCollection Elements { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } public ElementCollection Elements { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public void Append(IElement deedyElement) public void Append(IElement deedyElement)
{ {

View File

@@ -53,9 +53,35 @@ namespace Deedy.Activity
/// </summary> /// </summary>
/// <param name="element">需要构建参数映射表的Element节点</param> /// <param name="element">需要构建参数映射表的Element节点</param>
/// <param name="output">消息输出器</param> /// <param name="output">消息输出器</param>
internal static void BuildParamMapping(this IElement element, Output? output = null) public static void BuildParamMapping(this IElement element, Output? output = null)
{ {
// //
} }
/// <summary>
/// 将一个元素插入到当前节点前方「前提:当前节点的父级必须是可变容器节点」
/// </summary>
/// <param name="element">当前节点</param>
/// <param name="insertion">待插入的节点</param>
public static void InsertElementToFore(this IElement element, IElement insertion)
{
//
}
/// <summary>
/// 将一个元素插入到当前节点后方「前提:当前节点的父级必须是可变容器节点」
/// </summary>
/// <param name="element">当前节点</param>
/// <param name="insertion">待插入的节点</param>
public static void InsertElementAtRear(this IElement element, IElement insertion)
{
//
}
/// <summary>
/// 将当前节点从父节点中移除
/// </summary>
/// <param name="element">要移除的元素</param>
public static void RemoveFromParent(this IElement element)
{
if (element != null && element.ParentElement is IContainerElement container) container.Remove(element);
}
} }
} }

View File

@@ -19,7 +19,7 @@ namespace Deedy.Activity
public IElement RootElement => (this.ParentElement == null) ? this : this.ParentElement.RootElement; public IElement RootElement => (this.ParentElement == null) ? this : this.ParentElement.RootElement;
public DeedyElementCollection Elements { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } public ElementCollection Elements { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public Runtime Runtime => throw new NotImplementedException(); public Runtime Runtime => throw new NotImplementedException();
@@ -68,22 +68,6 @@ namespace Deedy.Activity
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
public void InsertToFore(IElement element)
{
throw new NotImplementedException();
}
public void InsertAtRear(IElement element)
{
throw new NotImplementedException();
}
public void SwapIndex(IElement element)
{
throw new NotImplementedException();
}
public void ReadyToWorking(IElement? element = null, Output? output = null) public void ReadyToWorking(IElement? element = null, Output? output = null)
{ {
throw new NotImplementedException(); throw new NotImplementedException();

View File

@@ -19,9 +19,6 @@ namespace Deedy.Activity
public int DepthLevel { get; } public int DepthLevel { get; }
public IElement? ParentElement { get; } public IElement? ParentElement { get; }
public IElement RootElement { get; } public IElement RootElement { get; }
public void InsertToFore(IElement element);
public void InsertAtRear(IElement element);
public void SwapIndex(IElement element);
/// <summary> /// <summary>
/// 将当前节点链接到一个节点上 /// 将当前节点链接到一个节点上
/// </summary> /// </summary>