Views: 5741
Number of votes: 0
Average rating:

Configuring page provider capabilities

Page providers requires some configuration. In addition to the obvious ones like name, type and entryPoint you should also define what capabilities your page provider supports, such as Create, Edit, Delete and Search. If you, for example, specify that your provider does not support delete, all delete related ui in edit mode will be disabled for your providers pages. More details on capabilities can be found in the Configuration section of the Page Provider Tech Note.

In almost all examples I have seen for page provider configuration, capabilities are specified in web.config. In my opinion, capabilities should not be defined in configuration. This could lead to, by accident, specifying more capabilities than what is actually implemented in code. I think the best place for this kind of configuration is code. Fortunately, the Capabilities property in PageProviderBase is virtual, which means you can override it and configure it there.

public override PageProviderCapabilities Capabilities
        return PageProviderCapabilities.Create | 
            PageProviderCapabilities.Edit | 
Feb 11, 2010

( 9/21/2010 10:33:06 AM)

Good one Martin! I totally agree with you.
/ Tom Stenius

( 9/21/2010 10:33:06 AM)

This is not as good if you want to provide some reusable provider. When you override Capabilities property web.config settings have no effect at all. So someone else won't be able to suppress for example Delete or Create later. I think implementation should be like this:

Math.Min( base.Capabilities & (int)PageProviderCapabilities.Create,
(int)PageProviderCapabilities.Create ) |
Math.Min( base.Capabilities & (int)PageProviderCapabilities.Edit,
(int)PageProviderCapabilities.Edit ) ...
/ Vlad

Please login to comment.