-
Notifications
You must be signed in to change notification settings - Fork 366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No "ToTransientMethod" method in BinderUntyped #46
Comments
You can just use |
Oh wait, you're right, only |
@svermeulen Thanks! I looked at the code inside |
Ok I pushed a change that adds that method. I tested it in the unit tests but will wait to hear from you whether that solves your problem before closing this item |
I am having a small problem that didn't happen in public static void ToPrefab(this BinderUntyped binder, String prefabLocation, Type type)
{
binder.ToMethod((ctx) => {
var obj = Resources.Load(prefabLocation) as GameObject;
return ctx.Container.InstantiatePrefabForComponent(type, obj) as MonoBehaviour;
});
}
So Zenject complains
I actually commented your code (the part that check types) so it didn't throw that exception but I got
I actually need something that binds the method type as a parameter like this public static void ToPrefab(this BinderUntyped binder, String prefabLocation, Type type)
{
//Pass "type" into ToMethod
binder.ToMethod(type, (ctx) => {
var obj = Resources.Load(prefabLocation) as GameObject;
return ctx.Container.InstantiatePrefabForComponent(type, obj) as MonoBehaviour;
});
} |
If passing |
Ok I added a non-generic version of ToMethod, try that. What errors are you getting now? |
Works!!!!!!!!!!!!!!!!!!!!!!!! Thanks man. Now I am able to define Routes like this with my framework [Route("some/route")]
public class SomeRouteView : MonoBehaviour
{
[PostInject]
public void PostConstruct(...) {
...
}
} and start and configure like this public class Startup : MVCApp
{
public override void Configure(IApplication app, DiContainer container)
{
//Set view dependencies
}
public override void Init(IRouter router)
{
router.GoTo(
url: "some/view",
body: 42
);
}
} the framework looks for classes annotated with |
Ok great :) Sounds like a cool setup |
Fix typo on README.md
Currently there is only a
ToSingleMethod
but I specifically need the dependency to be transient. Can this method be added to Zenject? I am trying to do the same as yesterday but now by passing types as parametersThe text was updated successfully, but these errors were encountered: