本文整理汇总了C#中Newtonsoft.WritePropertyName方法的典型用法代码示例。如果您正苦于以下问题:C# Newtonsoft.WritePropertyName方法的具体用法?C# Newtonsoft.WritePropertyName怎么用?C# Newtonsoft.WritePropertyName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Newtonsoft
的用法示例。
在下文中一共展示了Newtonsoft.WritePropertyName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteKeys
protected override void WriteKeys(Newtonsoft.Json.JsonWriter writer)
{
if (CurrencyCode != null)
{
writer.WritePropertyName("currencyCode");
writer.WriteValue(CurrencyCode);
}
if (NumberStyle != FieldNumberStyle.Unspecified)
{
writer.WritePropertyName("numberStyle");
writer.WriteValue(NumberStyle.ToString());
}
}
示例2: WriteProperties
protected override void WriteProperties(Newtonsoft.Json.JsonTextWriter writer)
{
base.WriteProperties(writer);
writer.WritePropertyName("size");
writer.WriteValue(this.size);
}
示例3: WriteProperties
protected override void WriteProperties(Newtonsoft.Json.JsonTextWriter writer)
{
if (null != this.itemSchema)
{
writer.WritePropertyName("items");
this.itemSchema.writeJson(writer);
}
}
示例4: WriteJson
/// <summary>
/// Writes the JSON representation of the object.
/// </summary>
public override void WriteJson( Newtonsoft.Json.JsonWriter writer, object value, Newtonsoft.Json.JsonSerializer serializer )
{
var catEntry = value as CatalogEntry;
if( catEntry != null )
{
writer.WriteStartObject();
writer.WritePropertyName( "key" );
writer.WriteValue( catEntry.Key );
if( catEntry.Attributes.Length > 0 )
{
writer.WritePropertyName( "attributes" );
serializer.Serialize( writer, catEntry.Attributes );
}
writer.WriteEndObject();
}
}
示例5: WriteKeys
protected override void WriteKeys(Newtonsoft.Json.JsonWriter writer)
{
if (DateStyle != FieldDateTimeStyle.Unspecified)
{
writer.WritePropertyName("dateStyle");
writer.WriteValue(DateStyle.ToString());
}
if (TimeStyle != FieldDateTimeStyle.Unspecified)
{
writer.WritePropertyName("timeStyle");
writer.WriteValue(TimeStyle.ToString());
}
writer.WritePropertyName("isRelative");
writer.WriteValue(IsRelative);
}
示例6: WriteJson
public override void WriteJson(Newtonsoft.Json.JsonWriter writer, object value)
{
CommentCollection c = value as CommentCollection;
if (c != null)
{
writer.WriteStartObject();
writer.WritePropertyName("Page");
writer.WriteValue(c.PageNumber);
writer.WritePropertyName("PageCount");
writer.WriteValue(c.Pages);
writer.WritePropertyName("PostLink");
writer.WriteValue(c.PostLink);
writer.WritePropertyName("Comments");
base.WriteJson(writer, value);
writer.WriteEndObject();
}
}
示例7: WriteJson
public override void WriteJson(Newtonsoft.Json.JsonWriter writer, object value, JsonSerializer serializer)
{
ConfigItemCollection items = (ConfigItemCollection)value;
if (value != null && items.Count > 0)
{
foreach (ConfigItem item in items)
{
writer.WritePropertyName(items.CamelName ? Ext.Net.Utilities.StringUtils.ToLowerCamelCase(item.Name) : item.Name);
writer.WriteRawValue(item.ValueToString());
}
}
}
示例8: WriteJson
public override void WriteJson(Newtonsoft.Json.JsonWriter writer, object value, JsonSerializer serializer)
{
DynamicConfigDictionary config = (DynamicConfigDictionary)value;
if (config != null)
{
var keys = config.GetDynamicMemberNames();
foreach (string key in keys)
{
writer.WritePropertyName(Ext.Net.Utilities.StringUtils.ToLowerCamelCase(key));
writer.WriteRawValue(JSON.Serialize(config.GetDynamicValue(key), new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver()));
}
}
}
示例9: WriteValue
public override void WriteValue(object Value, Newtonsoft.Json.JsonWriter Writer, MudObject Owner)
{
var contents = Value as Dictionary<String, Object>;
if (contents == null) throw new InvalidOperationException();
Writer.WriteStartObject();
foreach (var pair in contents)
{
Writer.WritePropertyName(pair.Key);
PersistAttribute._WriteValue(pair.Value, Writer, Owner);
}
Writer.WriteEndObject();
}
示例10: WriteJson
/// <summary>
/// Writes the JSON representation of the object.
/// </summary>
public override void WriteJson( Newtonsoft.Json.JsonWriter writer, object value, Newtonsoft.Json.JsonSerializer serializer )
{
var attribute = value as DataService.Attribute;
if( attribute != null )
{
writer.WritePropertyName( attribute.Key.ToString( System.Globalization.CultureInfo.InvariantCulture ) );
writer.WriteValue( attribute.Value );
}
else
{
writer.WriteStartObject();
var attributes = (DataService.Attribute[])value;
if( attributes != null && attributes.Length > 0 )
{
foreach( var att in attributes )
{
writer.WritePropertyName( att.Key.ToString( System.Globalization.CultureInfo.InvariantCulture ) );
writer.WriteValue( att.Value );
}
}
writer.WriteEndObject();
}
}
示例11: WriteValue
public override void WriteValue(object Value, Newtonsoft.Json.JsonWriter Writer, MudObject Owner)
{
var contents = Value as Dictionary<RelativeLocations, List<MudObject>>;
if (contents == null) throw new InvalidOperationException();
Writer.WriteStartObject();
foreach (var relloc in contents)
{
Writer.WritePropertyName(RelativeLocationToString(relloc.Key));
Writer.WriteStartArray();
foreach (var mudObject in relloc.Value.Where(o => o.IsNamedObject && o.IsInstance))
Writer.WriteValue(mudObject.GetFullName());
Writer.WriteEndArray();
}
Writer.WriteEndObject();
}
示例12: WriteJson
/// <summary>
/// Writes the JSON representation of the object.
/// </summary>
public override void WriteJson( Newtonsoft.Json.JsonWriter writer, object value, Newtonsoft.Json.JsonSerializer serializer )
{
var catalog = (Catalog)value;
if( catalog.Uuid != Guid.Empty )
{
writer.WriteStartObject();
writer.WritePropertyName( "uuid" );
writer.WriteValue( catalog.Uuid );
if( !String.IsNullOrEmpty( catalog.Name ) )
{
writer.WritePropertyName( "name" );
writer.WriteValue( catalog.Name );
}
if( catalog.ValidAttributes.Length > 0 )
{
writer.WritePropertyName( "validAttributes" );
writer.WriteStartArray();
foreach( var att in catalog.ValidAttributes )
{
writer.WriteValue( att );
}
writer.WriteEndArray();
}
if( catalog.CatalogEntries.Length > 0 )
{
writer.WritePropertyName( "catalogEntries" );
serializer.Serialize( writer, catalog.CatalogEntries );
}
writer.WriteEndObject();
}
}
示例13: SerializeNode
private void SerializeNode(Newtonsoft.Json.JsonWriter writer, IXmlNode node, XmlNamespaceManager manager, bool writePropertyName)
{
switch (node.NodeType)
{
case XmlNodeType.Document:
case XmlNodeType.DocumentFragment:
SerializeGroupedNodes(writer, node, manager, writePropertyName);
break;
case XmlNodeType.Element:
if (IsArray(node) && node.ChildNodes.All(n => n.LocalName == node.LocalName) && node.ChildNodes.Count > 0)
{
SerializeGroupedNodes(writer, node, manager, false);
}
else
{
manager.PushScope();
foreach (IXmlNode attribute in node.Attributes)
{
if (attribute.NamespaceUri == "http://www.w3.org/2000/xmlns/")
{
string namespacePrefix = (attribute.LocalName != "xmlns")
? attribute.LocalName
: string.Empty;
string namespaceUri = attribute.Value;
manager.AddNamespace(namespacePrefix, namespaceUri);
}
}
if (writePropertyName)
writer.WritePropertyName(GetPropertyName(node, manager));
if (!ValueAttributes(node.Attributes).Any() && node.ChildNodes.Count == 1 &&
node.ChildNodes[0].NodeType == XmlNodeType.Text)
{
// write elements with a single text child as a name value pair
writer.WriteValue(node.ChildNodes[0].Value);
}
else if (node.ChildNodes.Count == 0 && CollectionUtils.IsNullOrEmpty(node.Attributes))
{
IXmlElement element = (IXmlElement)node;
// empty element
if (element.IsEmpty)
writer.WriteNull();
else
writer.WriteValue(string.Empty);
}
else
{
writer.WriteStartObject();
for (int i = 0; i < node.Attributes.Count; i++)
{
SerializeNode(writer, node.Attributes[i], manager, true);
}
SerializeGroupedNodes(writer, node, manager, true);
writer.WriteEndObject();
}
manager.PopScope();
}
break;
case XmlNodeType.Comment:
if (writePropertyName)
writer.WriteComment(node.Value);
break;
case XmlNodeType.Attribute:
case XmlNodeType.Text:
case XmlNodeType.CDATA:
case XmlNodeType.ProcessingInstruction:
case XmlNodeType.Whitespace:
case XmlNodeType.SignificantWhitespace:
if (node.NamespaceUri == "http://www.w3.org/2000/xmlns/" && node.Value == JsonNamespaceUri)
return;
if (node.NamespaceUri == JsonNamespaceUri)
{
if (node.LocalName == "Array")
return;
}
if (writePropertyName)
writer.WritePropertyName(GetPropertyName(node, manager));
writer.WriteValue(node.Value);
break;
case XmlNodeType.XmlDeclaration:
IXmlDeclaration declaration = (IXmlDeclaration)node;
writer.WritePropertyName(GetPropertyName(node, manager));
writer.WriteStartObject();
if (!string.IsNullOrEmpty(declaration.Version))
{
writer.WritePropertyName("@version");
writer.WriteValue(declaration.Version);
}
//.........这里部分代码省略.........
示例14: writeJson
internal void writeJson(Newtonsoft.Json.JsonTextWriter writer)
{
writer.WriteStartObject();
//JsonHelper.writeIfNotNullOrEmpty(writer, "name", this.Name);
JsonHelper.writeIfNotNullOrEmpty(writer, "doc", this.Doc);
if (null != this.Request)
{
writer.WritePropertyName("request");
writer.WriteStartArray();
foreach (Parameter parameter in this.Request)
{
System.Diagnostics.Debug.Assert(parameter != null);
parameter.writeJson(writer);
}
writer.WriteEndArray();
}
if (null != this.Response)
{
writer.WritePropertyName("response");
this.Response.writeJson(writer);
}
if (null != this.Error)
{
writer.WritePropertyName("errors");
this.Error.writeJson(writer);
}
writer.WriteEndObject();
}
示例15: WriteJson
public void WriteJson(Newtonsoft.Json.JsonWriter writer)
{
writer.WritePropertyName(Name);
writer.WriteValue(Function);
}