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.
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.
In my opinion you have two options.
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.
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.
Please, sign in to be able to submit a new answer.