#270 Rename auth wrapper's internal collections to Items.

This commit is contained in:
Chris Ross 2015-04-17 10:05:32 -07:00
parent 4637a95157
commit a174bb299e
3 changed files with 37 additions and 37 deletions

View File

@ -21,22 +21,22 @@ namespace Microsoft.AspNet.Http.Authentication
/// </summary> /// </summary>
public AuthenticationDescription() public AuthenticationDescription()
{ {
Dictionary = new Dictionary<string, object>(StringComparer.Ordinal); Items = new Dictionary<string, object>(StringComparer.Ordinal);
} }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="AuthenticationDescription"/> class /// Initializes a new instance of the <see cref="AuthenticationDescription"/> class
/// </summary> /// </summary>
/// <param name="properties"></param> /// <param name="items"></param>
public AuthenticationDescription([NotNull] IDictionary<string, object> properties) public AuthenticationDescription([NotNull] IDictionary<string, object> items)
{ {
Dictionary = properties; Items = items;
} }
/// <summary> /// <summary>
/// Contains metadata about the authentication provider. /// Contains metadata about the authentication provider.
/// </summary> /// </summary>
public IDictionary<string, object> Dictionary { get; private set; } public IDictionary<string, object> Items { get; private set; }
/// <summary> /// <summary>
/// Gets or sets the name used to reference the authentication middleware instance. /// Gets or sets the name used to reference the authentication middleware instance.
@ -44,7 +44,7 @@ namespace Microsoft.AspNet.Http.Authentication
public string AuthenticationScheme public string AuthenticationScheme
{ {
get { return GetString(AuthenticationSchemePropertyKey); } get { return GetString(AuthenticationSchemePropertyKey); }
set { Dictionary[AuthenticationSchemePropertyKey] = value; } set { Items[AuthenticationSchemePropertyKey] = value; }
} }
/// <summary> /// <summary>
@ -53,13 +53,13 @@ namespace Microsoft.AspNet.Http.Authentication
public string Caption public string Caption
{ {
get { return GetString(CaptionPropertyKey); } get { return GetString(CaptionPropertyKey); }
set { Dictionary[CaptionPropertyKey] = value; } set { Items[CaptionPropertyKey] = value; }
} }
private string GetString(string name) private string GetString(string name)
{ {
object value; object value;
if (Dictionary.TryGetValue(name, out value)) if (Items.TryGetValue(name, out value))
{ {
return Convert.ToString(value, CultureInfo.InvariantCulture); return Convert.ToString(value, CultureInfo.InvariantCulture);
} }

View File

@ -24,51 +24,51 @@ namespace Microsoft.AspNet.Http.Authentication
/// Initializes a new instance of the <see cref="AuthenticationProperties"/> class /// Initializes a new instance of the <see cref="AuthenticationProperties"/> class
/// </summary> /// </summary>
public AuthenticationProperties() public AuthenticationProperties()
: this(dictionary: null) : this(items: null)
{ {
} }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="AuthenticationProperties"/> class /// Initializes a new instance of the <see cref="AuthenticationProperties"/> class
/// </summary> /// </summary>
/// <param name="dictionary"></param> /// <param name="items"></param>
public AuthenticationProperties(IDictionary<string, string> dictionary) public AuthenticationProperties(IDictionary<string, string> items)
{ {
Dictionary = dictionary ?? new Dictionary<string, string>(StringComparer.Ordinal); Items = items ?? new Dictionary<string, string>(StringComparer.Ordinal);
} }
/// <summary> /// <summary>
/// State values about the authentication session. /// State values about the authentication session.
/// </summary> /// </summary>
public IDictionary<string, string> Dictionary { get; private set; } public IDictionary<string, string> Items { get; private set; }
/// <summary> /// <summary>
/// Gets or sets whether the authentication session is persisted across multiple requests. /// Gets or sets whether the authentication session is persisted across multiple requests.
/// </summary> /// </summary>
public bool IsPersistent public bool IsPersistent
{ {
get { return Dictionary.ContainsKey(IsPersistentKey); } get { return Items.ContainsKey(IsPersistentKey); }
set set
{ {
if (Dictionary.ContainsKey(IsPersistentKey)) if (Items.ContainsKey(IsPersistentKey))
{ {
if (!value) if (!value)
{ {
Dictionary.Remove(IsPersistentKey); Items.Remove(IsPersistentKey);
} }
} }
else else
{ {
if (value) if (value)
{ {
Dictionary.Add(IsPersistentKey, string.Empty); Items.Add(IsPersistentKey, string.Empty);
} }
} }
} }
} }
/// <summary> /// <summary>
/// Gets or sets the full path or absolute URI to be used as an http redirect response value. /// Gets or sets the full path or absolute URI to be used as an http redirect response value.
/// </summary> /// </summary>
[SuppressMessage("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings", Justification = "By design")] [SuppressMessage("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings", Justification = "By design")]
public string RedirectUri public string RedirectUri
@ -76,19 +76,19 @@ namespace Microsoft.AspNet.Http.Authentication
get get
{ {
string value; string value;
return Dictionary.TryGetValue(RedirectUriKey, out value) ? value : null; return Items.TryGetValue(RedirectUriKey, out value) ? value : null;
} }
set set
{ {
if (value != null) if (value != null)
{ {
Dictionary[RedirectUriKey] = value; Items[RedirectUriKey] = value;
} }
else else
{ {
if (Dictionary.ContainsKey(RedirectUriKey)) if (Items.ContainsKey(RedirectUriKey))
{ {
Dictionary.Remove(RedirectUriKey); Items.Remove(RedirectUriKey);
} }
} }
} }
@ -102,7 +102,7 @@ namespace Microsoft.AspNet.Http.Authentication
get get
{ {
string value; string value;
if (Dictionary.TryGetValue(IssuedUtcKey, out value)) if (Items.TryGetValue(IssuedUtcKey, out value))
{ {
DateTimeOffset dateTimeOffset; DateTimeOffset dateTimeOffset;
if (DateTimeOffset.TryParseExact(value, UtcDateTimeFormat, CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind, out dateTimeOffset)) if (DateTimeOffset.TryParseExact(value, UtcDateTimeFormat, CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind, out dateTimeOffset))
@ -116,13 +116,13 @@ namespace Microsoft.AspNet.Http.Authentication
{ {
if (value.HasValue) if (value.HasValue)
{ {
Dictionary[IssuedUtcKey] = value.Value.ToString(UtcDateTimeFormat, CultureInfo.InvariantCulture); Items[IssuedUtcKey] = value.Value.ToString(UtcDateTimeFormat, CultureInfo.InvariantCulture);
} }
else else
{ {
if (Dictionary.ContainsKey(IssuedUtcKey)) if (Items.ContainsKey(IssuedUtcKey))
{ {
Dictionary.Remove(IssuedUtcKey); Items.Remove(IssuedUtcKey);
} }
} }
} }
@ -136,7 +136,7 @@ namespace Microsoft.AspNet.Http.Authentication
get get
{ {
string value; string value;
if (Dictionary.TryGetValue(ExpiresUtcKey, out value)) if (Items.TryGetValue(ExpiresUtcKey, out value))
{ {
DateTimeOffset dateTimeOffset; DateTimeOffset dateTimeOffset;
if (DateTimeOffset.TryParseExact(value, UtcDateTimeFormat, CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind, out dateTimeOffset)) if (DateTimeOffset.TryParseExact(value, UtcDateTimeFormat, CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind, out dateTimeOffset))
@ -150,13 +150,13 @@ namespace Microsoft.AspNet.Http.Authentication
{ {
if (value.HasValue) if (value.HasValue)
{ {
Dictionary[ExpiresUtcKey] = value.Value.ToString(UtcDateTimeFormat, CultureInfo.InvariantCulture); Items[ExpiresUtcKey] = value.Value.ToString(UtcDateTimeFormat, CultureInfo.InvariantCulture);
} }
else else
{ {
if (Dictionary.ContainsKey(ExpiresUtcKey)) if (Items.ContainsKey(ExpiresUtcKey))
{ {
Dictionary.Remove(ExpiresUtcKey); Items.Remove(ExpiresUtcKey);
} }
} }
} }
@ -170,7 +170,7 @@ namespace Microsoft.AspNet.Http.Authentication
get get
{ {
string value; string value;
if (Dictionary.TryGetValue(RefreshKey, out value)) if (Items.TryGetValue(RefreshKey, out value))
{ {
bool refresh; bool refresh;
if (bool.TryParse(value, out refresh)) if (bool.TryParse(value, out refresh))
@ -184,13 +184,13 @@ namespace Microsoft.AspNet.Http.Authentication
{ {
if (value.HasValue) if (value.HasValue)
{ {
Dictionary[RefreshKey] = value.Value.ToString(); Items[RefreshKey] = value.Value.ToString();
} }
else else
{ {
if (Dictionary.ContainsKey(RefreshKey)) if (Items.ContainsKey(RefreshKey))
{ {
Dictionary.Remove(RefreshKey); Items.Remove(RefreshKey);
} }
} }
} }

View File

@ -87,7 +87,7 @@ namespace Microsoft.AspNet.Http.Authentication
HttpResponseFeature.StatusCode = 401; HttpResponseFeature.StatusCode = 401;
var handler = HttpAuthenticationFeature.Handler; var handler = HttpAuthenticationFeature.Handler;
var challengeContext = new ChallengeContext(authenticationScheme, properties == null ? null : properties.Dictionary); var challengeContext = new ChallengeContext(authenticationScheme, properties == null ? null : properties.Items);
if (handler != null) if (handler != null)
{ {
handler.Challenge(challengeContext); handler.Challenge(challengeContext);
@ -103,7 +103,7 @@ namespace Microsoft.AspNet.Http.Authentication
{ {
var handler = HttpAuthenticationFeature.Handler; var handler = HttpAuthenticationFeature.Handler;
var signInContext = new SignInContext(authenticationScheme, principal, properties == null ? null : properties.Dictionary); var signInContext = new SignInContext(authenticationScheme, principal, properties == null ? null : properties.Items);
if (handler != null) if (handler != null)
{ {
handler.SignIn(signInContext); handler.SignIn(signInContext);
@ -120,7 +120,7 @@ namespace Microsoft.AspNet.Http.Authentication
{ {
var handler = HttpAuthenticationFeature.Handler; var handler = HttpAuthenticationFeature.Handler;
var signOutContext = new SignOutContext(authenticationScheme, properties?.Dictionary); var signOutContext = new SignOutContext(authenticationScheme, properties?.Items);
if (handler != null) if (handler != null)
{ {
handler.SignOut(signOutContext); handler.SignOut(signOutContext);