dynamic ConvertToDynamicThroughSerialization(object value) { var writer = new SpanWriter(); var storedDescriptorCtx = _mapping.StoreNewDescriptors(value); storedDescriptorCtx.FinishNewDescriptors(ref writer); storedDescriptorCtx.StoreObject(ref writer, value); storedDescriptorCtx.CommitNewDescriptors(); var originalDescription = _ts.DescriptorOf(value).Describe(); var reader = new SpanReader(writer.GetSpan()); var ts = new TypeSerializers(); ts.SetTypeNameMapper(new ToDynamicMapper()); var mapping = ts.CreateMapping(); mapping.LoadTypeDescriptors(ref reader); var obj = (dynamic)mapping.LoadObject(ref reader); Assert.Equal(originalDescription, ts.DescriptorOf((object)obj) !.Describe()); return(obj); }
public void SetNewTypeNameMapper(ITypeNameMapper mapper) { _typeSerializers.SetTypeNameMapper(mapper); }