https://github.com/k0dep/stator
💉IoC container that uses code generation instead of reflection for managing and resolving dependencies as a basis
https://github.com/k0dep/stator
code-generation codegeneration ioc-container originer unity-package-manager unity3d
Last synced: 8 months ago
JSON representation
💉IoC container that uses code generation instead of reflection for managing and resolving dependencies as a basis
- Host: GitHub
- URL: https://github.com/k0dep/stator
- Owner: k0dep
- License: mit
- Created: 2019-08-14T19:28:43.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-09-13T10:21:52.000Z (about 6 years ago)
- Last Synced: 2024-09-28T20:58:52.879Z (about 1 year ago)
- Topics: code-generation, codegeneration, ioc-container, originer, unity-package-manager, unity3d
- Language: C#
- Homepage:
- Size: 156 KB
- Stars: 16
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
💉Stator IoC container
====================Stator is an IoC container that uses code generation instead of reflection for managing and resolving dependencies as a basis.
> This repository is a UPM package.Example
-------1. Add TestFactory *partial* class
```csharp
using Stator;namespace StatorExample
{
public partial class TestFactory : ContainerFactory
{
public TestFactory()
{
AddTransient();
AddTransient();
}
}public class Foo { }
public class Bar
{
public Foo Foo;
public Bar(Foo foo)
{
Foo = foo;
}
}
}
```2. Focus unity editor for triger generation process, after compilation will generated partial classes in `./Assets/stator_generated/`
3. Use container:
```csharp
using StatorExample;
using UnityEngine;
using UnityEngine.Assertions;public class SceneTest : MonoBehaviour
{
void Start()
{
var container = new TestFactory();
var bar = container.Resolve();
Assert.IsNotNull(bar);
Assert.IsNotNull(bar.Foo);
Debug.Log("Ok");
}
}
```4. Enjoy!
Performance
-----------Performance testing was carried out on a PC and an Android device and
not a development build. As a comparison, the ioc container `Zenject` 8.0.0 version was selected.Device configurations:
* PC: Laptop Huawei Matebook 13, intel core i5 8th, 8gb ddr4 ram.
* Android device: Xiaomi Redmi Note 4 MTKResult:

Settings
--------To configure you need to add the file `.stator` to the root project folder. Config structure like ini file.
Options:| Key | Values |
|-------------------------|--------------------------------------------------------------------- |
| AutoGeneratedFolder | Relative path to the folder where the generated files will be stored |
| EnableDebugging | true - enable debug logs |
| DisabledAutoRefreshing | true - auto generation will be disabled |To manual start the code generation process, click the button in the window in `Window/Stator/Options`
Using
-----To start using this package add a line to your `./Packages/manifest.json` like next sample:
```json
{
"dependencies": {
"pro.kodep.stator": "https://github.com/k0dep/stator.git"
}
}
```Or use it as dependency from another packages and auto include by [Originer](https://github.com/k0dep/Originer) package