{"id":13664410,"url":"https://github.com/beatthat/services","last_synced_at":"2026-04-12T16:03:24.705Z","repository":{"id":144017211,"uuid":"100649736","full_name":"beatthat/services","owner":"beatthat","description":"A lightweight Inversion of Control container that supports dependency injection and service registration, driven by attributes or code","archived":false,"fork":false,"pushed_at":"2020-10-29T04:41:02.000Z","size":344,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-17T09:45:10.789Z","etag":null,"topics":["dependency-injection","ioc","ioc-container","package","unity","unity3d"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/beatthat.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-08-17T22:21:49.000Z","updated_at":"2020-10-29T04:41:00.000Z","dependencies_parsed_at":null,"dependency_job_id":"7fe5d224-7e6e-4a52-97d7-29642d2a360d","html_url":"https://github.com/beatthat/services","commit_stats":null,"previous_names":[],"tags_count":32,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beatthat%2Fservices","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beatthat%2Fservices/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beatthat%2Fservices/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beatthat%2Fservices/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/beatthat","download_url":"https://codeload.github.com/beatthat/services/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254304490,"owners_count":22048412,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dependency-injection","ioc","ioc-container","package","unity","unity3d"],"created_at":"2024-08-02T05:02:55.641Z","updated_at":"2025-10-07T22:15:55.256Z","avatar_url":"https://github.com/beatthat.png","language":"C#","funding_links":[],"categories":["C\\#"],"sub_categories":[],"readme":"# \u003ca name=\"readme\"\u003e\u003c/a\u003eservices\n\nEnables you register and then locate global services.\n\n## Install\n\nFrom your unity project folder:\n\n    npm init\n    npm install TEMPLATE --save\n    echo Assets/packages \u003e\u003e .gitignore\n    echo Assets/packages.meta \u003e\u003e .gitignore\n\nThe package and all its dependencies will be installed under Assets/Plugins/packages.\n\nIn case it helps, a quick video of the above: https://youtu.be/Uss_yOiLNw8\n\n## USAGE\n\nFirst, any service you want to use must be registered.\n\n#### Register Services to make them available for and lookup.\n\nThe simplest way to register a service is with the [RegisterService] attribute\n\n```c#\nusing BeatThat.Services;\n[RegisterService]public class Foo {}\n\npublic class UsesLookup\n{\n    void MyMethod()\n    {\n        // any service that is registered\n        // can be looked up directly\n        var foo = Services.Require\u003cFoo\u003e();\n    }\n}\n```\n\n#### Use interfaces for less tight coupling and easier refactoring\n\nIt's generally a good idea to use narrow interfaces for services to avoid tight coupling. More concretely, accessing services as interfaces makes it easier to swap the implementation, and, assuming the service interfaces are narrowly defined, also makes it much easier to understand at a glance what your service-dependent code really depends upon. This can be a big time saver when you're refactoring and using tools like 'Find References' to try to go through all the classes that depend on some service.\n\nThe [RegisterService] attribute provides a couple of features to make it easier to use interfaces.\n\n###### Interfaces defined directly on the service class are registered by default\n\n```c#\nusing BeatThat.Services;\npublic interface Bar {}\n\n[RegisterService]public class Foo : Bar {}\n\npublic class UsesBar\n{\n    void GetBar()\n    {\n      Bar bar = Services.Require\u003cBar\u003e(); // returns instance of Foo\n    }\n}\n````\n\n###### Use 'proxyInterfaces' to register interfaces further up the chain\n\n```c#\nusing BeatThat.Services;\npublic interface Bar {}\n\npublic class FooBase : Bar {}\n\n[RegisterService(\n    // interface Bar will not be auto registered\n    // because it is not defined directly on class Foo\n    proxyInterfaces: new System.Type[] { typeof(Bar) }\n)]\npublic class Foo : FooBase {}\n\npublic class UsesBar\n{\n  void GetBar()\n  {\n    Bar bar = Services.Require\u003cBar\u003e(); // returns instance of Foo\n  }\n}\n````\n\n###### Use 'interfaceRegistrationPolicy' to just register all interfaces\n```c#\nusing BeatThat.Services;\npublic interface Bar {}\n\npublic class FooBase : Bar {}\n\n[RegisterService(\n    // register all interfaces on class and parents\n    interfaceRegistrationPolicy: InterfaceRegistrationPolicy.RegisterInterfacesDeclaredOnTypeAndParents\n)]\npublic class Foo : FooBase {}\n\npublic class UsesBar : DependencyInjectedBehaviour\n{\n  void GetBar()\n  {\n    Bar bar = Services.Require\u003cBar\u003e(); // returns instance of Foo\n  }\n}\n````\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeatthat%2Fservices","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbeatthat%2Fservices","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeatthat%2Fservices/lists"}