Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    taylank
    @taylank
    I'll give the deterministic destruction setting a try. I'm not working on anything Android related so that may be fine
    and re: lawsuit - is there any way the community can help you?
    Steve Vermeulen
    @svermeulen
    Probably the easiest thing to do is just spread the news that Extenject exists and is active. Or donate to help me with the legal costs, of which there is a lot (currently exceeding 15k)
    taylank
    @taylank
    :grimacing:
    taylank
    @taylank
    done
    Steve Vermeulen
    @svermeulen
    Thanks!
    taylank
    @taylank
    hmm, turns out Ensure Deterministic Destruction Order was already on
    I'll try creating stuff under scene context then
    LP
    @grofit
    Wow if it's costing 15k it's probably cheaper to re write it all from scratch
    Alireza Tarahomi
    @ATHellboy_gitlab

    Hey guys,
    I need these 2 pieces of code in one installer.

    Container.Bind<IState>().To<Preparation>().FromResolve().When(context => string.Equals("startState", context.MemberName));
    Container.Bind<IState>().To<Idle>().FromResolve().When(context => string.Equals("startState", context.MemberName));

    How can I separate them not to get this error ?
    Found multiple matches when only one was expected for type 'IState' while building object

    taylank
    @taylank
    it appears your When clauses are identical though?
    Alireza Tarahomi
    @ATHellboy_gitlab
    @taylank Yup, I added type check to the When clauses but it didn't solve the problem.
    taylank
    @taylank
    @ATHellboy_gitlab what I mean is, your When clauses fail to eliminate one of the two binding possibilities. Whenver your member name is "startState" there will be two potential bindings for it
    in any case, you might wanna also try using WithId(string)
    Alireza Tarahomi
    @ATHellboy
    @taylank Yup, I know. Before it I just have one of them in my installer. So it worked.
    So I can't add any condition without using WithId ?
    taylank
    @taylank
    there's also WhenInjectedInto. When could also work, but as I said, you need to have two different conditions
    here you only have one condition
    context => string.Equals("startState", context.MemberName)
    if the second one said: context => string.Equals("someOtherState", context.MemberName)
    it might work
    do you see what I'm saying? You're trying to bind startState to two contradictory states
    Alireza Tarahomi
    @ATHellboy
    Yes I know :D I mean do you think if I can add any other condition to the When clause to make them rocognizable.
    taylank
    @taylank
    well, it depends on your logic. Right now it appears there is a logical flaw in those statements that is not even related to Zenject. You want to assign two different things to the same member. I could help more if you explained what you are trying to achieve with these states.
    Chad Wentz
    @CWentzJaneious
    could you do something like this,
    [Inject]
        public void Construct([Inject(Id = "state a")]State a, [Inject(Id = "state b")]State b)
        {
        }
    Mathijs Bakker
    @Mathijs-Bakker
    Nope
    But you can do a conditional statement in your binding.
    Mathijs Bakker
    @Mathijs-Bakker

    But reading your example… you are injecting State (more than once).
    So when your bindings are like this:

    Container.Bind<State>().To<FooState>().AsSingle();
    Container.Bind<State>().To<BarState>().AsSingle();

    You can resolve them in your constructor/method like this:

    [Inject]
    public void Construct(List<State> states>)
    {
        _states = states;
    }

    Then you can do - for example - a for loop on _states.

    Mathijs Bakker
    @Mathijs-Bakker
    I would recommend to read the documentation on 'conditional bindings'
    Chad Wentz
    @CWentzJaneious
    @ATHellboy_gitlab do you have some examples of the cases when those IStates are used?
    Alireza Tarahomi
    @ATHellboy
    Thanks guys. I added this condition and it works now. (According to the link which Mathijs sent)
    context => context.ObjectType == typeof(InteractStateMachineContext)
    Chad Wentz
    @CWentzJaneious
    anyone know why the binding component isn't calling initialize and dispose when created from a factory?
    Chad Wentz
    @CWentzJaneious
    It is triggering when I load the scene. Just not the factory
    Chad Wentz
    @CWentzJaneious
    I tried adding a gameobject context and having the binding component and using the GOC it works now
    Mathijs Bakker
    @Mathijs-Bakker
    That’s odd. Could you show some code?
    Ah!
    Lol
    Good!
    Steve Vermeulen
    @svermeulen
    @CWentzJaneious Objects created through factories that have Initialize / Dispose methods need to be called explicitly. GameObjectContext is one exception to this because it behaves like SceneContext in that it automatically will call IInitializable/IDisposable bindings
    You can also create non-gameobjectcontext subcontainers via a factory and use IInitializeable/IDisposable inside there, but it's a bit more work (documentation contains examples)
    Mathijs Bakker
    @Mathijs-Bakker
    @svermeulen Is it cool to spread the word for Extenject? Or does it cause you more annoyance?
    Mathijs Bakker
    @Mathijs-Bakker
    Btw: I think you already seen the pull request. But I altered your Moq extention class. So it supports NSubstitute. It’s own located in a package (in OptionalExtras) with a working lib included.
    And works like a charm ;)
    Changed the AutoMocking doc. So it’s more generic about ‘mocking’ and adds the installation instructions for the new package.
    But maybe it could need some proof reading.
    Steve Vermeulen
    @svermeulen
    @Mathijs-Bakker For sure, yeah. I wish more people knew it exists so go ahead :)
    Ok cool, I'll take a look at your PR this afternoon
    Mathijs Bakker
    @Mathijs-Bakker
    We changed the Zenject channel on the Infallible Code discord server a while ago
    to Zenject/Exenject
    Mathijs Bakker
    @Mathijs-Bakker
    But will spread the word further
    Mathijs Bakker
    @Mathijs-Bakker
    Schermafbeelding 2019-07-25 om 12.43.18.png
    taylank
    @taylank
    :thumbsup: