Beispiel #1
0
 public void TryRegister(DependencyCollection collection, Type implementation)
 {
     if (ECSUtils.TryGetImplementedSystemInterfaces(implementation, out var contracts))
     {
         collection.AddDependency(contracts, implementation, _lifetime);
     }
 }
Beispiel #2
0
        public static DependencyCollection AddSystem <TSystem>(
            this DependencyCollection dependencies,
            DependencyLifetime lifetime = DependencyLifetime.Singleton)
        {
            var implementation = typeof(TSystem);

            if (!ECSUtils.TryGetImplementedSystemInterfaces(implementation, out var contracts))
            {
                throw Error.InvalidOperation(
                          $"Type '{ReflectionUtils.GetName<TSystem>()}' isn't implemented system interfaces");
            }

            dependencies.AddDependency(contracts, implementation, lifetime);
            return(dependencies);
        }