public SQLiteSimpleCache(ISQLitePlatform platform, SQLiteConnectionString connection, IByteSerializer defaultSerializer) : base(platform, connection) { this.CreateTable <SQliteCacheTable>(); this.serializer = defaultSerializer; this.asyncConnection = new SQLiteAsyncConnection(() => this); }
public static ArrayPoolBufferWriter <byte> Write(this IByteSerializer serializer, object?value, Type type) { var bufferWriter = new ArrayPoolBufferWriter <byte>(); serializer.Write(bufferWriter, value); return(bufferWriter); }
public static ArrayPoolBufferWriter <byte> Write <T>(this IByteSerializer <T> serializer, T value) { var bufferWriter = new ArrayPoolBufferWriter <byte>(); serializer.Write(bufferWriter, value); return(bufferWriter); }
public static Channel <T> WithByteSerializer <T>( this Channel <ReadOnlyMemory <byte> > downstreamChannel, IByteSerializer <T> serializer, BoundedChannelOptions?channelOptions = null, CancellationToken cancellationToken = default) { channelOptions ??= new BoundedChannelOptions(16) { FullMode = BoundedChannelFullMode.Wait, SingleReader = true, SingleWriter = true, AllowSynchronousContinuations = true, }; var pair = ChannelPair.CreateTwisted( Channel.CreateBounded <T>(channelOptions), Channel.CreateBounded <T>(channelOptions)); downstreamChannel.Connect(pair.Channel1, serializer.Read, Write, ChannelCompletionMode.Full, cancellationToken); return(pair.Channel2); ReadOnlyMemory <byte> Write(T value) { using var bufferWriter = serializer.Write(value); return(bufferWriter.WrittenMemory.ToArray()); } }
public static IBlobSerializer AsBlobSerializer(this IByteSerializer serializer) { return(new BlobSerializerDelegate( serializer.SerializeToBytes, (data, type) => serializer.Deserialize(data, type), serializer.CanDeserialize)); }
public static bool CanSerializeBytes <T>(this IByteSerializer serializer, T item) { var text = serializer.SerializeToBytes(item); var obj = serializer.Deserialize <T>(text); return(obj.Equals(item)); }
public static IBlobSerializer AsBlobSerializer(this IByteSerializer serializer) { var gm = typeof(IByteSerializer).GetTypeInfo().GetDeclaredMethod("Deserialize"); return(new BlobSerializerDelegate( obj => serializer.SerializeToBytes(obj), (data, type) => gm.MakeGenericMethod(type).Invoke(serializer, new[] { data }), serializer.CanDeserialize)); }
public RequestCachingBehavior(IDistributedCache cache, IByteSerializer byteSerializer, ILogger <TResponse> logger, IOptionsSnapshot <RequestCacheConfiguration> options, IDateTimeService dateTimeService) { _options = options ?? throw new ArgumentNullException(nameof(options)); _dateTimeService = dateTimeService ?? throw new ArgumentNullException(nameof(dateTimeService)); _cache = cache ?? throw new ArgumentNullException(nameof(cache)); _byteSerializer = byteSerializer ?? throw new ArgumentNullException(nameof(byteSerializer)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); }
public ZyreBackplane(CrossStitchCore core, BackplaneConfiguration config = null, IByteSerializer byteSerializer = null) { _core = core; _config = config ?? BackplaneConfiguration.GetDefault(); _byteSerializer = byteSerializer ?? new JsonByteSerializer(); // TODO: Need to expose more zyre options in the config, including broadcast port, broadcast interface, // and beacon interval. _zyre = new NetMQ.Zyre.Zyre(core.NodeId); _zyre.EnterEvent += ZyreEnterEvent; _zyre.StopEvent += ZyreStopEvent; _zyre.ExitEvent += ZyreExitEvent; _zyre.EvasiveEvent += ZyreEvasiveEvent; _zyre.JoinEvent += ZyreJoinEvent; _zyre.LeaveEvent += ZyreLeaveEvent; _zyre.WhisperEvent += ZyreWhisperEvent; _zyre.ShoutEvent += ZyreShoutEvent; }
public CastingByteSerializer(IByteSerializer untypedSerializer, Type serializedType) { UntypedSerializer = untypedSerializer; SerializedType = serializedType; }
private static bool CanDeserialize(this IByteSerializer serializer, Type type) { return(true); }
public NetMqMessageMapper(IByteSerializer byteSerializer) { _byteSerializer = byteSerializer; }
/// <summary> /// Extend base serializer with additional messages /// </summary> public Generic <T> Add(IByteSerializer <T> additionalSerializer) { _serializers.Add(additionalSerializer); return(this); }
public PracticalTest(IByteSerializer serializer) { _byteSerializer = serializer; }
public static T Read <T>(this IByteSerializer serializer, ReadOnlyMemory <byte> data) => (T)serializer.Read(data, typeof(T)) !;
public ConcurrentSessionContextManager() { _byteSerializer = new BinaryFormatterByteSerializer(); _sessionContexts = new ConcurrentDictionary <Guid, SessionContext>(); }
public ObjectEncryptor(IEncrypting encrypting, IByteSerializer byteSerializer) { _encrypting = encrypting; _byteSerializer = byteSerializer; }
public static ArrayPoolBufferWriter <byte> Write <T>(this IByteSerializer serializer, T value) // ReSharper disable once HeapView.PossibleBoxingAllocation => serializer.Write(value, typeof(T));
/// <summary> /// Initialize merged serializer with a minimum of one target /// </summary> /// <param name="core">Serializer for the core protocol specification</param> internal Generic(IByteSerializer <T> core) { _serializers.Add(core); }
public static IByteSerializer NewAsymmetric(IByteSerializer reader, IByteSerializer writer) => new AsymmetricByteSerializer(reader, writer);
public AsymmetricByteSerializer(IByteSerializer reader, IByteSerializer writer) { Reader = reader; Writer = writer; }
public CacheService(ICacheProvider cacheProvider, IByteSerializer byteSerializer) { _byteSerializer = byteSerializer; _lazyCache = new AsyncLazy <IDatabase>(cacheProvider.Get); }
public RequestCachingBehavior(IDistributedCache cache, IByteSerializer byteSerializer, ILogger <TResponse> logger) { this.cache = cache ?? throw new ArgumentNullException(nameof(cache)); this.byteSerializer = byteSerializer ?? throw new ArgumentNullException(nameof(byteSerializer)); this.logger = logger ?? throw new ArgumentNullException(nameof(logger)); }
/// <summary> /// Extension method to extend a serializer with additional serializers for type support /// </summary> /// <typeparam name="T">Type of header</typeparam> /// <param name="coreSerializer">Current serializer</param> /// <param name="extension">Additional serializer</param> /// <returns>Merged instance</returns> public static IByteSerializer <T> Extend <T>(this IByteSerializer <T> coreSerializer, IByteSerializer <T> extension) where T : IBinaryHeader, new() { return((coreSerializer as Generic <T> ?? new Generic <T>(coreSerializer)).Add(extension)); }