U4-2606 - Resolvers - List available items in a resolver

Created by Warren Buckley (Personal) 08 Aug 2013, 10:37:51 Updated by Stephan 16 Dec 2013, 14:49:56

I am currently working on an Umbraco diagnostics page and I would love to haver a way of listing all items from a resolver.

For example all SurfaceControllers, XSLT Extensions, Rest Extensions etc that are registered in the Umbraco app. So if we can have a 'public' way of retrieving these values that would be fantastic.

Cheers, Warren

Comments

Ove Andersen 08 Aug 2013, 13:50:02

Would love this for uComponents as well. Need to get a list of all registered {{IPropertyEditorValueConverter}}'s


Stephan 28 Aug 2013, 17:29:45

Shannon, any objection to adding a public GetTypes() method to ManyObjectResolverBase, that would return a shallow clone of the internal types list, eg _instanceTypes.ToArray() -- just to prevent ppl from modifying the internal list?

We already have public method ContainsType(Type value) to test if a type is registered...


Stephan 11 Oct 2013, 10:18:49

Done, merged into 6.2.0 and 7.0.0. Now you can GetTypes() on a resolver to get the (readonly) list of types.


Shannon Deminick 01 Nov 2013, 06:12:00

@Stephen, is this completed? If so can you mark as fixed?


Stephan 01 Nov 2013, 08:06:57

Yup


Warren Buckley (Personal) 07 Dec 2013, 13:04:09

@Stephan any chance on a quick example on usage please, as would like to use this but totally forgotten how I would go about it now.


Stephan 07 Dec 2013, 13:14:46

You lazy ;-)

For anything that inherits from ManyObjectsResolverBase,

IEnumerable types = SomethingResolver.GetTypes();

So,

var controllerTypes = SurvaceControllerResolver.GetTypes();

OTOH I'm not sure base REST extensions, nor XSLT extensions, have been migrated to a resolver yet, so that would not work for them.


Warren Buckley (Personal) 08 Dec 2013, 19:42:30

Hey Stephan, Can't do your example as SurfaceControllerResolver is marked as internal :-(


Warren Buckley (Personal) 08 Dec 2013, 20:25:04

Also Stephan, I am going through the source code on GitHub for resolvers. Thank God for their search!

The public ones I am writing into my WebAPI Controller, however wondering if you can offer a bit of advice please.

public IEnumerable GetContentFinders() { return ContentFinderResolver.Current.GetTypes(); }

So in this snippet I would prefer to return a strongly typed object of the IContentFinders as opposed to the type, however I am unsure how to do this.

As the JSON from the WebAPI returns this:

[ "Umbraco.Web.Routing.ContentFinderByPageIdQuery, umbraco, Version=1.0.5073.23298, Culture=neutral, PublicKeyToken=null", "Umbraco.Web.Routing.ContentFinderByNiceUrl, umbraco, Version=1.0.5073.23298, Culture=neutral, PublicKeyToken=null", "Umbraco.Web.Routing.ContentFinderByIdPath, umbraco, Version=1.0.5073.23298, Culture=neutral, PublicKeyToken=null", "Umbraco.Web.Routing.ContentFinderByNotFoundHandlers, umbraco, Version=1.0.5073.23298, Culture=neutral, PublicKeyToken=null" ]

Any ideas please?

Thanks, Warren


Warren Buckley (Personal) 08 Dec 2013, 20:35:15

Ignore me found the answer to myself after an hour poking around

public IEnumerable GetContentFinders() { return ContentFinderResolver.Current.Finders; }


Stephan 16 Dec 2013, 11:44:23

What do you mean by "strongly typed object"? Do you mean the actual content finder, vs. its type? Then I guess you can do something along ContentFinderResolver.Current.Finders (can't remember the exact name) -- that's what we use to get them. Making sense?


Shannon Deminick 16 Dec 2013, 11:48:13

I don't understand why you'd want the resolved object and not just the type if it's for reporting? There's an overhead in instantiating these objects, if you're not going to use them I can't see why you want that.


Stephan 16 Dec 2013, 11:48:59

@Shan: agreed. Getting the types should be enough.


Warren Buckley (Personal) 16 Dec 2013, 12:08:01

@shannon & @stephan using return ContentFinderResolver.Current.GetTypes(); is fine then

But I suppose my question then is there any neat way for me to serialize the results a bit better, as the current JSON serialised object is not great and will need some string splitting to be done if used client side back from a WebAPI call.

[ { Type: "Umbraco.Web.Routing.ContentFinderByPageIdQuery", Assembly: "Umbraco", Version: "" .... } ]


Shannon Deminick 16 Dec 2013, 12:11:50

The type object exposes all sorts of name properties you can use.


Stephan 16 Dec 2013, 13:58:01

You'll want to start with the Type instances and better serialize them, then. Makes more sense than working with the actual finders.


Warren Buckley (Personal) 16 Dec 2013, 14:18:26

@Stephan err you loosing me :S Just wanted to query custom stuff like surface controllers etc in an install for the Diagnostics package really with WebAPI so whatever the best way is to do that.

Maybe move this over into an email thread?!


Stephan 16 Dec 2013, 14:49:56

Yes better email me at sgay@pilotine.com as I'm totally lost and don't understand what you're trying to do...


Priority: Normal

Type: Feature (request)

State: Fixed

Assignee:

Difficulty: Normal

Category:

Backwards Compatible: True

Fix Submitted:

Affected versions:

Due in version: 7.0.0, 6.2.0

Sprint:

Story Points:

Cycle: