Geen omschrijving
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SerieConvertAttribute.cs 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using System;
  2. namespace XCharts.Runtime
  3. {
  4. /// <summary>
  5. /// The attribute for which serie types can be converted to.
  6. /// |可转化为哪些Serie类型。
  7. /// </summary>
  8. [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
  9. public sealed class SerieConvertAttribute : Attribute
  10. {
  11. public readonly Type type0;
  12. public readonly Type type1;
  13. public readonly Type type2;
  14. public readonly Type type3;
  15. public SerieConvertAttribute(Type serie)
  16. {
  17. type0 = serie;
  18. }
  19. public SerieConvertAttribute(Type serie, Type serie2)
  20. {
  21. type0 = serie;
  22. type1 = serie2;
  23. }
  24. public SerieConvertAttribute(Type serie, Type serie2, Type serie3)
  25. {
  26. type0 = serie;
  27. type1 = serie2;
  28. type2 = serie3;
  29. }
  30. public SerieConvertAttribute(Type serie, Type serie2, Type serie3, Type serie4)
  31. {
  32. type0 = serie;
  33. type1 = serie2;
  34. type2 = serie3;
  35. type3 = serie4;
  36. }
  37. public bool Contains<T>() where T : Serie
  38. {
  39. return Contains(typeof(T));
  40. }
  41. public bool Contains(Type type)
  42. {
  43. return (type == type0 || type == type1 || type == type2 || type == type3);
  44. }
  45. }
  46. }