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); } } } }
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); } }
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); }
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); } }
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); } }