Initial Client/Server Communication
#1 Followed the MagicOnion quickstart guide, borrowing code from the chat sample app to get something working
This commit is contained in:
parent
52b0d4d8ff
commit
a0c8dbee72
493 changed files with 57790 additions and 3 deletions
|
|
@ -0,0 +1,38 @@
|
|||
// Copyright (c) All contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using MessagePack.Formatters;
|
||||
using MessagePack.Internal;
|
||||
|
||||
namespace MessagePack.Resolvers
|
||||
{
|
||||
/// <summary>
|
||||
/// A base class for <see cref="IFormatterResolver"/> classes that want to cache their responses for perf reasons.
|
||||
/// </summary>
|
||||
internal abstract class CachingFormatterResolver : IFormatterResolver
|
||||
{
|
||||
/// <summary>
|
||||
/// The cache of types to their formatters.
|
||||
/// </summary>
|
||||
private readonly ThreadsafeTypeKeyHashTable<IMessagePackFormatter> formatters = new ThreadsafeTypeKeyHashTable<IMessagePackFormatter>();
|
||||
|
||||
/// <inheritdoc />
|
||||
public IMessagePackFormatter<T> GetFormatter<T>()
|
||||
{
|
||||
if (!this.formatters.TryGetValue(typeof(T), out IMessagePackFormatter formatter))
|
||||
{
|
||||
formatter = this.GetFormatterCore<T>();
|
||||
this.formatters.TryAdd(typeof(T), formatter);
|
||||
}
|
||||
|
||||
return (IMessagePackFormatter<T>)formatter;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a formatter for a type that has not been previously cached.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type to be formatted.</typeparam>
|
||||
/// <returns>The formatter to use, or <c>null</c> if none found.</returns>
|
||||
protected abstract IMessagePackFormatter<T> GetFormatterCore<T>();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue