{"id":16208001,"url":"https://github.com/coryleach/unityserviceprovider","last_synced_at":"2025-08-20T15:34:14.436Z","repository":{"id":138391180,"uuid":"222583546","full_name":"coryleach/UnityServiceProvider","owner":"coryleach","description":"Simplified service provider implementation minus the fancy stuff","archived":false,"fork":false,"pushed_at":"2022-08-29T20:01:51.000Z","size":50,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-28T16:55:40.759Z","etag":null,"topics":["dependency-injection","package","service-provider","services","singleton","singleton-pattern","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":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/coryleach.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","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":"2019-11-19T01:45:07.000Z","updated_at":"2024-07-11T08:05:15.000Z","dependencies_parsed_at":"2023-04-30T11:00:40.495Z","dependency_job_id":null,"html_url":"https://github.com/coryleach/UnityServiceProvider","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coryleach%2FUnityServiceProvider","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coryleach%2FUnityServiceProvider/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coryleach%2FUnityServiceProvider/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coryleach%2FUnityServiceProvider/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coryleach","download_url":"https://codeload.github.com/coryleach/UnityServiceProvider/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243976459,"owners_count":20377691,"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","package","service-provider","services","singleton","singleton-pattern","unity","unity3d"],"created_at":"2024-10-10T10:15:03.868Z","updated_at":"2025-03-19T08:30:34.133Z","avatar_url":"https://github.com/coryleach.png","language":"C#","readme":"\u003ch1 align=\"center\"\u003eGameframe.ServiceProvider 👋\u003c/h1\u003e\n\u003cp\u003e\n  \u003cimg alt=\"Version\" src=\"https://img.shields.io/badge/version-1.0.0-blue.svg?cacheSeconds=2592000\" /\u003e\n  \u003ca href=\"https://twitter.com/Cory Leach\"\u003e\n    \u003cimg alt=\"Twitter: coryleach\" src=\"https://img.shields.io/twitter/follow/coryleach.svg?style=social\" target=\"_blank\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp\u003e  \nA simple service provider implementation for use in Unity3D.  \nProvides singleton and transient services.   \n\u003c/p\u003e  \n\u003cp\u003e  \nBecause the focus was on creating a simplified service provider this package does not do dependency graphs, property or constructor injection.  \nIt is probably most easily used as a glorified singleton manager.  \n\u003c/p\u003e\n\n## Quick Package Install\n\n#### Using UnityPackageManager (for Unity 2019.3 or later)\nOpen the package manager window (menu: Window \u003e Package Manager)\u003cbr/\u003e\nSelect \"Add package from git URL...\", fill in the pop-up with the following link:\u003cbr/\u003e\nhttps://github.com/coryleach/UnityServiceProvider.git#1.0.0\u003cbr/\u003e\n\n#### Using UnityPackageManager (for Unity 2019.1 or later)\n\nFind the manifest.json file in the Packages folder of your project and edit it to look like this:\n```js\n{\n  \"dependencies\": {\n    \"com.gameframe.serviceprovider\": \"https://github.com/coryleach/UnityServiceProvider.git#1.0.0\",\n    ...\n  },\n}\n```\n\n\u003c!-- DOC-START --\u003e\n\n## Usage\n\n### Configure your ServiceProvider and ServiceCollection\n\u003e By Default ServiceProvider.Current and ServiceCollection.Current are\n\u003e implemented using the BasicServiceProvider class that is provided so you\n\u003e can immediately use ServiceCollection.Current and ServiceProvider.Current\n\u003e right out of the box without any setup.\n\n```c#\n//ServiceProvider is used to get service instance(s)\n// MyServiceProvider implements IServiceProvider\nServiceProvider.Current = MyServiceProvider;\n```\n\n```C#\n//ServiceCollection handles adding services to be provided\n//It also controls how they will be configured (Singleton vs Transient)\n//Singleton = All Get calls will return the same service instance\n//Transient = Every Get call will return a newly created instance of the service\n//MyServiceCollection implements IServiceCollection\nServiceCollection.Current = MyServiceCollection;\n```\n\n### Adding Singleton Service\n```C#\n//This will configure a specific instance which already has been created\nServiceCollection.Current.AddSingleton(serviceInstance.GetType(),serviceInstance);\n\n//You can also configure a service to be served when requesting a parent type\nServiceCollection.Current.AddSingleton(typeof(ParentClass),childClassServiceInstance);\n\n//You can also configure a function that will be used to construct the singleton service on demand\nServiceCollection.Current.AddSingleton((provider)=\u003e new MyService());\n```\n\n### Adding Transient Service\n```C#\n//Transient services require a factory because a new instance is created every time\nServiceCollection.Current.AddTransient\u003cServiceType\u003e((provider) =\u003e new ServiceType());\n\n//Adding a transient service with a parent type\nServiceCollection.Current.AddTransient\u003cParentType,ServiceType\u003e((provider) =\u003e (ParentType)new ServiceType());\n```\n\n### Getting a Service\n```C#\n//Get a particular service\nvar service = ServiceProvider.Get\u003cServiceType\u003e();\n\n//If more than one service of the given type is provided we can get them all\nvar services = ServiceProvider.GetAll\u003cServiceType\u003e();\n```\n\n### Using the Bootstrapper\n\n\u003e The UnityServiceProviderBootstrapper can be used to configure singleton services from MonoBehaviours or ScriptableObjects\n\u003e In Awake() UnityServiceProviderBootstrapper will configure the ServiceCollection and ServiceProvider to an instance of UnityServiceProvider\n\u003e Additional services can be configured by creating a child class of UnityServiceProviderBootstrapper\n\u003e and overriding the ConfigureServices method. Be sure to include a call to base.ConfigureServices(unityServiceProvider) or the singletonService list will not be added.\n\n\u003c!-- DOC-END --\u003e\n\n## Author\n\n👤 **Cory Leach**\n\n* Twitter: [@coryleach](https://twitter.com/coryleach)\n* Github: [@coryleach](https://github.com/coryleach)\n\n\n## Show your support\n\nGive a ⭐️ if this project helped you!\n\n***\n_This README was generated with ❤️ by [Gameframe.Packages](https://github.com/coryleach/unitypackages)_\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoryleach%2Funityserviceprovider","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoryleach%2Funityserviceprovider","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoryleach%2Funityserviceprovider/lists"}