mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-30 05:08:48 +00:00
增加MainComponent的order设置执行优先级
This commit is contained in:
@@ -7,17 +7,20 @@ namespace XCharts.Runtime
|
|||||||
{
|
{
|
||||||
public readonly Type handler;
|
public readonly Type handler;
|
||||||
public readonly bool allowMultiple = true;
|
public readonly bool allowMultiple = true;
|
||||||
|
public readonly int order = 3;
|
||||||
|
|
||||||
public ComponentHandlerAttribute(Type handler)
|
public ComponentHandlerAttribute(Type handler, int order = 3)
|
||||||
{
|
{
|
||||||
this.handler = handler;
|
this.handler = handler;
|
||||||
this.allowMultiple = true;
|
this.allowMultiple = true;
|
||||||
|
this.order = order;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ComponentHandlerAttribute(Type handler, bool allowMultiple)
|
public ComponentHandlerAttribute(Type handler, bool allowMultiple, int order = 3)
|
||||||
{
|
{
|
||||||
this.handler = handler;
|
this.handler = handler;
|
||||||
this.allowMultiple = allowMultiple;
|
this.allowMultiple = allowMultiple;
|
||||||
|
this.order = order;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -123,9 +123,11 @@ namespace XCharts.Runtime
|
|||||||
var handler = (MainComponentHandler)Activator.CreateInstance(attrubte.handler);
|
var handler = (MainComponentHandler)Activator.CreateInstance(attrubte.handler);
|
||||||
handler.attribute = attrubte;
|
handler.attribute = attrubte;
|
||||||
handler.chart = this;
|
handler.chart = this;
|
||||||
|
handler.order = attrubte.order;
|
||||||
handler.SetComponent(component);
|
handler.SetComponent(component);
|
||||||
component.handler = handler;
|
component.handler = handler;
|
||||||
m_ComponentHandlers.Add(handler);
|
m_ComponentHandlers.Add(handler);
|
||||||
|
m_ComponentHandlers.Sort((a, b) => { return a.order.CompareTo(b.order); });
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool RemoveChartComponent<T>(int index = 0)
|
public bool RemoveChartComponent<T>(int index = 0)
|
||||||
|
|||||||
@@ -88,6 +88,7 @@ namespace XCharts.Runtime
|
|||||||
|
|
||||||
public abstract class MainComponentHandler
|
public abstract class MainComponentHandler
|
||||||
{
|
{
|
||||||
|
public int order { get; internal set; }
|
||||||
public BaseChart chart { get; internal set; }
|
public BaseChart chart { get; internal set; }
|
||||||
public ComponentHandlerAttribute attribute { get; internal set; }
|
public ComponentHandlerAttribute attribute { get; internal set; }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user