使用ProtoBuf序列化类型System.Drawing.Rectangle从.NET到C
Serialize type System.Drawing.Rectangle from .Net to C++ Using protobuf
如果我序列化(使用protobuf)c#中的矩形(system.drawing.trectangle),可以在Objective-C或C 中进行对其进行测试,因为System.Drawing.Recting.Rectangle是不是像int。
这样的常见类型如果可能的话,在C 或Objective-C?
我通过使用自己的类类型修复了它,我的意思是将System.Drawing.Rectangle替换为我自己的类,而不是包含相同的属性。
我的意思是,如果您要序列化和估算化,则必须使用常见类型。
System.Drawing.Rectangle
类型不直接在protobuf-net中支持(自动培训代码由于几个额外的属性而不会触发),所以我假设您要么有一个替代到位,或者您正在手动配置模型 - 例如:
RuntimeTypeModel.Default.Add(typeof(Rectangle),false)
.Add("X","Y","Width","Height");
在这种情况下,您需要做的是创建一个.proto架构,该模式匹配该。Protobuf-net实际上会在这里为您提供帮助:
var proto = RuntimeTypeModel.Default.GetSchema(typeof(Rectangle));
对我来说(即我使用的配置)生成:
message Rectangle {
optional int32 X = 1;
optional int32 Y = 2;
optional int32 Width = 3;
optional int32 Height = 4;
}
这应该可以从任何Protobuf实施中使用。
相关文章:
- 在 C++/CLI 中将 .NET 事件从一个 DLL 引发到另一个 DLL
- 如何在 64 位 vb.net Windows 应用程序中引用 32 位 dll
- 加载与引用 .NET DLL 位于同一文件夹中的引用的 .NET DLL 时"Not found"异常
- 是否可以在Linux上使用.Net Core 3.1创建C++/CLI代码的C#DLL
- Poco::Net::FTPClientSession 在 open() 方法上挂起 129 秒,如果 ftp 主机不存
- C++ DLL(不是 CLI)是否可以调用 .NET Core 3.0 委托?
- System.AccessViolationException:shared_ptr C# .NET 和 C++ 应用程
- C++/CLI targetting .NET Core 3.1
- 是否有可能构建面向Linux和Windows的.Net Core C++ / CLI应用程序?
- WM_PAINT消息频率:C#(.Net Framework 4.7.2 WinForms)与C++
- 如何将 VB.Net 字符串作为字符*传递给C++dll?
- 从C++标头中导入常量而不是硬编码它们:扩展 .net 控件?
- VB.NET DLL中的C++DLL函数复制
- .NET核心应用程序无法加载C++DLL
- TEA在VB.NET中的实现
- 如何使用Winforms C#或C++.Net在不更改文件中其他内容的情况下修改jpg文件中的Orientation e
- 在.NET Core 3.1中运行托管C++/CLI程序集时,映像格式错误
- 如何使函数返回数组?用于制作在VB.NET中使用的DLL
- 生成.NET包装程序需要源代码吗
- 使用ProtoBuf序列化类型System.Drawing.Rectangle从.NET到C