当前位置: 首页>>代码示例>>C#>>正文


C# IJsonSerializer.SerializeValue方法代码示例

本文整理汇总了C#中IJsonSerializer.SerializeValue方法的典型用法代码示例。如果您正苦于以下问题:C# IJsonSerializer.SerializeValue方法的具体用法?C# IJsonSerializer.SerializeValue怎么用?C# IJsonSerializer.SerializeValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IJsonSerializer的用法示例。


在下文中一共展示了IJsonSerializer.SerializeValue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SerializeMembers

 /// <summary>
 /// Serialize a list of members from the object.
 /// </summary>
 /// <param name="serializer">The serializer to utilize when serializing the values.</param>
 /// <param name="type">The type of the object to serialize the members from.</param>
 /// <param name="value">The value to serialize the members from.</param>
 /// <returns>The list of members that make up the object.</returns>
 static IEnumerable<JsonMember> SerializeMembers(IJsonSerializer serializer, Type type, object value)
 {
     foreach (var property in type.GetRuntimeProperties().Where(p => p.CanRead))
     {
         yield return new JsonMember(serializer.FieldNamingStrategy.GetName(property.Name), serializer.SerializeValue(property.GetValue(value)));
     }
 }
开发者ID:cosullivan,项目名称:Hypermedia,代码行数:14,代码来源:ComplexConverter.cs

示例2: SerializeValue

 /// <summary>
 /// Serialize the value.
 /// </summary>
 /// <param name="serializer">The serializer to utilize when serializing nested objects.</param>
 /// <param name="type">The CLR type of the value to serialize.</param>
 /// <param name="value">The value to serialize.</param>
 /// <returns>The JSON value that represents the given CLR value.</returns>
 public JsonValue SerializeValue(IJsonSerializer serializer, Type type, object value)
 {
     return serializer.SerializeValue(value);
 }
开发者ID:cosullivan,项目名称:Hypermedia,代码行数:11,代码来源:NullableConverter.cs

示例3: SerializeValue

 /// <summary>
 /// Serialize a list of values.
 /// </summary>
 /// <param name="serializer">The serializer to utilize when serializing the values.</param>
 /// <param name="values">The list of values to serialize to the array.</param>
 /// <returns>The list of values that make up the array.</returns>
 static IEnumerable<JsonValue> SerializeValue(IJsonSerializer serializer, IEnumerable values)
 {
     foreach (var value in values)
     {
         yield return serializer.SerializeValue(value);
     }
 }
开发者ID:cosullivan,项目名称:Hypermedia,代码行数:13,代码来源:EnumerableConverter.cs

示例4: SerializeMembers

 /// <summary>
 /// Serialize a list of members from the object.
 /// </summary>
 /// <param name="serializer">The serializer to utilize when serializing the values.</param>
 /// <param name="contract">The contract of the object to serialize the members from.</param>
 /// <param name="value">The value to serialize the members from.</param>
 /// <returns>The list of members that make up the object.</returns>
 static IEnumerable<JsonMember> SerializeMembers(IJsonSerializer serializer, IContract contract, object value)
 {
     foreach (var field in contract.Fields.Where(ShouldSerializeField))
     {
         yield return new JsonMember(field.Name, serializer.SerializeValue(field.GetValue(value)));
     }
 }
开发者ID:cosullivan,项目名称:Hypermedia,代码行数:14,代码来源:ContractConverter.cs


注:本文中的IJsonSerializer.SerializeValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。