Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed to expression bodied members. Change to out variables. #566

Merged
merged 1 commit into from
Jan 24, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 6 additions & 17 deletions src/Polly.Shared/Registry/PolicyRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@ public class PolicyRegistry : IPolicyRegistry<string>
/// <typeparam name="TPolicy">The type of Policy.</typeparam>
/// <exception cref="ArgumentNullException"><paramref name="key"/> is null.</exception>
/// <exception cref="ArgumentException">A Policy with same <paramref name="key"/> already exists.</exception>
public void Add<TPolicy>(string key, TPolicy policy) where TPolicy : IsPolicy
{
public void Add<TPolicy>(string key, TPolicy policy) where TPolicy : IsPolicy =>
_registry.Add(key, policy);
}

/// <summary>
/// Gets of sets the <see cref="IsPolicy"/> with the specified key.
Expand All @@ -48,14 +46,8 @@ public void Add<TPolicy>(string key, TPolicy policy) where TPolicy : IsPolicy
/// <returns>The value associated with the specified key.</returns>
public IsPolicy this[string key]
{
get
{
return _registry[key];
}
set
{
_registry[key] = value;
}
get => _registry[key];
set => _registry[key] = value;
}

/// <summary>
Expand All @@ -65,10 +57,8 @@ public IsPolicy this[string key]
/// <returns>The policy stored in the registry under the given key.</returns>
/// <exception cref="ArgumentNullException"><paramref name="key"/> is null.</exception>
/// <exception cref="KeyNotFoundException">The given key was not present in the dictionary.</exception>
public TPolicy Get<TPolicy>(string key) where TPolicy : IsPolicy
{
return (TPolicy) _registry[key];
}
public TPolicy Get<TPolicy>(string key) where TPolicy : IsPolicy =>
(TPolicy) _registry[key];

/// <summary>
/// Gets the policy stored under the provided key, casting to <typeparamref name="TPolicy"/>.
Expand All @@ -83,8 +73,7 @@ public TPolicy Get<TPolicy>(string key) where TPolicy : IsPolicy
/// <returns>True if Policy exists for the provided Key. False otherwise.</returns>
public bool TryGet<TPolicy>(string key, out TPolicy policy) where TPolicy : IsPolicy
{
IsPolicy value;
bool got = _registry.TryGetValue(key, out value);
bool got = _registry.TryGetValue(key, out IsPolicy value);
policy = got ? (TPolicy)value : default(TPolicy);
return got;
}
Expand Down