转储使用 C# 中的 Clay 构建的对象
有什么方法可以使用 C# 中的 ClaySharp 将对象转储到控制台/日志文件构建吗?
Clay 是一种动态 C# 类型,使您能够像在 JavaScript 或其他动态语言中一样轻松地雕刻任何形状的对象。 项目链接
使用 Clay 构建 Ex 对象:
// Build a Clay object
dynamic New = new ClayFactory();
dynamic directory = New.Array(
New.Person(
FirstName: "Louis",
LastName: "Dejardin",
Aliases: new[] { "Lou" }
),
New.Person(
FirstName: "Bertrand",
LastName: "Le Roy"
).Aliases("bleroy", "boudin"),
New.Person(
FirstName: "Renaud",
LastName: "Paquay"
).Aliases("Your Scruminess", "Chef")
).Name("Some Orchard folks");
Is any way to dump objects to console / logfile build with ClaySharp in C#?
Clay is a dynamic C# type that will enable you to sculpt objects of any shape just as easily as in JavaScript or other dynamic languages. Project Link
Ex object build with Clay:
// Build a Clay object
dynamic New = new ClayFactory();
dynamic directory = New.Array(
New.Person(
FirstName: "Louis",
LastName: "Dejardin",
Aliases: new[] { "Lou" }
),
New.Person(
FirstName: "Bertrand",
LastName: "Le Roy"
).Aliases("bleroy", "boudin"),
New.Person(
FirstName: "Renaud",
LastName: "Paquay"
).Aliases("Your Scruminess", "Chef")
).Name("Some Orchard folks");
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为这可能需要向 Clay 添加一个功能,因为我们所追求的详细信息位于
PropBehaviour
的私有字段内名为_behaviour
(集合)的私有字段<属性的 code>_props 集合,以及数组的ArrayBehaviour
的私有字段_data
内。也许是一个新的
ClayBehavior
(或更可能是PropBehaviour
的扩展),类似于ArrayBehaviour
的GetEnumerator
魔法,列出了所有属性...更新: 试试这个:
Sample output of the above:
I think this might take adding a feature to Clay, as the details we are after live under a private field called
_behaviour
(a collection) inside thePropBehaviour
's private field_props
collection for properties, and also inside theArrayBehaviour
's private field_data
for Arrays.Perhaps a new
ClayBehavior
(or more likely an extension toPropBehaviour
) similar toArrayBehaviour
'sGetEnumerator
magic that lists all the properties...Update: Try this:
Sample output of the above: