This is a migrated thread and some comments may be shown as answers.

Custom Constructor for Custom Provider

6 Answers 80 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
NEX
Top achievements
Rank 1
NEX asked on 22 Jan 2010, 03:39 PM
Hi,

I am trying to create custom provider class for general purposes and  need to instantiate the class with some configuration settings including specifying an itemhandler depending on settings during the initialization of the class.

I see that in your example you read settings from web.config but that does not allow for multiple instances for the class with different configurations depeding on configuration values.

I think this a very needed addition to the custom provider classes to make it even more dynamic and extend it's capabilities.

is  there any other way to do this  that I am not aware of?

Thank you,

Alfred


6 Answers, 1 is accepted

Sort by
0
NEX
Top achievements
Rank 1
answered on 26 Jan 2010, 04:31 PM
Hi,

Does Telerik have anything to say about my request.

Thank you,

Alfred
0
Fiko
Telerik team
answered on 27 Jan 2010, 01:36 PM
Hello Alfred,

The constructor of the FileBrowserContentProvider cannot be changed, because this will broke the implementation of the RadFileExplorer control. In your case I recommend you to pass the path of the handler by using a Session value. For example in Page_Load event you can add the session variable as follows:

protected void Page_Load(object sender, EventArgs e)
{
    Context.Session["HandlerPath"] = "Handler.ashx";
}

Then you can access this value inside the content provider by using this approach:
string pathToHandler =  Context.Session["HandlerPath"] as string ;


I hope this helps.

Sincerely yours,
Fiko
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
NEX
Top achievements
Rank 1
answered on 28 Jan 2010, 01:12 AM
Hi Fiko,

Your solution is not appropiate since the session variable is not by instance of the class. An instance of the class should be able to have it own configuration parameters. I am suggesting that the custom provider class should have a way to be instantiated with different configuration arguments.

I think is something that other customers probably benefit from and I need to create custom provider that I can re-use with different backend databases and other configuration parameters. Probably what's needed is a public property that is an "arguments array".

Thank you,

Alfred.
0
Fiko
Telerik team
answered on 02 Feb 2010, 11:10 AM
Hello Alfred,

The purpose of the FileBrowserContentProvide is to provide an interface that can be used in order to serve the content to the RadFileExlorer control. This interface is intended to be used internally by RadFileExplorer only and this is why its constructor does not accept additional parameters. Also the FileBroserContentProvider class is instantiated by using reflection (by its AssemblyQualifiedName) in private method inside the RadFileExplorer and you do not have the opportunity to pass additional parameters into it. This behavior is by design and we do not plan to change it because this will lead to many changes in the current implementation of the RadFileExplorer and RadEditor controls and will brake the backward compatibility.


All the best,
Fiko
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Marco
Top achievements
Rank 1
answered on 15 Feb 2010, 02:52 PM
Can you tell us what other approach might solve our problem?
I'm have a similar isue, because I'm loading files using our internal framework; Loading this framework takes quit some time, but I need it to find the directories and files I want to show in the filebrowser. Since the class is constructed for every object (file/directory) the constructor (that inherits from FileBrowserContentProvider) is loaded everytime and requires me to also load the framework all the time.
If I could just pass an existing framework to the construct that would solve my issue's, but I understand that this is fixed.
However, what approach can you suggest to us?
0
Marco
Top achievements
Rank 1
answered on 16 Feb 2010, 12:22 PM
After spending half a day to find a way to access an object without passing it as a variable to the FileBrowserContentProvider.
Then I figured out I could use the context, which is a variable passed to the FileBrowserContentProvider, holds a Session object, which in term can hold any variable you put into it.
And when I returned to tell you about my brilliant discovery, I found that was exactly what mr. Fiko  was talking about. I just didn't get that the context was a variable that was already available in the constructor. Also, it was unclear to me when the context had to be filled, but thats right before the creation of the editor object.

Telerik thanks! (It's me who's dumb :))
Tags
FileExplorer
Asked by
NEX
Top achievements
Rank 1
Answers by
NEX
Top achievements
Rank 1
Fiko
Telerik team
Marco
Top achievements
Rank 1
Share this question
or