mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-25 18:30:14 +00:00
重构Component相关代码,调整API接口
This commit is contained in:
84
Runtime/Internal/Attributes/SerieComponentAttribute.cs
Normal file
84
Runtime/Internal/Attributes/SerieComponentAttribute.cs
Normal file
@@ -0,0 +1,84 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// The attribute for serie component.
|
||||
/// |可添加到Serie的组件。
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
|
||||
public sealed class SerieComponentAttribute : Attribute
|
||||
{
|
||||
public readonly List<Type> types = new List<Type>();
|
||||
|
||||
public SerieComponentAttribute()
|
||||
{ }
|
||||
public SerieComponentAttribute(Type type1)
|
||||
{
|
||||
AddType(type1);
|
||||
}
|
||||
public SerieComponentAttribute(Type type1, Type type2)
|
||||
{
|
||||
AddType(type1);
|
||||
AddType(type2);
|
||||
}
|
||||
public SerieComponentAttribute(Type type1, Type type2, Type type3)
|
||||
{
|
||||
AddType(type1);
|
||||
AddType(type2);
|
||||
AddType(type3);
|
||||
}
|
||||
public SerieComponentAttribute(Type type1, Type type2, Type type3, Type type4)
|
||||
{
|
||||
AddType(type1);
|
||||
AddType(type2);
|
||||
AddType(type3);
|
||||
AddType(type4);
|
||||
}
|
||||
public SerieComponentAttribute(Type type1, Type type2, Type type3, Type type4, Type type5)
|
||||
{
|
||||
AddType(type1);
|
||||
AddType(type2);
|
||||
AddType(type3);
|
||||
AddType(type4);
|
||||
AddType(type5);
|
||||
}
|
||||
public SerieComponentAttribute(Type type1, Type type2, Type type3, Type type4, Type type5, Type type6)
|
||||
{
|
||||
AddType(type1);
|
||||
AddType(type2);
|
||||
AddType(type3);
|
||||
AddType(type4);
|
||||
AddType(type5);
|
||||
AddType(type6);
|
||||
}
|
||||
public SerieComponentAttribute(Type type1, Type type2, Type type3, Type type4, Type type5, Type type6, Type type7)
|
||||
{
|
||||
AddType(type1);
|
||||
AddType(type2);
|
||||
AddType(type3);
|
||||
AddType(type4);
|
||||
AddType(type5);
|
||||
AddType(type6);
|
||||
AddType(type7);
|
||||
}
|
||||
|
||||
private void AddType(Type type)
|
||||
{
|
||||
if (!Serie.extraComponentMap.ContainsKey(type))
|
||||
throw new ArgumentException("Serie not support extra component:" + type);
|
||||
types.Add(type);
|
||||
}
|
||||
|
||||
public bool Contains<T>() where T : ISerieComponent
|
||||
{
|
||||
return Contains(typeof(T));
|
||||
}
|
||||
|
||||
public bool Contains(Type type)
|
||||
{
|
||||
return types.Contains(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user