React to options
This commit is contained in:
Родитель
7bb59a287c
Коммит
f5c8bf09e2
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<packageSources>
|
||||
<add key="AspNetVNext" value="https://www.myget.org/F/aspnetlitedev/api/v2" />
|
||||
|
|
|
@ -13,10 +13,8 @@ namespace Microsoft.AspNet.Antiforgery
|
|||
public class AntiforgeryOptionsSetup : ConfigureOptions<AntiforgeryOptions>
|
||||
{
|
||||
public AntiforgeryOptionsSetup(IOptions<DataProtectionOptions> dataProtectionOptionsAccessor)
|
||||
: base((options) => ConfigureOptions(options, dataProtectionOptionsAccessor.Options))
|
||||
: base((options) => ConfigureOptions(options, dataProtectionOptionsAccessor.Value))
|
||||
{
|
||||
// We want this to run after any user setups to compute a default name if needed.
|
||||
Order = 10000;
|
||||
}
|
||||
|
||||
public static void ConfigureOptions(AntiforgeryOptions options, DataProtectionOptions dataProtectionOptions)
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace Microsoft.AspNet.Antiforgery
|
|||
IAntiforgeryTokenStore tokenStore,
|
||||
IHtmlEncoder htmlEncoder)
|
||||
{
|
||||
_options = antiforgeryOptionsAccessor.Options;
|
||||
_options = antiforgeryOptionsAccessor.Value;
|
||||
_tokenGenerator = tokenGenerator;
|
||||
_tokenSerializer = tokenSerializer;
|
||||
_tokenStore = tokenStore;
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace Microsoft.AspNet.Antiforgery
|
|||
[NotNull] IOptions<AntiforgeryOptions> optionsAccessor,
|
||||
[NotNull] IAntiforgeryTokenSerializer tokenSerializer)
|
||||
{
|
||||
_options = optionsAccessor.Options;
|
||||
_options = optionsAccessor.Value;
|
||||
_tokenSerializer = tokenSerializer;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace Microsoft.AspNet.Antiforgery
|
|||
var options = services.GetRequiredService<IOptions<AntiforgeryOptions>>();
|
||||
|
||||
// Act
|
||||
var cookieName = options.Options.CookieName;
|
||||
var cookieName = options.Value.CookieName;
|
||||
|
||||
// Assert
|
||||
Assert.Equal(expectedCookieName, cookieName);
|
||||
|
@ -49,7 +49,7 @@ namespace Microsoft.AspNet.Antiforgery
|
|||
var options = services.GetRequiredService<IOptions<AntiforgeryOptions>>();
|
||||
|
||||
// Act
|
||||
var cookieName = options.Options.CookieName;
|
||||
var cookieName = options.Value.CookieName;
|
||||
|
||||
// Assert
|
||||
Assert.Equal("antiforgery", cookieName);
|
||||
|
|
|
@ -466,7 +466,7 @@ namespace Microsoft.AspNet.Antiforgery
|
|||
var optionsManager = new TestOptionsManager();
|
||||
if (options != null)
|
||||
{
|
||||
optionsManager.Options = options;
|
||||
optionsManager.Value = options;
|
||||
}
|
||||
|
||||
return new DefaultAntiforgery(
|
||||
|
@ -628,12 +628,7 @@ namespace Microsoft.AspNet.Antiforgery
|
|||
|
||||
private class TestOptionsManager : IOptions<AntiforgeryOptions>
|
||||
{
|
||||
public AntiforgeryOptions Options { get; set; } = new AntiforgeryOptions();
|
||||
|
||||
public AntiforgeryOptions GetNamedOptions(string name)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public AntiforgeryOptions Value { get; set; } = new AntiforgeryOptions();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -17,11 +17,6 @@ namespace Microsoft.AspNet.Antiforgery
|
|||
Options = options;
|
||||
}
|
||||
|
||||
public AntiforgeryOptions Options { get; set; } = new AntiforgeryOptions();
|
||||
|
||||
public AntiforgeryOptions GetNamedOptions(string name)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public AntiforgeryOptions Value { get; set; } = new AntiforgeryOptions();
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче