本文整理汇总了C#中JsonWriter.Serialize方法的典型用法代码示例。如果您正苦于以下问题:C# JsonWriter.Serialize方法的具体用法?C# JsonWriter.Serialize怎么用?C# JsonWriter.Serialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JsonWriter
的用法示例。
在下文中一共展示了JsonWriter.Serialize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: foreach
void IJsonSerializable.Serialize(JsonWriter writer)
{
// Types
if (Types != null && Types.Any())
{
writer.WritePropertyName("types");
writer.WriteStartObject();
foreach (var type in Types)
{
writer.WritePropertyName(type);
writer.WriteRawValue(GetTypeJson(type));
}
writer.WriteEndObject();
}
if (Instances != null && Instances.Any())
{
writer.WritePropertyName("instances");
writer.WriteStartObject();
foreach (var typeItem in Instances)
{
writer.WritePropertyName(typeItem.Key);
writer.WriteStartObject();
// Serialize static property values
if (typeItem.Value.StaticProperties.Count > 0)
{
writer.WritePropertyName("static");
writer.Serialize(
typeItem.Value.StaticProperties.ToDictionary(
property => property.Name,
property => JsonConverter.GetPropertyValue(property, property.DeclaringType)));
}
// Serialize instances
foreach (var instanceItem in typeItem.Value.Instances)
{
writer.WritePropertyName(instanceItem.Key);
writer.Serialize(instanceItem.Value);
}
writer.WriteEndObject();
}
writer.WriteEndObject();
}
if (Conditions != null && Conditions.Any())
{
writer.WritePropertyName("conditions");
writer.Serialize(Conditions);
}
if (Events != null && Events.Any())
{
writer.WritePropertyName("events");
writer.Serialize(Events);
}
if (Model != null && Model.Any())
{
writer.WritePropertyName("model");
writer.Serialize(Model);
}
if (ServerInfo != null)
{
writer.WritePropertyName("serverInfo");
writer.Serialize(ServerInfo);
}
if (Changes != null && Changes.Any())
{
writer.WritePropertyName("changes");
writer.Serialize(Changes.Where(modelEvent => !(modelEvent is ModelValueChangeEvent) || ExoWeb.IncludeInClientModel(((ModelValueChangeEvent)modelEvent).Property)));
}
}