Make UserState non-virtual; add protected impl

Makes the public UserState property non-virtual and adds a protected
virtual UserStateCore that can be overridden. This follows the pattern
of the other members.
pull/18086/head
Christopher Warrington 6 years ago
parent 2adb48acf0
commit 1232f60ac2
  1. 26
      src/csharp/Grpc.Core.Api/ServerCallContext.cs

@ -120,18 +120,7 @@ namespace Grpc.Core
/// Gets a dictionary that can be used by the various interceptors and handlers of this
/// call to store arbitrary state.
/// </summary>
public virtual IDictionary<object, object> UserState
{
get
{
if (userState == null)
{
userState = new Dictionary<object, object>();
}
return userState;
}
}
public IDictionary<object, object> UserState => UserStateCore;
/// <summary>Provides implementation of a non-virtual public member.</summary>
protected abstract Task WriteResponseHeadersAsyncCore(Metadata responseHeaders);
@ -157,5 +146,18 @@ namespace Grpc.Core
protected abstract WriteOptions WriteOptionsCore { get; set; }
/// <summary>Provides implementation of a non-virtual public member.</summary>
protected abstract AuthContext AuthContextCore { get; }
/// <summary>Provides implementation of a non-virtual public member.</summary>
protected virtual IDictionary<object, object> UserStateCore
{
get
{
if (userState == null)
{
userState = new Dictionary<object, object>();
}
return userState;
}
}
}
}

Loading…
Cancel
Save