TestPlayerBuildModifierAttribute.cs 770 B

12345678910111213141516171819202122232425
  1. using System;
  2. namespace UnityEditor.TestTools
  3. {
  4. [AttributeUsage(AttributeTargets.Assembly)]
  5. public class TestPlayerBuildModifierAttribute : Attribute
  6. {
  7. private Type m_Type;
  8. public TestPlayerBuildModifierAttribute(Type type)
  9. {
  10. var interfaceType = typeof(ITestPlayerBuildModifier);
  11. if (!interfaceType.IsAssignableFrom(type))
  12. {
  13. throw new ArgumentException(string.Format("Type provided to {0} does not implement {1}", this.GetType().Name, interfaceType.Name));
  14. }
  15. m_Type = type;
  16. }
  17. internal ITestPlayerBuildModifier ConstructModifier()
  18. {
  19. return Activator.CreateInstance(m_Type) as ITestPlayerBuildModifier;
  20. }
  21. }
  22. }