Giter Club home page Giter Club logo

Comments (4)

YairHalberstadt avatar YairHalberstadt commented on September 22, 2024 1

I see. I wouldn't implement this myself, but if you send a PR I'd be happy to review.

from stronginject.

YairHalberstadt avatar YairHalberstadt commented on September 22, 2024

I don't see a problem with this, and I think it should be fairly simple to implement - we just add the interface to Owned<T>, and add a check to InstanceSourcesScope to return a ForwardedInstanceSource wrapping and OwnedSource if it sees IOwned.

My only issue is I'm not convinced of the utility. This seems like a relatively niche use case, and there's a valid workaround.

I can see a separate advantage in that it allows other libraries to provide their own implementation of IOwned, but in practice I can't really see that happening - Owned takes a delegate in it's constructor so is pretty flexible.

from stronginject.

jnm2 avatar jnm2 commented on September 22, 2024

The biggest reason I would like this is that I recently had to add 110 occurrences of .AsObject() into a project when moving from my own Owned type to using the one in the StrongInject library. I could mitigate this in a minority of the cases by making all the windowing system methods generic so they can directly take Owned<T> without the caller having to create a new Owned<object> themselves.

Hopefully it's not too hard to see why a windowing system deals heavily with Owned<object> rather than Owned<AbcView> and Owned<DefView>, and why menu items have Func<Owned<object>> properties. But obtaining these Owned<object> instances has to start with StrongInject returning Owned<AbcView> and Owned<DefView> from injected delegates. I don't see a way around the .AsObject() call syntax bloat without going back to the bad old days of having the windowing system dispose both views and view models by calling container.Release directly rather than disposing an Owned<object>. StrongInject doesn't provide such a method, so the mere ability to use StrongInject is the driver behind all of this.

image

Example of the syntax bloat imposed on callers since there's no implicit conversion from what the caller must have (Lease<SpecificViewModel>) and what the navigation service must deal with (Lease<object>):

navigationService.AddSiblingViewModel(this, baseFormulasViewModelFactory.Invoke(EditList.FocusedItem).AsObject());

from stronginject.

jnm2 avatar jnm2 commented on September 22, 2024

@YairHalberstadt As I'm working with the XML docs, I noticed that it looks like <para> blocks may have been intended:

image

With <para>:

image

I'm going ahead and making this change before basing IOwned<T> docs off of them, but just give a shout if that's not what you would have wanted.

from stronginject.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.