Dependency Injection - This document is dependent on the following: - library_structure.txt - Dependency Injection Requirements: - The dependent cannot place a requirement on the origin of the service. - Reasoning: - Ensures services can come from any origin (file system, network, etc.). - The dependent cannot place a requirement on the time the service is supplied. - Reasoning: - Ensures that services can have their dependencies fulfilled when they become ready. - The dependent cannot place a requirement on the thread the service is supplied on. - Reasoning: - Ensures that all threads can be used equally which enhances application performance. - Services must not be searched for. - Reasoning: - Prevents the search for services which enhances efficiency. - Unique IDs do not have to be created and stored, further enhancing efficiency. - Services must not be created until they needed. - Reasoning: Reduces memory consumption - Services must be replaceable. - Reasoning: Allows applications to be enhanced with additional functionality (mods, plugins, etc.) - Dependency Injection Solution: - Static IValue and IEventEnumerables types hold services. - Looks like this: // Static service classes like this are held in "Config" libraries. static class Services { public static IValue UserName { get; private set; } } - Config libraries hold the static services classes. - Config libraries will access these instances directly. No other library will access these instances.