本文整理汇总了C#中Newtonsoft.WriteEndArray方法的典型用法代码示例。如果您正苦于以下问题:C# Newtonsoft.WriteEndArray方法的具体用法?C# Newtonsoft.WriteEndArray怎么用?C# Newtonsoft.WriteEndArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Newtonsoft
的用法示例。
在下文中一共展示了Newtonsoft.WriteEndArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: writeJson
internal override void writeJson(Newtonsoft.Json.JsonTextWriter writer)
{
writer.WriteStartArray();
foreach (Schema schema in this.schemas)
{
schema.writeJson(writer);
}
writer.WriteEndArray();
}
示例2: 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();
}
示例3: WriteJson
public override void WriteJson(Newtonsoft.Json.JsonWriter writer, object value, JsonSerializer serializer)
{
IList items = (IList)value;
if (value != null && items.Count > 0)
{
if (items.Count == 1 && this.IsSingleItemArray())
{
Control item = (Control)items[0];
if (!item.Visible)
{
writer.WriteNull();
return;
}
if (!(item is IProxyContainer))
{
writer.WriteRawValue(this.Format(items[0] as Control));
}
else
{
List<string> ids = ((IProxyContainer)item).GetIDS();
if (ids != null && ids.Count > 0)
{
if (ids.Count == 1)
{
writer.WriteRawValue(this.Format(ids[0]));
}
else
{
writer.WriteStartArray();
foreach (string id in ids)
{
writer.WriteRawValue(this.Format(id));
}
writer.WriteEndArray();
}
}
}
}
else
{
bool visible = false;
foreach (Observable item in items)
{
if (item.Visible)
{
visible = true;
}
}
if (visible)
{
writer.WriteStartArray();
foreach (Observable item in items)
{
if (item.Visible)
{
if (!(item is IProxyContainer))
{
writer.WriteRawValue(this.Format(item));
}
else
{
List<string> ids = ((IProxyContainer)item).GetIDS();
if (ids != null && ids.Count > 0)
{
foreach (string id in ids)
{
writer.WriteRawValue(this.Format(id));
}
}
}
}
}
writer.WriteEndArray();
}
else
{
writer.WriteNull();
}
}
}
}
示例4: WriteJson
/// <summary>
/// Writes the json.
/// </summary>
/// <param name="writer">The writer.</param>
/// <param name="value">The value.</param>
/// <param name="serializer">The serializer.</param>
public override void WriteJson(Newtonsoft.Json.JsonWriter writer, object value, Newtonsoft.Json.JsonSerializer serializer) {
DataTable table = value as DataTable;
writer.WriteStartObject();
writer.WritePropertyName("TableName");
writer.WriteValue(table.TableName);
writer.WritePropertyName("Columns");
writer.WriteStartArray();
foreach (DataColumn column in table.Columns) {
writer.WriteStartObject();
writer.WritePropertyName("AllowDBNull");
writer.WriteValue(column.AllowDBNull);
writer.WritePropertyName("AutoIncrement");
writer.WriteValue(column.AutoIncrement);
writer.WritePropertyName("AutoIncrementSeed");
writer.WriteValue(column.AutoIncrementSeed);
writer.WritePropertyName("AutoIncrementStep");
writer.WriteValue(column.AutoIncrementStep);
writer.WritePropertyName("Caption");
writer.WriteValue(column.Caption);
writer.WritePropertyName("ColumnName");
writer.WriteValue(column.ColumnName);
writer.WritePropertyName("DataType");
writer.WriteValue(column.DataType.Name);
writer.WritePropertyName("DateTimeMode");
writer.WriteValue(column.DateTimeMode.ToString());
writer.WritePropertyName("DefaultValue");
writer.WriteValue(column.DefaultValue);
writer.WritePropertyName("MaxLength");
writer.WriteValue(column.MaxLength);
writer.WritePropertyName("Ordinal");
writer.WriteValue(column.Ordinal);
writer.WritePropertyName("ReadOnly");
writer.WriteValue(column.ReadOnly);
writer.WritePropertyName("Unique");
writer.WriteValue(column.Unique);
writer.WriteEndObject();
}
writer.WriteEndArray();
writer.WritePropertyName("Rows");
writer.WriteStartArray();
foreach (DataRow row in table.Rows) {
if (row.RowState != DataRowState.Deleted && row.RowState != DataRowState.Detached) {
writer.WriteStartArray();
for (int index = 0; index <= table.Columns.Count - 1; index++) {
writer.WriteValue(row[index]);
}
writer.WriteEndArray();
}
}
writer.WriteEndArray();
// Write out primary key if the table has one. This will be useful when deserializing the table.
// We will write it out as an array of column names
writer.WritePropertyName("PrimaryKey");
writer.WriteStartArray();
if (table.PrimaryKey.Length > 0) {
foreach (DataColumn column in table.PrimaryKey) {
writer.WriteValue(column.ColumnName);
}
}
writer.WriteEndArray();
writer.WriteEndObject();
}
示例5: 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();
}
}
示例6: 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();
}
示例7: Write
public void Write(Newtonsoft.Json.JsonWriter writer, object value)
{
var grid = (TileData[, ,])value;
int w = grid.GetLength(2);
int h = grid.GetLength(1);
int d = grid.GetLength(0);
writer.WriteStartObject();
writer.WritePropertyName("Width");
writer.WriteValue(w);
writer.WritePropertyName("Height");
writer.WriteValue(h);
writer.WritePropertyName("Depth");
writer.WriteValue(d);
writer.WritePropertyName("TileData");
writer.WriteStartArray();
var queue = new BlockingCollection<Tuple<int, byte[]>>();
var writerTask = Task.Factory.StartNew(() =>
{
foreach (var tuple in queue.GetConsumingEnumerable())
{
writer.WriteValue(tuple.Item1);
writer.WriteValue(tuple.Item2);
}
});
Parallel.For(0, d, z =>
{
using (var memStream = new MemoryStream())
{
using (var compressStream = new DeflateStream(memStream, CompressionMode.Compress, true))
using (var bufferedStream = new BufferedStream(compressStream))
using (var streamWriter = new BinaryWriter(bufferedStream))
{
var srcArr = grid;
for (int y = 0; y < h; ++y)
for (int x = 0; x < w; ++x)
streamWriter.Write(srcArr[z, y, x].Raw);
}
queue.Add(new Tuple<int, byte[]>(z, memStream.ToArray()));
}
});
queue.CompleteAdding();
writerTask.Wait();
writer.WriteEndArray();
writer.WriteEndObject();
}
示例8: WriteJsonFields
/// <summary>
/// Writes enum schema in JSON format
/// </summary>
/// <param name="writer">JSON writer</param>
/// <param name="names">list of named schema already written</param>
/// <param name="encspace">enclosing namespace of the enum schema</param>
protected internal override void WriteJsonFields(Newtonsoft.Json.JsonTextWriter writer,
SchemaNames names, string encspace)
{
base.WriteJsonFields(writer, names, encspace);
writer.WritePropertyName("symbols");
writer.WriteStartArray();
foreach (string s in this.Symbols)
writer.WriteValue(s);
writer.WriteEndArray();
}
示例9: WriteJsonFields
/// <summary>
/// Writes named schema in JSON format
/// </summary>
/// <param name="writer">JSON writer</param>
/// <param name="names">list of named schemas already written</param>
/// <param name="encspace">enclosing namespace of the named schema</param>
protected internal override void WriteJsonFields(Newtonsoft.Json.JsonTextWriter writer, SchemaNames names, string encspace)
{
this.SchemaName.WriteJson(writer, names, encspace);
if (null != aliases)
{
writer.WritePropertyName("aliases");
writer.WriteStartArray();
foreach (SchemaName name in aliases)
{
string fullname = (null != name.Space) ? name.Space + "." + name.Name : name.Name;
writer.WriteValue(fullname);
}
writer.WriteEndArray();
}
}
示例10: WriteJson
/// <summary>
/// Writes Protocol in JSON format
/// </summary>
/// <param name="writer">JSON writer</param>
/// <param name="names">list of named schemas already written</param>
internal void WriteJson(Newtonsoft.Json.JsonTextWriter writer, SchemaNames names)
{
writer.WriteStartObject();
JsonHelper.writeIfNotNullOrEmpty(writer, "protocol", this.Name);
JsonHelper.writeIfNotNullOrEmpty(writer, "namespace", this.Namespace);
JsonHelper.writeIfNotNullOrEmpty(writer, "doc", this.Doc);
writer.WritePropertyName("types");
writer.WriteStartArray();
foreach (Schema type in this.Types)
type.WriteJson(writer, names, this.Namespace);
writer.WriteEndArray();
writer.WritePropertyName("messages");
writer.WriteStartObject();
foreach (KeyValuePair<string,Message> message in this.Messages)
{
writer.WritePropertyName(message.Key);
message.Value.writeJson(writer, names, this.Namespace);
}
writer.WriteEndObject();
writer.WriteEndObject();
}
示例11: WriteJson
public override void WriteJson(Newtonsoft.Json.JsonWriter writer, object value, JsonSerializer serializer)
{
IList items = (IList)value;
if (value != null && items.Count > 0)
{
if (items.Count == 1 && this.IsSingleItemArray())
{
Control item = (Control)items[0];
var pnl = item as AbstractPanel;
if (!item.Visible)
{
writer.WriteNull();
return;
}
writer.WriteRawValue(this.Format(items[0] as Control));
}
else
{
bool visible = false;
foreach (Observable item in items)
{
if (item.Visible)
{
visible = true;
}
}
if (visible)
{
writer.WriteStartArray();
foreach (Observable item in items)
{
if (item.Visible)
{
writer.WriteRawValue(this.Format(item));
}
}
writer.WriteEndArray();
}
else
{
writer.WriteNull();
}
}
}
}
示例12: WriteJson
/// <summary>
/// Writes union schema in JSON format
/// </summary>
/// <param name="writer">JSON writer</param>
/// <param name="names">list of named schemas already written</param>
/// <param name="encspace">enclosing namespace of the schema</param>
protected internal override void WriteJson(Newtonsoft.Json.JsonTextWriter writer, SchemaNames names, string encspace)
{
writer.WriteStartArray();
foreach (Schema schema in this.Schemas)
schema.WriteJson(writer, names, encspace);
writer.WriteEndArray();
}
示例13: WriteProperties
protected override void WriteProperties(Newtonsoft.Json.JsonTextWriter writer)
{
base.WriteProperties(writer);
if (null != this.Fields && this.Fields.Count > 0)
{
writer.WritePropertyName("fields");
writer.WriteStartArray();
foreach (Field field in this.Fields.Values)
{
field.writeJson(writer);
}
writer.WriteEndArray();
}
}
示例14: SerializeGroupedNodes
private void SerializeGroupedNodes(Newtonsoft.Json.JsonWriter writer, IXmlNode node, XmlNamespaceManager manager, bool writePropertyName)
{
// group nodes together by name
Dictionary<string, List<IXmlNode>> nodesGroupedByName = new Dictionary<string, List<IXmlNode>>();
for (int i = 0; i < node.ChildNodes.Count; i++)
{
IXmlNode childNode = node.ChildNodes[i];
string nodeName = GetPropertyName(childNode, manager);
List<IXmlNode> nodes;
if (!nodesGroupedByName.TryGetValue(nodeName, out nodes))
{
nodes = new List<IXmlNode>();
nodesGroupedByName.Add(nodeName, nodes);
}
nodes.Add(childNode);
}
// loop through grouped nodes. write single name instances as normal,
// write multiple names together in an array
foreach (KeyValuePair<string, List<IXmlNode>> nodeNameGroup in nodesGroupedByName)
{
List<IXmlNode> groupedNodes = nodeNameGroup.Value;
bool writeArray;
if (groupedNodes.Count == 1)
{
writeArray = IsArray(groupedNodes[0]);
}
else
{
writeArray = true;
}
if (!writeArray)
{
SerializeNode(writer, groupedNodes[0], manager, writePropertyName);
}
else
{
string elementNames = nodeNameGroup.Key;
if (writePropertyName)
writer.WritePropertyName(elementNames);
writer.WriteStartArray();
for (int i = 0; i < groupedNodes.Count; i++)
{
SerializeNode(writer, groupedNodes[i], manager, false);
}
writer.WriteEndArray();
}
}
}
示例15: 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 configuration = value as Configuration;
if( configuration != null )
{
writer.WriteStartObject();
if(configuration.PartAttributes.Length > 0 )
{
writer.WritePropertyName( "partAttributes" );
writer.WriteStartArray();
foreach( var att in configuration.PartAttributes )
{
serializer.Serialize( writer, att );
}
writer.WriteEndArray();
}
if( configuration.CharacteristicAttributes.Length > 0 )
{
writer.WritePropertyName( "characteristicAttributes" );
writer.WriteStartArray();
foreach( var att in configuration.CharacteristicAttributes )
{
serializer.Serialize( writer, att );
}
writer.WriteEndArray();
}
if( configuration.MeasurementAttributes.Length > 0 )
{
writer.WritePropertyName( "measurementAttributes" );
writer.WriteStartArray();
foreach( var att in configuration.MeasurementAttributes )
{
serializer.Serialize( writer, att );
}
writer.WriteEndArray();
}
if( configuration.ValueAttributes.Length > 0 )
{
writer.WritePropertyName( "valueAttributes" );
writer.WriteStartArray();
foreach( var att in configuration.ValueAttributes )
{
serializer.Serialize( writer, att );
}
writer.WriteEndArray();
}
if( configuration.CatalogAttributes.Length > 0 )
{
writer.WritePropertyName( "catalogAttributes" );
writer.WriteStartArray();
foreach( var att in configuration.CatalogAttributes )
{
serializer.Serialize( writer, att );
}
writer.WriteEndArray();
}
writer.WriteEndObject();
}
}