Skip to content
This repository has been archived by the owner on Jan 24, 2021. It is now read-only.

Commit

Permalink
Updated configurable boostrapper for csrf types
Browse files Browse the repository at this point in the history
  • Loading branch information
grumpydev committed Sep 29, 2011
1 parent 74775c7 commit fff6f23
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions src/Nancy.Testing/ConfigurableBootstrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace Nancy.Testing
using Nancy.ErrorHandling;
using Nancy.ModelBinding;
using Nancy.Routing;
using Nancy.Security;
using Nancy.ViewEngines;

using TinyIoC;
Expand Down Expand Up @@ -953,6 +954,54 @@ public ConfigurableBoostrapperConfigurator ViewResolver<T>() where T : IViewReso
this.bootstrapper.configuration.ViewResolver = typeof(T);
return this;
}

/// <summary>
/// Configures the bootstrapper to use the provided instance of <see cref="ICsrfTokenValidator"/>.
/// </summary>
/// <param name="tokenValidator">The <see cref="ICsrfTokenValidator"/> instance that should be used by the bootstrapper.</param>
/// <returns>A reference to the current <see cref="ConfigurableBoostrapperConfigurator"/>.</returns>
public ConfigurableBoostrapperConfigurator CsrfTokenValidator(ICsrfTokenValidator tokenValidator)
{
this.bootstrapper.registeredInstances.Add(
new InstanceRegistration(typeof(ICsrfTokenValidator), tokenValidator));

return this;
}

/// <summary>
/// Configures the bootstrapper to create an <see cref="ICsrfTokenValidator"/> instance of the specified type.
/// </summary>
/// <typeparam name="T">The type of the <see cref="ICsrfTokenValidator"/> that the bootstrapper should use.</typeparam>
/// <returns>A reference to the current <see cref="ConfigurableBoostrapperConfigurator"/>.</returns>
public ConfigurableBoostrapperConfigurator CsrfTokenValidator<T>() where T : ICsrfTokenValidator
{
this.bootstrapper.configuration.CsrfTokenValidator = typeof(T);
return this;
}

/// <summary>
/// Configures the bootstrapper to use the provided instance of <see cref="IObjectSerializer"/>.
/// </summary>
/// <param name="objectSerializer">The <see cref="IObjectSerializer"/> instance that should be used by the bootstrapper.</param>
/// <returns>A reference to the current <see cref="ConfigurableBoostrapperConfigurator"/>.</returns>
public ConfigurableBoostrapperConfigurator ObjectSerializer(IObjectSerializer objectSerializer)
{
this.bootstrapper.registeredInstances.Add(
new InstanceRegistration(typeof(IObjectSerializer), objectSerializer));

return this;
}

/// <summary>
/// Configures the bootstrapper to create an <see cref="IObjectSerializer"/> instance of the specified type.
/// </summary>
/// <typeparam name="T">The type of the <see cref="IObjectSerializer"/> that the bootstrapper should use.</typeparam>
/// <returns>A reference to the current <see cref="ConfigurableBoostrapperConfigurator"/>.</returns>
public ConfigurableBoostrapperConfigurator ObjectSerializer<T>() where T : IObjectSerializer
{
this.bootstrapper.configuration.ObjectSerializer = typeof(T);
return this;
}
}
}
}

0 comments on commit fff6f23

Please sign in to comment.