Skip to content

Instantly share code, notes, and snippets.

@Vidarls
Created August 1, 2011 06:07
Show Gist options
  • Save Vidarls/1117641 to your computer and use it in GitHub Desktop.
Save Vidarls/1117641 to your computer and use it in GitHub Desktop.
Provisional extension points to modify namer and reporter at runtime.
public class Approvals
{
//Default implementation works as before
static Func<IApprovalNamer> _defaultNamerSource = (()=> new UnitTestFrameworkNamer());
//Extension point to allow injection of new default namer
//at runtime, as vb6 does not support attributes, nor stacktraces.
public static Func<IApprovalNamer> DefaultNamerSource
{
private get { return _defaultNamerSource; }
set { _defaultNamerSource = value; }
}
//Default Implementation works as before
static Func<IApprovalFailureReporter> _defaultReporterSource = (() => new QuietReporter());
//Extension point to allow injection of new default reporter
//at runtime, as VB6 does not support attributes.
public static Func<IApprovalFailureReporter> DefaultReporterSource
{
private get { return _defaultReporterSource; }
set { _defaultReporterSource = value; }
}
//Changes to existing methods to use the new extension points
public static IApprovalNamer GetDefaultNamer()
{
return DefaultNamerSource();
}
public static IApprovalFailureReporter GetReporter()
{
return GetReporter(DefaultReporterSource());
{
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment