Skip to content

Commit

Permalink
Changed to expression bodied members. Change to out variables. (#566)
Browse files Browse the repository at this point in the history
  • Loading branch information
moerwald authored and reisenberger committed Jan 24, 2019
1 parent 0b88966 commit d7e5825
Showing 1 changed file with 6 additions and 17 deletions.
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

0 comments on commit d7e5825

Please sign in to comment.