问题标签 [bond]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
395 浏览

bond - Microsoft Bond 运行时 schemaDef

我希望有人可以说明 Microsoft Bond 运行时架构 (SchemaDef) 的常见用例。我知道在编译时不知道架构定义时会使用这些,但是如果对象的形状是流动的并且经常变化,那么运行时生成的架构可以提供什么好处?

我的用例是业务用户控制对象的形状(通过规则引擎)。可以想象,他们可以做各种可能破坏我们向后兼容性的事情(例如,反转对象上字段的顺序)。如果我们计划持久化用户创建的所有对象版本,有没有办法使用 Bond 运行时模式来管理向后/向前兼容性?我想不,好像他们从这个倒过来:

对此

我预计会出现运行时错误。这意味着使用运行时模式管理对象不会对我提供太多帮助。

运行时模式实际上有用的用例是什么?

谢谢!

0 投票
1 回答
349 浏览

c# - Bond:如何在代码生成期间更改字段和类名

我有一个结构如下的债券文件:

我正在使用此文件为 C++ 和 C# 生成代码。但在 C# 代码中,我希望字段名称大写:MyField1、MyField2。

有没有办法做到这一点?

同样,我可能希望在我的 C# 代码中将 Foo 命名为 Bar(以便与我的预绑定客户端向后兼容)。但我没有看到任何关于如何做到这一点的文档。

0 投票
1 回答
1190 浏览

c# - How do I correctly use derived classes as fields of a Microsoft Bond object

So there's no confusion, when I talk through my issue I am doing so as someone who is using the compiled classes that result from Bond schemas (that is to say I use "class" instead of "struct", etc.). I feel like it makes more cognitive sense to think of it this way.

I am using Microsoft Bond and I have a main class that has several properties, one of which is an instance of a derived class.

When creating an instance of the main class I have no problem setting the property to an instance of the derived class; however when I deserialize from binary back into the main class the property is now seen as its base class.

I have tried to cast it as the derived class but that throws a runtime exception.

The examples for using derived classes in the Bond documentation/manual have you specifying the derived class at the time of deserialization, but I am not deserializing just the derived class but the main class.

Here's an example of how I have the bond schema set up

In usage I am setting mainProperty to an instance of the DerivedExample class. What I'd expect is that after deserialization, mainProperty is still of type DerivedExample (containing property2) but what I am seeing instead is mainProperty is of type BaseExample (and doesn't contain property2)

Am I forced to use generics to do this or is there something I am missing?

EDIT: Adding examples

My code that uses the classes generated from the Bond schemas is like this.

We have a calling service that creates a message of this type and uses Bond to serialize it into a byte array before sending it on a stream.

Now we have a receiving service that is going to take this message off the stream and use Bond to deserialize it back into an object.

Full disclosure: I am actually using F# but I figured it would be better to do these in C#

0 投票
1 回答
82 浏览

bond - 将新字段添加到 Bond 模式

假设我已经序列化了一个给定的 schema A,然后A'通过向它添加一个新的可为空字段X将其更新为 schema。我可以反序列化使用A带有 schema 的 schema序列化的对象A'吗?反序列化后,新的字段会有价值null吗?

0 投票
1 回答
1342 浏览

bond - 使用 Microsoft Bond 进行 C# DateTime 序列化

我正在将我的应用程序中的内部序列化从 Jil 替换为 Bond

我正在使用 Ms Bond 属性切换简单的类,并且一切正常,直到我得到一个具有DateTime的类。然后我在序列化过程中遇到了Dictionary KeyNotFound Exception错误。

我怀疑 Bond 不支持 DateTime,是这样吗?如果是,为什么不实施?DateTime 不是基本类型,但添加自定义转换器不值得,与 protobuf-net 相比的速度增益很小,我不需要泛型,只需简单的快速反序列化器。

我希望我遗漏了一些东西,我真的很想使用 Bond,但我也需要一个简单的工具,我不能冒险破坏应用程序,因为默认情况下不支持 Date 或 Guid 之类的基本内容。经过数小时的研究,我在这里写信,而 C# Bond 的年轻指南并没有明确提到什么是支持的,什么是不支持的。

0 投票
1 回答
141 浏览

bond - 反序列化中是否使用了 Bond 字段名称?

假设我用一个字段序列化了一个给定的 Bond 结构:

然后我重命名了 .bond 文件中的字段(不更改其序数):

我还能反序列化它吗?

结构的名称呢?(NameBond在示例中。)

改变它会阻止我反序列化吗?

0 投票
1 回答
449 浏览

c# - 不推荐使用 Bond 通信框架

我已经使用债券编译器 gbc 为我创建了一些对象和服务定义:

Something_services.cs编译器使用此签名生成了一个类定义:

我想知道 IService 接口并想了解更多信息,因此来到了 Bond Communications Framework Doku ( https://microsoft.github.io/bond/manual/bond_comm.html )。首先要阅读的是,不推荐使用 Bond.Comm,您应该改用 Bond-over-gRPC ( https://microsoft.github.io/bond/manual/bond_over_grpc.html )。

我有两个问题:

  • 有人知道,为什么这已被废弃但默认情况下仍由编译器使用?
  • 有人可以解释 Bond.Comm 和 Bond-over-gRPC 之间的区别吗?

提前致谢!

编辑

第三个问题出现了:如何使用文档中提到的--grpc-flag?

0 投票
2 回答
1726 浏览

c# - C#bond 中有哪些可用的数据类型?

我想知道表示应该包含 C# 键格式的这些字段的表的最佳方法是什么?

  • 字符串名字
  • 字符串姓氏
  • 字符串 电子邮件
  • bool 已注册
  • 日期时间日期加入
  • 字符性别
  • 列出<string> 收藏夹
  • 字符串城市
  • 字符串状态
  • unit16 邮编
  • 字符串国家
  • 列出<string>FrequentPagesURLs

我想有类似这种格式的东西

我不确定在 C# 键格式中使用它们在对象存储中创建表的最佳方式是什么charDateTimeList<string>

0 投票
1 回答
331 浏览

c# - C# Bond:我的债券结构中可以有自定义类的列表吗?

我知道 Bond 支持列表,我只是想知道我们是否可以创建类似的类

那么我可以在债券文件中有这样的东西吗?

如果可能的话,任何人都可以写一个完整的债券文件应该是什么样子的例子吗?

另外我应该在哪里添加类定义才能像这样使用它?

编辑:我需要 Car 是一个绑定结构,作为 Gallery 的一部分进行序列化,所以每当我检索 Gallery 对象时,我应该能够访问和修改属于它的汽车列表。

0 投票
1 回答
113 浏览

web-services - 如何在 Bond 服务定义中实现功能?

查看Bond Comm 文档,我不清楚我为服务定义的函数是如何连接到我的代码中的特定函数的。

它是否在项目中寻找具有相同签名的函数并将其分配给端点?我缺少一些基础设置文件吗?