Get InfoProvider from ClassName

Brenden Kehren asked on August 7, 2014 16:00

Never had a need for this until now (which is odd) but I need to know how to get an InfoProviderobject from a class name. For instance my custom class is CustomClass.BrendenExample and I want to get the provider for this object (BrendenExampleInfoProvider).

Essentially I'm attempting to create a generic sorting function for a web part to be able to pass in a class name and dynamically load columns and such in a UniGrid. I want to use the infoobject.Generalized.MoveObjectUp() method without having to hard code the Info objects.

Recent Answers

Joshua Adams answered on August 7, 2014 17:32

You could use a switch statement, but again, that's very similar to hard coding it. Not the best choice, but would allow for you to handle multiple scenarios at least.

0 votesVote for this answer Mark as a Correct answer

David Kadlec answered on August 7, 2014 18:18 (last edited on August 8, 2014 16:47)


In my opinion you have two options.

  1. Use AbstractProvider.GetProvider which returns you BrendenExampleInfoProvider for your example, but you would need to cast it depending the object type as returned object is AbstractProvider. Not so great as this would be almost the same as hardcoding it.

  2. You can use CustomTableItemProvider.GetProviderObject method which takes className as a parameter. This gets you provider that is built to work with custom classes and you can then use general methods like GetItem, SetItem, etc...

Hope this helps you with your problem.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.