public void test_protobuf_date_time_offset_serialization() { var serviceCollection = new ServiceCollection(); serviceCollection.AddDistributedMemoryCache(); serviceCollection.AddTransient <DistributedCacheManager>(); serviceCollection.AddSingleton(new DistributedCacheEntryOptions { SlidingExpiration = new TimeSpan(0, 5, 0) }); var serviceProvider = serviceCollection.BuildServiceProvider(); var distributedCacheManager = serviceProvider.GetRequiredService <DistributedCacheManager>(); DateTimeOffsetSurrogate.Configure(); var myClass = new MyClass { DateTimeOffset = DateTimeOffset.UtcNow }; distributedCacheManager.Set("myClass", myClass); myClass = distributedCacheManager.Get <MyClass>("myClass"); DateTimeOffsetSurrogate.Configure(); distributedCacheManager.Set("myClass", myClass); myClass = distributedCacheManager.Get <MyClass>("myClass"); }
static EventSerializer() { DateTimeOffsetSurrogate.Install(TypeModel); foreach (var asm in AppDomain.CurrentDomain.GetAssemblies()) { Register(asm); } }