Custom Constructor for Custom Provider

7 posts, 0 answers
  1. NEX
    NEX avatar
    84 posts
    Member since:
    Aug 2007

    Posted 22 Jan 2010 Link to this post

    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


  2. NEX
    NEX avatar
    84 posts
    Member since:
    Aug 2007

    Posted 26 Jan 2010 Link to this post

    Hi,

    Does Telerik have anything to say about my request.

    Thank you,

    Alfred
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Fiko
    Admin
    Fiko avatar
    1406 posts

    Posted 27 Jan 2010 Link to this post

    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.
  5. NEX
    NEX avatar
    84 posts
    Member since:
    Aug 2007

    Posted 27 Jan 2010 Link to this post

    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.
  6. Fiko
    Admin
    Fiko avatar
    1406 posts

    Posted 02 Feb 2010 Link to this post

    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.
  7. Marco
    Marco avatar
    22 posts
    Member since:
    Jan 2009

    Posted 15 Feb 2010 Link to this post

    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?
  8. Marco
    Marco avatar
    22 posts
    Member since:
    Jan 2009

    Posted 16 Feb 2010 Link to this post

    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 :))
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017