1
Vote

PageFlow does not allow NavigationService to be customized; value is hardcoded to Microsoft.Practices.PageFlow.Services.NavigationService

description

When using the web.config to configure the pageflow provider, there is no way to customize the INavigationService used within the WorkflowFoundationPageFlowProvider. It is hardcoded on line 55 as:
 
public WorkflowFoundationPageFlowProvider(PageFlowInstanceStoreProviderSection pageFlowInstanceStoreProviderSection, PageFlowInstanceCorrelationTokenProviderSection pageFlowCorrelationTokenProviderSection)
{
       ...
        _pageFlowFactory = new WorkflowFoundationPageFlowFactory();
       ...
}
 
This constructor uses Microsoft.Practices.PageFlow.Services.NavigationService:
 
public WorkflowFoundationPageFlowFactory() : this(new NavigationService())
{
}
 
I propose:
 
1) Adding a navigationType configuration element to PageFlowProviderSection, which defaults to Microsoft.Practices.PageFlow.Services.NavigationService but allows a custom value to be entered if necessary:
    /// <summary>
    /// Defines the concrete type of the INavigator.
    /// </summary>
    [ConfigurationProperty("navigationType", DefaultValue = "Microsoft.Practices.PageFlow.Services.NavigationService", IsRequired = false)]
    public string NavigationType
        {
        get { return (string)base["navigationType"]; }
        }
 
 
2) Constructor for WorkFlowFoundationPageFlowProvider would be modified as:
public WorkflowFoundationPageFlowProvider(PageFlowInstanceStoreProviderSection pageFlowInstanceStoreProviderSection, PageFlowInstanceCorrelationTokenProviderSection pageFlowCorrelationTokenProviderSection)
{
       ...
        _pageFlowFactory = new WorkflowFoundationPageFlowFactory(navigationService);
       ...
}
 
and (3): Modify BuildProvider to use specified navigationType and pass it on to the WorkflowFoundationPageFlowProvider constructor:
 
private static IPageFlowProvider BuildProvider()
{
...
        Type navigationType = Type.GetType(configSection.NavigationType);
        Services.INavigationService navigationService = (Services.INavigationService)Activator.CreateInstance(navigationType);
        _provider = (IPageFlowProvider) Activator.CreateInstance(providerType,
                                                                BindingFlags.CreateInstance,
                                                                null,
                                                                new object[] { navigationService, storeSection, tokenProviderSection },
                                                                CultureInfo.CurrentCulture);
...
}
 
Enjoy!

file attachments

comments

BrandonHaynes wrote Feb 16, 2008 at 11:24 PM

Fixes implemented here, also uploaded as patch.

BrandonHaynes wrote Jun 5, 2008 at 11:08 PM

Small type in point #2. Should read:

public WorkflowFoundationPageFlowProvider([b]Services.INavigationService navigationService[/b], PageFlowInstanceStoreProviderSection pageFlowInstanceStoreProviderSection, PageFlowInstanceCorrelationTokenProviderSection pageFlowCorrelationTokenProviderSection)

Oops!