157 lines
4.2 KiB
C#
157 lines
4.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using JD.Collections.Interfaces;
|
|
using JD.TeaBoxAddinSystem.Addins.Description.Conditions;
|
|
|
|
namespace JD.TeaBoxAddinSystem.Addins.Description
|
|
{
|
|
/// <summary>
|
|
/// Defines an <see cref="ExtensionNode"/> in an <see cref="ExtensionPoint"/>.
|
|
/// </summary>
|
|
public sealed class ExtensionNodeDescription : NodeDescription
|
|
{
|
|
#region Variables
|
|
|
|
private const string AnonymousId = "<anonymous>";
|
|
|
|
internal const string IdAttributeName = "id";
|
|
internal const string InsertAfterAttributeName = "insertafter";
|
|
internal const string InsertBeforeAttributeName = "insertbefore";
|
|
|
|
private readonly ExtensionNodeDescriptionCollection m_childNodes = new ExtensionNodeDescriptionCollection();
|
|
private readonly AddinObjectCollection<ConditionInfo> m_conditions = new AddinObjectCollection<ConditionInfo>();
|
|
|
|
#endregion
|
|
|
|
#region Constructor
|
|
|
|
/// <summary>
|
|
/// Constructor.
|
|
/// </summary>
|
|
/// <param name="name"></param>
|
|
public ExtensionNodeDescription(string name)
|
|
: base(name)
|
|
{
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Properties
|
|
|
|
/// <summary>
|
|
/// Child Nodes.
|
|
/// </summary>
|
|
public IKeyedList<string, ExtensionNodeDescription> ChildNodes
|
|
{
|
|
get
|
|
{
|
|
return m_childNodes;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Conditions that affect this node.
|
|
/// </summary>
|
|
public IList<ConditionInfo> Conditions
|
|
{
|
|
get
|
|
{
|
|
return m_conditions;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Id.
|
|
/// </summary>
|
|
public string Id
|
|
{
|
|
get
|
|
{
|
|
return Attributes[IdAttributeName];
|
|
}
|
|
set
|
|
{
|
|
Attributes[IdAttributeName] = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Id to display in error messages.
|
|
/// </summary>
|
|
internal string DisplayId
|
|
{
|
|
get
|
|
{
|
|
string id = Id;
|
|
if (!string.IsNullOrEmpty(id))
|
|
{
|
|
return id;
|
|
}
|
|
return AnonymousId;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets/Sets the extension node Ids (comma separated) that this node should be inserted after.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// This is no guarantee. If there is circular dependency between the nodes, this order will probably not be respected
|
|
/// </remarks>
|
|
public string InsertAfter
|
|
{
|
|
get
|
|
{
|
|
return Attributes[InsertAfterAttributeName];
|
|
}
|
|
set
|
|
{
|
|
Attributes[InsertAfterAttributeName] = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets/Sets the extension node Ids (comma separated) that this node should be inserted before.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// This is no guarantee. If there is circular dependency between the nodes, this order will probably not be respected
|
|
/// </remarks>
|
|
public string InsertBefore
|
|
{
|
|
get
|
|
{
|
|
return Attributes[InsertBeforeAttributeName];
|
|
}
|
|
set
|
|
{
|
|
Attributes[InsertBeforeAttributeName] = value;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Methods
|
|
|
|
/// <summary>
|
|
/// Overriden.
|
|
/// </summary>
|
|
/// <param name="e"></param>
|
|
internal override void OnModuleChanged(EventArgs e)
|
|
{
|
|
m_childNodes.Owner = Module;
|
|
m_conditions.Owner = Module;
|
|
base.OnModuleChanged(e);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Overriden.
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public override string ToString()
|
|
{
|
|
return
|
|
$"[ExtensionNodeDescription ({Name}): Id={(string.IsNullOrEmpty(Id) ? AnonymousId : Id)}, {ChildNodes.Count} child nodes, {Conditions.Count} conditions]";
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|