This commit is contained in:
Hao Kung 2015-09-02 15:28:52 -07:00
Родитель 7bb59a287c
Коммит f5c8bf09e2
7 изменённых файлов: 9 добавлений и 21 удалений

Просмотреть файл

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<configuration> <configuration>
<packageSources> <packageSources>
<add key="AspNetVNext" value="https://www.myget.org/F/aspnetlitedev/api/v2" /> <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 class AntiforgeryOptionsSetup : ConfigureOptions<AntiforgeryOptions>
{ {
public AntiforgeryOptionsSetup(IOptions<DataProtectionOptions> dataProtectionOptionsAccessor) 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) public static void ConfigureOptions(AntiforgeryOptions options, DataProtectionOptions dataProtectionOptions)

Просмотреть файл

@ -30,7 +30,7 @@ namespace Microsoft.AspNet.Antiforgery
IAntiforgeryTokenStore tokenStore, IAntiforgeryTokenStore tokenStore,
IHtmlEncoder htmlEncoder) IHtmlEncoder htmlEncoder)
{ {
_options = antiforgeryOptionsAccessor.Options; _options = antiforgeryOptionsAccessor.Value;
_tokenGenerator = tokenGenerator; _tokenGenerator = tokenGenerator;
_tokenSerializer = tokenSerializer; _tokenSerializer = tokenSerializer;
_tokenStore = tokenStore; _tokenStore = tokenStore;

Просмотреть файл

@ -21,7 +21,7 @@ namespace Microsoft.AspNet.Antiforgery
[NotNull] IOptions<AntiforgeryOptions> optionsAccessor, [NotNull] IOptions<AntiforgeryOptions> optionsAccessor,
[NotNull] IAntiforgeryTokenSerializer tokenSerializer) [NotNull] IAntiforgeryTokenSerializer tokenSerializer)
{ {
_options = optionsAccessor.Options; _options = optionsAccessor.Value;
_tokenSerializer = tokenSerializer; _tokenSerializer = tokenSerializer;
} }

Просмотреть файл

@ -25,7 +25,7 @@ namespace Microsoft.AspNet.Antiforgery
var options = services.GetRequiredService<IOptions<AntiforgeryOptions>>(); var options = services.GetRequiredService<IOptions<AntiforgeryOptions>>();
// Act // Act
var cookieName = options.Options.CookieName; var cookieName = options.Value.CookieName;
// Assert // Assert
Assert.Equal(expectedCookieName, cookieName); Assert.Equal(expectedCookieName, cookieName);
@ -49,7 +49,7 @@ namespace Microsoft.AspNet.Antiforgery
var options = services.GetRequiredService<IOptions<AntiforgeryOptions>>(); var options = services.GetRequiredService<IOptions<AntiforgeryOptions>>();
// Act // Act
var cookieName = options.Options.CookieName; var cookieName = options.Value.CookieName;
// Assert // Assert
Assert.Equal("antiforgery", cookieName); Assert.Equal("antiforgery", cookieName);

Просмотреть файл

@ -466,7 +466,7 @@ namespace Microsoft.AspNet.Antiforgery
var optionsManager = new TestOptionsManager(); var optionsManager = new TestOptionsManager();
if (options != null) if (options != null)
{ {
optionsManager.Options = options; optionsManager.Value = options;
} }
return new DefaultAntiforgery( return new DefaultAntiforgery(
@ -628,12 +628,7 @@ namespace Microsoft.AspNet.Antiforgery
private class TestOptionsManager : IOptions<AntiforgeryOptions> private class TestOptionsManager : IOptions<AntiforgeryOptions>
{ {
public AntiforgeryOptions Options { get; set; } = new AntiforgeryOptions(); public AntiforgeryOptions Value { get; set; } = new AntiforgeryOptions();
public AntiforgeryOptions GetNamedOptions(string name)
{
throw new NotImplementedException();
}
} }
} }
} }

Просмотреть файл

@ -17,11 +17,6 @@ namespace Microsoft.AspNet.Antiforgery
Options = options; Options = options;
} }
public AntiforgeryOptions Options { get; set; } = new AntiforgeryOptions(); public AntiforgeryOptions Value { get; set; } = new AntiforgeryOptions();
public AntiforgeryOptions GetNamedOptions(string name)
{
throw new NotImplementedException();
}
} }
} }