Beispiel #1
0
 private Registry()
 {
     if (ComponentTypeUtility.IsManagedComponentType(typeof(TComponent)))
     {
         mode = RegistryMode.Managed;
     }
     else
     {
         mode = RegistryMode.Native;
     }
 }
Beispiel #2
0
        public static IEnumerable <IRegistry> GetRegistries(IComponent component)
        {
            if (component == null)
            {
                throw new ArgumentNullException(nameof(component));
            }

            foreach (var componentType in ComponentTypeUtility.GetManagedComponentTypes(component.GetType()))
            {
                yield return(GetRegistry(componentType));
            }
        }
Beispiel #3
0
        private static IEnumerable <Type> FetchRequiredComponentTypes(Type componentType)
        {
            if (!typeof(Component).IsAssignableFrom(componentType))
            {
                throw new ArgumentException("Component type is not derived from component.", nameof(componentType));
            }

            foreach (var type in ComponentTypeUtility.GetManagedComponentTypes(componentType))
            {
                foreach (var attribute in type.GetCustomAttributes(typeof(RuntimeRequireComponentAttribute), true).Cast <RuntimeRequireComponentAttribute>())
                {
                    var requiredComponentType = attribute.componentType;

                    if (!typeof(Component).IsAssignableFrom(requiredComponentType))
                    {
                        Debug.LogWarning($"Required component type '{requiredComponentType}' is not derived from component, ignoring.");
                        continue;
                    }

                    yield return(requiredComponentType);
                }
            }
        }