using System; using System.Collections; namespace EcsRx.Infrastructure.Dependencies { /// /// This represents a cross platform way of managing dependencies. /// /// It is up to the consumer to implement the actual underlying handler /// for unity it will be done out of the box with Zenject, but in other /// platforms like Monogame, Godot etc it would be up to the consumer /// to define what DI system they want to use and create an implementation /// themselves. /// public interface IDependencyContainer : IDisposable { /// /// This exposes the underlying DI container, but any calls to this directly /// will not be cross platform, so be weary if you need it or not. /// object NativeContainer { get; } /// /// Binds from one type to another, generally from an interface to a concrete class /// /// Type to bind from /// Type to bind to /// Optional configuration void Bind(Type fromType, Type toType, BindingConfiguration configuration = null); /// /// Bind the type to itself/instance/method, useful for concrete class bindings /// /// The type to bind /// Optional configuration /// This is useful for self binding concrete classes void Bind(Type type, BindingConfiguration configuration = null); /// /// Checks to see if a binding exists in the container /// /// Type to check against /// Optional name of the binding /// bool HasBinding(Type type, string name = null); /// /// Gets an instance of a given type from the underlying DI container /// /// Type of the object you want /// Optional name of the binding /// An instance of the given type object Resolve(Type type, string name = null); /// /// Unbinds a type from the container /// /// The type to unbind void Unbind(Type type); /// /// Unbinds a type from the container /// /// The fromType to unbind /// The toType to unbind void UnbindId(Type fromType, Type toType, string name = null); /// /// Gets an enumerable of a given type from the underlying DI container /// /// Type to resolve /// All matching instances of that type within the underlying container IEnumerable ResolveAll(Type type); /// /// Loads the given modules bindings into the underlying di container /// /// Type of module to load void LoadModule(IDependencyModule module); IEnumerator InitializeModules(); void UnloadModules(); } }