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


C# Newtonsoft.WriteEndObject方法代码示例

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


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

示例1: ToJson

 public static void ToJson(Newtonsoft.Json.JsonWriter jsonWriter, Stock stock)
 {
     jsonWriter.WriteStartObject();
     Madingley.Serialization.Common.Writer.PropertyInt(jsonWriter, "_FunctionalGroupIndex", stock._FunctionalGroupIndex);
     Madingley.Serialization.Common.Writer.PropertyDouble(jsonWriter, "_IndividualBodyMass", stock._IndividualBodyMass);
     Madingley.Serialization.Common.Writer.PropertyDouble(jsonWriter, "_TotalBiomass", stock._TotalBiomass);
     jsonWriter.WriteEndObject();
 }
开发者ID:timcdlucas,项目名称:Refactored-Madingley,代码行数:8,代码来源:Stock.cs

示例2: 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();
        }
开发者ID:Reddit-Mud,项目名称:RMUD,代码行数:15,代码来源:DictionaryStringObjectSerializer.cs

示例3: 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();
            }
        }
开发者ID:darksun190,项目名称:PiWeb-Api,代码行数:20,代码来源:CatalogueEntryConverter.cs

示例4: 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();
            }
        }
开发者ID:mrkurt,项目名称:mubble-old,代码行数:18,代码来源:CommentCollectionConverter.cs

示例5: 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();
        }
开发者ID:Reddit-Mud,项目名称:RMUD,代码行数:20,代码来源:ContainerSerializer.cs

示例6: 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();
            }
        }
开发者ID:darksun190,项目名称:PiWeb-Api,代码行数:27,代码来源:AttributeConverter.cs

示例7: WriteJson

            public override void WriteJson(Newtonsoft.Json.JsonWriter writer, object value, Newtonsoft.Json.JsonSerializer serializer)
            {
                NodeState NodeStateFlags = (NodeState)value;
                //Newtonsoft.Json.JsonConvert.SerializeObject

                writer.WriteStartObject();

                //foreach (NodeState CurrentFlag in Enum.GetValues(NodeStateFlags.GetType()))
                foreach (NodeState CurrentFlag in Enum.GetValues(typeof(NodeState)))
                {

                    if ((NodeStateFlags & CurrentFlag) != 0) // if (name.HasFlag(val))
                    {
                        writer.WritePropertyName(CurrentFlag.ToString());
                        serializer.Serialize(writer, "true");
                    } // End if( (NodeStateFlags & CurrentFlag) != 0)

                } // Next CurrentFlag

                writer.WriteEndObject();
            }
开发者ID:ststeiger,项目名称:Svg3Dtest,代码行数:21,代码来源:jsTreeItem.cs

示例8: 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();
        }
开发者ID:Gemikro,项目名称:PdfStamper,代码行数:82,代码来源:DataTableConverter.cs

示例9: 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();
        }
开发者ID:tomba,项目名称:dwarrowdelf,代码行数:57,代码来源:TileGridReaderWriter.cs

示例10: writeJson

        /// <summary>
        /// Writes the messages section of a protocol definition
        /// </summary>
        /// <param name="writer">writer</param>
        /// <param name="names">list of names written</param>
        /// <param name="encspace">enclosing namespace</param>
        internal void writeJson(Newtonsoft.Json.JsonTextWriter writer, SchemaNames names, string encspace)
        {
            writer.WriteStartObject();
            JsonHelper.writeIfNotNullOrEmpty(writer, "doc", this.Doc);

            if (null != this.Request)
                this.Request.WriteJsonFields(writer, names, null);

            if (null != this.Response)
            {
                writer.WritePropertyName("response");
                Response.WriteJson(writer, names, encspace);
            }

            if (null != this.Error)
            {
                writer.WritePropertyName("errors");
                this.Error.WriteJson(writer, names, encspace);
            }

            if (null != Oneway)
            {
                writer.WritePropertyName("one-way");
                writer.WriteValue(Oneway);
            }

            writer.WriteEndObject();
        }
开发者ID:torgebo,项目名称:avro,代码行数:34,代码来源:Message.cs

示例11: 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);
                    }
//.........这里部分代码省略.........
开发者ID:HaKDMoDz,项目名称:eStd,代码行数:101,代码来源:XmlNodeConverter.cs

示例12: WriteJson

        /// <summary>
        /// Writes the JSON representation of the object.
        /// </summary>
        /// <param name="writer">The <see cref="JsonWriter"/> to write to.</param>
        /// <param name="serializer">The calling serializer.</param>
        /// <param name="value">The value.</param>
        public override void WriteJson(Newtonsoft.Json.JsonWriter writer, object value, System.Serialisation.Json.JsonSerializer serializer)
        {
            IXmlNode node = WrapXml(value);

            XmlNamespaceManager manager = new XmlNamespaceManager(new NameTable());
            PushParentNamespaces(node, manager);
            
            if (!OmitRootObject)
                writer.WriteStartObject();

            SerializeNode(writer, node, manager, !OmitRootObject);
            
            if (!OmitRootObject)
                writer.WriteEndObject();
        }
开发者ID:HaKDMoDz,项目名称:eStd,代码行数:21,代码来源:XmlNodeConverter.cs

示例13: 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();
            }
        }
开发者ID:darksun190,项目名称:PiWeb-Api,代码行数:68,代码来源:ConfigurationConverter.cs

示例14: writeJson

        internal virtual void writeJson(Newtonsoft.Json.JsonTextWriter writer)
        {
            writeStartObject(writer);
            WriteProperties(writer);

            foreach (KeyValuePair<string, string> kp in this.Props)
            {
                if (log.IsDebugEnabled) log.DebugFormat("Processing \"{0}\"", kp.Key);
                if (RESERVED_PROPS.ContainsKey(kp.Key))
                {
                    if (log.IsWarnEnabled) log.WarnFormat("Skipping reserved property \"{0}\"", kp.Key);
                    continue;
                }

                writer.WritePropertyName(kp.Key);
                writer.WriteValue(kp.Value);
            }

            writer.WriteEndObject();
        }
开发者ID:thirumg,项目名称:Avro.NET,代码行数:20,代码来源:Schema.cs

示例15: ToJson

        public static void ToJson(Newtonsoft.Json.JsonWriter jsonWriter, string name, FunctionalGroupDefinitions functionalGroupDefinitions)
        {
            jsonWriter.WritePropertyName(name);
            jsonWriter.WriteStartObject();

            Madingley.Serialization.Common.Writer.PropertyKeyValuePairs(jsonWriter, "IndexLookupFromTrait", functionalGroupDefinitions.IndexLookupFromTrait,
                (jw, key, value) =>
                {
                    Madingley.Serialization.Common.Writer.PropertyInlineKeyValuePairs(jw, key, value,
                        (jw2, key2, value2) =>
                        {
                            Madingley.Serialization.Common.Writer.PropertyArray(jw2, key2, value2, Madingley.Serialization.Common.Writer.WriteInt);
                        });
                });

            Madingley.Serialization.Common.Writer.PropertyKeyValuePairs(jsonWriter, "FunctionalGroupProperties", functionalGroupDefinitions.FunctionalGroupProperties,
                (jw, key, value) =>
                {
                    Madingley.Serialization.Common.Writer.PropertyInlineArray(jw, key, value, Madingley.Serialization.Common.Writer.WriteDouble);
                });

            Madingley.Serialization.Common.Writer.PropertyKeyValuePairs(jsonWriter, "TraitLookupFromIndex", functionalGroupDefinitions.IndexLookupFromTrait,
                (jw, key, value) =>
                {
                    Madingley.Serialization.Common.Writer.PropertyInlineKeyValuePairs(jw, key, value,
                        (jw2, key2, value2) =>
                        {
                            Madingley.Serialization.Common.Writer.PropertyArray(jw2, key2, value2, Madingley.Serialization.Common.Writer.WriteInt);
                        });
                });

            Madingley.Serialization.Common.Writer.PropertyInlineArray(jsonWriter, "AllFunctionalGroupsIndex", functionalGroupDefinitions.AllFunctionalGroupsIndex, Madingley.Serialization.Common.Writer.WriteInt);

            jsonWriter.WriteEndObject();
        }
开发者ID:timcdlucas,项目名称:Refactored-Madingley,代码行数:35,代码来源:FunctionalGroupDefinitions.cs


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