protected static void RegisterFactory(IUxmlFactory factory)
 {
     if (factories.TryGetValue(factory.uxmlQualifiedName, out var factoryList))
     {
         foreach (var f in factoryList)
         {
             if (f.GetType() == factory.GetType())
             {
                 throw new ArgumentException($"A factory for the type {factory.GetType().FullName} was already registered");
             }
         }
         factoryList.Add(factory);
     }
     else
     {
         factoryList = new List <IUxmlFactory>();
         factoryList.Add(factory);
         factories.Add(factory.uxmlQualifiedName, factoryList);
         Type uxmlType = factory.uxmlType;
         var  attr     = uxmlType?.GetCustomAttribute <MovedFromAttribute>(false);
         if (attr != null && typeof(VisualElement).IsAssignableFrom(uxmlType))
         {
             string movedTypeName = GetMovedUIControlTypeName(uxmlType, attr);
             if (string.IsNullOrEmpty(movedTypeName) == false)
             {
                 s_MovedTypesFactories.Add(movedTypeName, factoryList);
             }
         }
     }
 }
Ejemplo n.º 2
0
 protected static void RegisterFactory(IUxmlFactory factory)
 {
     if (factories.TryGetValue(factory.uxmlQualifiedName, out var factoryList))
     {
         foreach (var f in factoryList)
         {
             if (f.GetType() == factory.GetType())
             {
                 throw new ArgumentException($"A factory for the type {factory.GetType().FullName} was already registered");
             }
         }
         factoryList.Add(factory);
     }
     else
     {
         factoryList = new List <IUxmlFactory>();
         factoryList.Add(factory);
         factories.Add(factory.uxmlQualifiedName, factoryList);
     }
 }
Ejemplo n.º 3
0
        public static UxmlTraits GetTraits(this IUxmlFactory factory)
        {
            var traitsField = factory.GetType()
                              .GetField("m_Traits", BindingFlags.Instance | BindingFlags.NonPublic);

            if (traitsField == null)
            {
                Debug.LogError(s_TraitsNotFoundMessage);
                return(null);
            }

            return(traitsField.GetValue(factory) as UxmlTraits);
        }
Ejemplo n.º 4
0
        internal static void RegisterFactory(IUxmlFactory factory)
        {
            List <IUxmlFactory> list;
            bool flag = VisualElementFactoryRegistry.factories.TryGetValue(factory.uxmlQualifiedName, out list);

            if (flag)
            {
                foreach (IUxmlFactory current in list)
                {
                    bool flag2 = current.GetType() == factory.GetType();
                    if (flag2)
                    {
                        throw new ArgumentException("A factory for the type " + factory.GetType().FullName + " was already registered");
                    }
                }
                list.Add(factory);
            }
            else
            {
                list = new List <IUxmlFactory>();
                list.Add(factory);
                VisualElementFactoryRegistry.factories.Add(factory.uxmlQualifiedName, list);
            }
        }
Ejemplo n.º 5
0
        internal static void RegisterFactory(IUxmlFactory factory)
        {
            List <IUxmlFactory> factoryList;

            if (factories.TryGetValue(factory.uxmlQualifiedName, out factoryList))
            {
                foreach (IUxmlFactory f in factoryList)
                {
                    if (f.GetType() == factory.GetType())
                    {
                        throw new ArgumentException("A factory of this type was already registered");
                    }
                }
                factoryList.Add(factory);
            }
            else
            {
                factoryList = new List <IUxmlFactory>();
                factoryList.Add(factory);
                factories.Add(factory.uxmlQualifiedName, factoryList);
            }
        }