MessagePack-CSharp 序列化 System.Drawing.Color结构或Point结构
2021-04-23 02:30
标签:wing ref poi system 初始 format ack private pos 如题,直接序列化会报错, 好像百度不到, 自已看了半个小时的官方文档, 摸索出来了, 需要 实现一个 IMessagePackFormatter MessagePack-CSharp 序列化 System.Drawing.Color结构或Point结构 标签:wing ref poi system 初始 format ack private pos 原文地址:https://www.cnblogs.com/yangzn/p/14687495.html 1 using MessagePack;
2 using MessagePack.Formatters;
3 using MessagePack.Resolvers;
4 using System;
5 using System.Drawing;
6
7 namespace MessageTest
8 {
9 internal class Program
10 {
11 private static void Main(string[] args)
12 {
13 // 不想用属性特性的话,就需要下两行代码.
14 var resolver = MessagePack.Resolvers.CompositeResolver.Create(
15 StandardResolver.Instance,
16 CompositeResolver.Create(ColorFormatter.Instance)
17 );
18
19 var options = MessagePackSerializerOptions.Standard.WithResolver(resolver);
20 MessagePackSerializer.DefaultOptions = options;
21
22 var bin = MessagePackSerializer.Serialize(new IntKeySample() { S = Color.Red });
23
24 var obj = MessagePackSerializer.Deserialize
文章标题:MessagePack-CSharp 序列化 System.Drawing.Color结构或Point结构
文章链接:http://soscw.com/index.php/essay/78357.html