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!


Comments

most recent at top (show oldest at top)
BrandonHaynes wrote Jun 6 2008 at 12:08 AM
Small type in point #2. Should read:

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

Oops!

BrandonHaynes wrote Feb 17 2008 at 12:24 AM
Fixes implemented here, also uploaded as patch.

Updating...
© 2006-2009 Microsoft | About CodePlex | Privacy Statement | Terms of Use | Code of Conduct | Advertise With Us | Version 2009.10.27.15987