4 implementations of IHybridCacheSerializer
Microsoft.Extensions.Caching.Hybrid (3)
Internal\DefaultJsonSerializerFactory.cs (1)
19internal sealed class DefaultJsonSerializer<T> : IHybridCacheSerializer<T>
Internal\InbuiltTypeSerializer.cs (2)
15internal sealed class InbuiltTypeSerializer : IHybridCacheSerializer<string>, IHybridCacheSerializer<byte[]>
Microsoft.Extensions.Caching.Hybrid.Tests (1)
ServiceConstructionTests.cs (1)
241private class CustomerSerializer : IHybridCacheSerializer<Customer>
33 references to IHybridCacheSerializer
Microsoft.Extensions.Caching.Abstractions (2)
Hybrid\IHybridCacheSerializerFactory.cs (2)
9/// Factory provider for per-type <see cref="IHybridCacheSerializer{T}"/> instances. 19bool TryCreateSerializer<T>([NotNullWhen(true)] out IHybridCacheSerializer<T>? serializer);
Microsoft.Extensions.Caching.Hybrid (25)
HybridCacheBuilderExtensions.cs (4)
20public static IHybridCacheBuilder AddSerializer<T>(this IHybridCacheBuilder builder, IHybridCacheSerializer<T> serializer) 22_ = Throw.IfNull(builder).Services.AddSingleton<IHybridCacheSerializer<T>>(serializer); 34where TImplementation : class, IHybridCacheSerializer<T> 36_ = Throw.IfNull(builder).Services.AddSingleton<IHybridCacheSerializer<T>, TImplementation>();
HybridCacheServiceExtensions.cs (2)
39services.TryAddSingleton<IHybridCacheSerializer<string>>(InbuiltTypeSerializer.Instance); 40services.TryAddSingleton<IHybridCacheSerializer<byte[]>>(InbuiltTypeSerializer.Instance);
Internal\DefaultHybridCache.MutableCacheItem.cs (2)
10private IHybridCacheSerializer<T> _serializer = null!; // deferred until SetValue 17public void SetValue(ref BufferChunk buffer, IHybridCacheSerializer<T> serializer)
Internal\DefaultHybridCache.Serialization.cs (7)
22internal IHybridCacheSerializer<T> GetSerializer<T>() 25? Unsafe.As<IHybridCacheSerializer<T>>(serializer) : ResolveAndAddSerializer(this); 27static IHybridCacheSerializer<T> ResolveAndAddSerializer(DefaultHybridCache @this) 31var serializer = @this._services.GetService<IHybridCacheSerializer<T>>(); 36if (factory.TryCreateSerializer<T>(out var current)) 46throw new InvalidOperationException($"No {nameof(IHybridCacheSerializer<T>)} configured for type '{typeof(T).Name}'");
Internal\DefaultHybridCache.StampedeStateT.cs (3)
206IHybridCacheSerializer<T> serializer = Cache.GetSerializer<T>(); 286IHybridCacheSerializer<T> serializer = Cache.GetSerializer<T>(); 331private void SetResultPreSerialized(T value, ref BufferChunk buffer, IHybridCacheSerializer<T> serializer)
Internal\DefaultJsonSerializerFactory.cs (3)
12public bool TryCreateSerializer<T>([NotNullWhen(true)] out IHybridCacheSerializer<T>? serializer) 21T IHybridCacheSerializer<T>.Deserialize(ReadOnlySequence<byte> source) 31void IHybridCacheSerializer<T>.Serialize(T value, IBufferWriter<byte> target)
Internal\InbuiltTypeSerializer.cs (4)
19string IHybridCacheSerializer<string>.Deserialize(ReadOnlySequence<byte> source) 39void IHybridCacheSerializer<string>.Serialize(string value, IBufferWriter<byte> target) 53byte[] IHybridCacheSerializer<byte[]>.Deserialize(ReadOnlySequence<byte> source) 56void IHybridCacheSerializer<byte[]>.Serialize(byte[] value, IBufferWriter<byte> target)
Microsoft.Extensions.Caching.Hybrid.Tests (6)
BufferReleaseTests.cs (2)
120IHybridCacheSerializer<Customer> serializer = cache.GetSerializer<Customer>(); 179IHybridCacheSerializer<Customer> serializer = cache.GetSerializer<Customer>();
ServiceConstructionTests.cs (4)
243Customer IHybridCacheSerializer<Customer>.Deserialize(ReadOnlySequence<byte> source) => throw new NotSupportedException(); 244void IHybridCacheSerializer<Customer>.Serialize(Customer value, IBufferWriter<byte> target) => throw new NotSupportedException(); 249bool IHybridCacheSerializerFactory.TryCreateSerializer<T>(out IHybridCacheSerializer<T>? serializer) 253serializer = (IHybridCacheSerializer<T>)new CustomerSerializer();