예제 #1
0
 private Registry()
 {
     if (ComponentTypeUtility.IsManagedComponentType(typeof(TComponent)))
     {
         mode = RegistryMode.Managed;
     }
     else
     {
         mode = RegistryMode.Native;
     }
 }
예제 #2
0
파일: Registries.cs 프로젝트: r2d2m/gocs
        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));
            }
        }
예제 #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);
                }
            }
        }