Skip to content

Commit

Permalink
Merge pull request #53 from JakBlack/main
Browse files Browse the repository at this point in the history
Add an example of a custom ITypeResolver to documentation
  • Loading branch information
bazyleu authored Sep 25, 2024
2 parents 594415f + b035ea4 commit 67e0b14
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,28 @@ public UniTask<StateTransitionInfo> Execute(CancellationToken token)
}
```

#### Custom type resolvers

While UniState provides `ITypeResolver` implementations for modern DI frameworks out of the box, you can create custom implementations, tailored to your needs

An example of `ITypeResolver` with automatic state bindings:
```csharp
public class ZenjectAutoBindTypeResolver : ITypeResolver
{
...

public object Resolve(Type type)
{
if (!type.IsAbstract && !type.IsInterface && !_container.HasBinding(type))
{
_container.BindState(type);
}

return _container.Resolve(type);
}
}
```

#### State Machine Context

UniState natively supports sub-containers and sub-contexts available in modern DI frameworks.
Expand Down

0 comments on commit 67e0b14

Please sign in to comment.