Пример #1
0
        public static void ResolveDependencies(object instance)
        {
            var dependencies = DependencyAttribute.GetUnresolvedDependencies(instance.GetType(), instance);

            foreach (var dependency in dependencies)
            {
                if (DependencyRegistry.Registry.ContainsKey(dependency.FieldType))
                {
                    dependency.SetValue(instance, DependencyRegistry.Registry[dependency.FieldType].instance);
                }
                else
                {
                    Debug.LogError($"Failed to resolve dependency of type {dependency.FieldType} for {instance.GetType()}");
                }
            }
        }
Пример #2
0
 private List <FieldInfo> GetDependencies()
 {
     return(DependencyAttribute.GetUnresolvedDependencies(_implementationType, instance));
 }