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


C# JsonWriter.WriteRaw方法代码示例

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


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

示例1: WriteJson

            /// <summary>
            /// Write the JSON string.  This will convert all the properties to a JSON string.
            /// This is done manaully to improve conversion time.  The default serializer will check
            /// each property if it can convert.  This will convert the properties automatically.  This
            /// will double the speed.
            /// 
            /// Newtonsoft.Json.JsonConvert.SerializeObject(ensemble.InstrumentVelocityData).
            /// 
            /// </summary>
            /// <param name="writer">JSON Writer.</param>
            /// <param name="value">Object to write to JSON.</param>
            /// <param name="serializer">Serializer to convert the object.</param>
            public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
            {
                // Cast the object
                var data = value as InstrumentVelocityDataSet;

                // Start the object
                writer.Formatting = Formatting.None;            // Make the text not indented, so not as human readable.  This will save disk space
                writer.WriteStartObject();                      // Start the JSON object

                // Write the base values
                writer.WriteRaw(data.ToJsonBaseStub());
                writer.WriteRaw(",");

                // Write the float[,] array data
                // This will be an array of arrays
                // Each array element will contain an array with the 4 beam's value
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_INSTRUMENTVELOCITYDATA);
                writer.WriteStartArray();
                for (int bin = 0; bin < data.NumElements; bin++)
                {
                    // Write an array of float values for each beam's value
                    writer.WriteStartArray();

                    for (int beam = 0; beam < data.ElementsMultiplier; beam++)
                    {
                        writer.WriteValue(data.InstrumentVelocityData[bin, beam]);
                    }

                    writer.WriteEndArray();
                }
                writer.WriteEndArray();

                // End the object
                writer.WriteEndObject();
            }
开发者ID:Bobfrat,项目名称:RTI,代码行数:47,代码来源:InstrumentVelocityDataSet.cs

示例2: WriteJson

            /// <summary>
            /// Write the JSON string.  This will convert all the properties to a JSON string.
            /// This is done manaully to improve conversion time.  The default serializer will check
            /// each property if it can convert.  This will convert the properties automatically.  This
            /// will double the speed.
            /// 
            /// Newtonsoft.Json.JsonConvert.SerializeObject(ensemble.BottomTrackData).
            /// 
            /// </summary>
            /// <param name="writer">JSON Writer.</param>
            /// <param name="value">Object to write to JSON.</param>
            /// <param name="serializer">Serializer to convert the object.</param>
            public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
            {
                // Cast the object
                var data = value as BottomTrackDataSet;

                // Start the object
                writer.Formatting = Formatting.None;            // Make the text not indented, so not as human readable.  This will save disk space
                writer.WriteStartObject();                      // Start the JSON object

                // Write the base values
                writer.WriteRaw(data.ToJsonBaseStub());
                writer.WriteRaw(",");

                // FirstPingTime
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_FIRSTPINGTIME);
                writer.WriteValue(data.FirstPingTime);

                // LastPingTime
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_LASTPINGTIME);
                writer.WriteValue(data.LastPingTime);

                // Heading
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_HEADING);
                writer.WriteValue(data.Heading);

                // Pitch
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_PITCH);
                writer.WriteValue(data.Pitch);

                // Roll
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_ROLL);
                writer.WriteValue(data.Roll);

                // WaterTemp
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_WATERTEMP);
                writer.WriteValue(data.WaterTemp);

                // SystemTemp
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_SYSTEMP);
                writer.WriteValue(data.SystemTemp);

                // Salinity
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_SALINITY);
                writer.WriteValue(data.Salinity);

                // Pressure
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_PRESSURE);
                writer.WriteValue(data.Pressure);

                // TransducerDepth
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_TRANSDUCERDEPTH);
                writer.WriteValue(data.TransducerDepth);

                // SpeedOfSound
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_SPEEDOFSOUND);
                writer.WriteValue(data.SpeedOfSound);

                // Status Value
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_BT_STATUS);
                writer.WriteValue(data.Status.Value);

                // NumBeams
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_BT_NUMBEAMS);
                writer.WriteValue(data.NumBeams);

                // ActualPingCount
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_BT_ACTUALPINGCOUNT);
                writer.WriteValue(data.ActualPingCount);

                // Range
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_BT_RANGE);
                writer.WriteStartArray();
                for (int beam = 0; beam < data.NumBeams; beam++)
                {
                    writer.WriteValue(data.Range[beam]);
                }
                writer.WriteEndArray();

                // SNR
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_BT_SNR);
                writer.WriteStartArray();
                for (int beam = 0; beam < data.NumBeams; beam++)
                {
                    writer.WriteValue(data.SNR[beam]);
                }
                writer.WriteEndArray();

                // Amplitude
//.........这里部分代码省略.........
开发者ID:Bobfrat,项目名称:RTI,代码行数:101,代码来源:BottomTrackDataSet.cs

示例3: WriteJson

            /// <summary>
            /// Write the JSON string.  This will convert all the properties to a JSON string.
            /// This is done manaully to improve conversion time.  The default serializer will check
            /// each property if it can convert.  This will convert the properties automatically.  This
            /// will double the speed.
            /// 
            /// Newtonsoft.Json.JsonConvert.SerializeObject(ensemble.RangeTrackingData).
            /// 
            /// </summary>
            /// <param name="writer">JSON Writer.</param>
            /// <param name="value">Object to write to JSON.</param>
            /// <param name="serializer">Serializer to convert the object.</param>
            public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
            {
                // Cast the object
                var data = value as RangeTrackingDataSet;

                // Start the object
                writer.Formatting = Formatting.None;            // Make the text not indented, so not as human readable.  This will save disk space
                writer.WriteStartObject();                      // Start the JSON object

                // Write the base values
                writer.WriteRaw(data.ToJsonBaseStub());
                writer.WriteRaw(",");

                // Number of Beams
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_NUMBEAMS);
                writer.WriteValue(data.NumBeams);

                // SNR
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_RT_SNR);
                writer.WriteStartArray();
                for (int beam = 0; beam < data.SNR.Length; beam++)
                {
                    writer.WriteValue(data.SNR[beam]);
                }
                writer.WriteEndArray();

                // Range
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_RT_RANGE);
                writer.WriteStartArray();
                for (int beam = 0; beam < data.Range.Length; beam++)
                {
                    writer.WriteValue(data.Range[beam]);
                }
                writer.WriteEndArray();

                // Pings
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_RT_PINGS);
                writer.WriteStartArray();
                for (int beam = 0; beam < data.Pings.Length; beam++)
                {
                    writer.WriteValue(data.Pings[beam]);
                }
                writer.WriteEndArray();

                // End the object
                writer.WriteEndObject();
            }
开发者ID:rowetechinc,项目名称:RTI,代码行数:59,代码来源:RangeTrackingDataSet.cs

示例4: WriteJson

            /// <summary>
            /// Write the JSON string.  This will convert all the properties to a JSON string.
            /// This is done manaully to improve conversion time.  The default serializer will check
            /// each property if it can convert.  This will convert the properties automatically.  This
            /// will double the speed.
            /// 
            /// Newtonsoft.Json.JsonConvert.SerializeObject(ensemble.DvlData).
            /// 
            /// </summary>
            /// <param name="writer">JSON Writer.</param>
            /// <param name="value">Object to write to JSON.</param>
            /// <param name="serializer">Serializer to convert the object.</param>
            public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
            {
                // Cast the object
                var data = value as DvlDataSet;

                // Start the object
                writer.Formatting = Formatting.None;            // Make the text not indented, so not as human readable.  This will save disk space
                writer.WriteStartObject();                      // Start the JSON object

                // Write the base values
                writer.WriteRaw(data.ToJsonBaseStub());
                writer.WriteRaw(",");

                #region System

                // Subsystem Index
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_SUBSYSTEM_INDEX);
                writer.WriteValue(data.SubsystemConfig.SubSystem.Index);

                // Subsystem Code
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_SUBSYSTEM_CODE);
                writer.WriteValue(data.SubsystemConfig.SubSystem.Code);

                // CEPO Index
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_CEPOINDEX);
                writer.WriteValue(data.SubsystemConfig.CepoIndex);

                // SubsystemConfiguration Index
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_SSCONFIG_INDEX);
                writer.WriteValue(data.SubsystemConfig.SubsystemConfigIndex);

                // Sample Number
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_DVL_SAMPLENUMBER);
                writer.WriteValue(data.SampleNumber);

                // Pitch
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_DVL_PITCH);
                writer.WriteValue(data.Pitch);

                // Roll
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_DVL_ROLL);
                writer.WriteValue(data.Roll);

                // Heading
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_DVL_HEADING);
                writer.WriteValue(data.Heading);

                // Year
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_YEAR);
                writer.WriteValue(data.Year);

                // Month
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_MONTH);
                writer.WriteValue(data.Month);

                // Day
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_DAY);
                writer.WriteValue(data.Day);

                // Hour
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_HOUR);
                writer.WriteValue(data.Hour);

                // Minute
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_MINUTE);
                writer.WriteValue(data.Minute);

                // Second
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_SECOND);
                writer.WriteValue(data.Second);

                // HSec
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_HSEC);
                writer.WriteValue(data.HSec);

                // Salinity
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_SALINITY);
                writer.WriteValue(data.Salinity);

                // Temperature
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_DVL_TEMPERATURE);
                writer.WriteValue(data.WaterTemp);

                // Depth of Transducer
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_TRANSDUCERDEPTH);
                writer.WriteValue(data.TransducerDepth);

                // Speed Of Sound
//.........这里部分代码省略.........
开发者ID:rowetechinc,项目名称:RTI,代码行数:101,代码来源:DvlDataSet.cs

示例5: WriteJson

 public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
 {
     if ((value != null) && ((Legend)value).LegendPosition != LegendPostion.Default)
     {
         string s = value.ToString();
         writer.WriteRaw(s);
     }
     else
     {
         writer.WriteRaw("{}");
     }
 }
开发者ID:JulsMan,项目名称:googlevisualizationsdotnet,代码行数:12,代码来源:CustomConverters.cs

示例6: WriteJson

            /// <summary>
            /// Write the JSON string.  This will convert all the properties to a JSON string.
            /// This is done manaully to improve conversion time.  The default serializer will check
            /// each property if it can convert.  This will convert the properties automatically.  This
            /// will double the speed.
            /// 
            /// Newtonsoft.Json.JsonConvert.SerializeObject(ensemble.NmeaData).
            /// 
            /// </summary>
            /// <param name="writer">JSON Writer.</param>
            /// <param name="value">Object to write to JSON.</param>
            /// <param name="serializer">Serializer to convert the object.</param>
            public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
            {
                // Cast the object
                var data = value as NmeaDataSet;

                // Start the object
                writer.Formatting = Formatting.None;            // Make the text not indented, so not as human readable.  This will save disk space
                writer.WriteStartObject();                      // Start the JSON object

                // Write the base values
                writer.WriteRaw(data.ToJsonBaseStub());
                writer.WriteRaw(",");

                // Write the NMEA strings
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_NMEASTRINGS);
                if (data.NmeaStrings != null)
                {
                    writer.WriteStartArray();
                    for (int x = 0; x < data.NmeaStrings.Count; x++)
                    {
                        writer.WriteValue(data.NmeaStrings[x]);
                    }
                    writer.WriteEndArray();
                }
                else
                {
                    writer.WriteNull();
                }

                // End the object
                writer.WriteEndObject();
            }
开发者ID:Bobfrat,项目名称:RTI,代码行数:44,代码来源:NmeaDataSet.cs

示例7: WriteTo

 /// <summary>
 /// Writes this token to a <see cref="JsonWriter"/>.
 /// </summary>
 /// <param name="writer">A <see cref="JsonWriter"/> into which this method will write.</param>
 /// <param name="converters">A collection of <see cref="JsonConverter"/> which will be used when writing the token.</param>
 public override void WriteTo(JsonWriter writer, params JsonConverter[] converters)
 {
     switch (_valueType)
       {
     case JsonTokenType.Comment:
       writer.WriteComment(_value.ToString());
       break;
     case JsonTokenType.Integer:
       WriteConvertableValue(writer, converters, v => writer.WriteValue(Convert.ToInt64(v, CultureInfo.InvariantCulture)), _value);
       break;
     case JsonTokenType.Float:
       WriteConvertableValue(writer, converters, v => writer.WriteValue(Convert.ToDouble(v, CultureInfo.InvariantCulture)), _value);
       break;
     case JsonTokenType.String:
       WriteConvertableValue(writer, converters, v => writer.WriteValue(v.ToString()), _value);
       break;
     case JsonTokenType.Boolean:
       WriteConvertableValue(writer, converters, v => writer.WriteValue(Convert.ToBoolean(v, CultureInfo.InvariantCulture)), _value);
       break;
     case JsonTokenType.Date:
       WriteConvertableValue(writer, converters, v =>
       {
     if (v is DateTimeOffset)
       writer.WriteValue((DateTimeOffset)v);
     else
       writer.WriteValue(Convert.ToDateTime(v, CultureInfo.InvariantCulture));
       }, _value);
       break;
     case JsonTokenType.Raw:
       writer.WriteRaw(_value.ToString());
       break;
     case JsonTokenType.Null:
       writer.WriteNull();
       break;
     case JsonTokenType.Undefined:
       writer.WriteUndefined();
       break;
     default:
       throw MiscellaneousUtils.CreateArgumentOutOfRangeException("TokenType", _valueType, "Unexpected token type.");
       }
 }
开发者ID:robgreen,项目名称:nom,代码行数:46,代码来源:JValue.cs

示例8: WriteJson

            /// <summary>
            /// Write the JSON string.  This will convert all the properties to a JSON string.
            /// This is done manaully to improve conversion time.  The default serializer will check
            /// each property if it can convert.  This will convert the properties automatically.  This
            /// will double the speed.
            /// 
            /// Newtonsoft.Json.JsonConvert.SerializeObject(ensemble.EarthVelocityData).
            /// 
            /// </summary>
            /// <param name="writer">JSON Writer.</param>
            /// <param name="value">Object to write to JSON.</param>
            /// <param name="serializer">Serializer to convert the object.</param>
            public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
            {
                // Cast the object
                var data = value as EarthVelocityDataSet;

                // Start the object
                writer.Formatting = Formatting.None;            // Make the text not indented, so not as human readable.  This will save disk space
                writer.WriteStartObject();                      // Start the JSON object

                // Write the base values
                writer.WriteRaw(data.ToJsonBaseStub());
                writer.WriteRaw(",");

                // IsVelocityVectorAvail Property
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_ISVELOCITYVECTORAVAIL);
                writer.WriteValue(data.IsVelocityVectorAvail);

                // VelocityVector Property
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_VELOCITYVECTORS);
                if (data.VelocityVectors != null)
                {
                    writer.WriteStartArray();
                    for (int x = 0; x < data.VelocityVectors.Length; x++)
                    {
                        // Write the velocity vector
                        if (data.VelocityVectors[x] != null)
                        {
                            writer.WriteStartObject();
                            writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_VV_MAG);                   // Magnitude
                            writer.WriteValue(data.VelocityVectors[x].Magnitude);
                            writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_VV_XNORTH);                // Direction X North
                            writer.WriteValue(data.VelocityVectors[x].DirectionXNorth);
                            writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_VV_YNORTH);                // Direction Y North
                            writer.WriteValue(data.VelocityVectors[x].DirectionYNorth);
                            writer.WriteEndObject();
                        }
                        else
                        {
                            // Write null if the value is null
                            writer.WriteNull();
                        }
                    }
                    writer.WriteEndArray();
                }
                else
                {
                    writer.WriteNull();
                }

                // Write the float[,] array data
                // This will be an array of arrays
                // Each array element will contain an array with the 4 beam's value
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_EARTHVELOCITYDATA);
                writer.WriteStartArray();
                for (int bin = 0; bin < data.EarthVelocityData.GetLength(0); bin++)
                {
                    // Write an array of float values for each beam's value
                    writer.WriteStartArray();

                    for (int beam = 0; beam < data.EarthVelocityData.GetLength(1); beam++)
                    {
                        writer.WriteValue(data.EarthVelocityData[bin, beam]);
                    }

                    writer.WriteEndArray();
                }
                writer.WriteEndArray();

                // End the object
                writer.WriteEndObject();
            }
开发者ID:rowetechinc,项目名称:RTI,代码行数:83,代码来源:EarthVelocityDataSet.cs

示例9: WriteJson

            /// <summary>
            /// Write the JSON string.  This will convert all the properties to a JSON string.
            /// This is done manaully to improve conversion time.  The default serializer will check
            /// each property if it can convert.  This will convert the properties automatically.  This
            /// will double the speed.
            /// 
            /// Newtonsoft.Json.JsonConvert.SerializeObject(ensemble.AncillaryData).
            /// 
            /// </summary>
            /// <param name="writer">JSON Writer.</param>
            /// <param name="value">Object to write to JSON.</param>
            /// <param name="serializer">Serializer to convert the object.</param>
            public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
            {
                // Cast the object
                var data = value as AncillaryDataSet;

                // Start the object
                writer.Formatting = Formatting.None;            // Make the text not indented, so not as human readable.  This will save disk space
                writer.WriteStartObject();                      // Start the JSON object

                // Write the base values
                writer.WriteRaw(data.ToJsonBaseStub());
                writer.WriteRaw(",");

                // FirstBinRange
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_FIRSTBINRANGE);
                writer.WriteValue(data.FirstBinRange);

                // BinSize
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_BINSIZE);
                writer.WriteValue(data.BinSize);

                // FirstPingTime
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_FIRSTPINGTIME);
                writer.WriteValue(data.FirstPingTime);

                // LastPingTime
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_LASTPINGTIME);
                writer.WriteValue(data.LastPingTime);

                // Heading
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_HEADING);
                writer.WriteValue(data.Heading);

                // Pitch
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_PITCH);
                writer.WriteValue(data.Pitch);

                // Roll
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_ROLL);
                writer.WriteValue(data.Roll);

                // WaterTemp
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_WATERTEMP);
                writer.WriteValue(data.WaterTemp);

                // SystemTemp
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_SYSTEMP);
                writer.WriteValue(data.SystemTemp);

                // Salinity
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_SALINITY);
                writer.WriteValue(data.Salinity);

                // Pressure
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_PRESSURE);
                writer.WriteValue(data.Pressure);

                // TransducerDepth
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_TRANSDUCERDEPTH);
                writer.WriteValue(data.TransducerDepth);

                // SpeedOfSound
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_SPEEDOFSOUND);
                writer.WriteValue(data.SpeedOfSound);

                // End the object
                writer.WriteEndObject();
            }
开发者ID:Bobfrat,项目名称:RTI,代码行数:80,代码来源:AncillaryDataSet.cs

示例10: WriteJson

            /// <summary>
            /// Write the JSON string.  This will convert all the properties to a JSON string.
            /// This is done manaully to improve conversion time.  The default serializer will check
            /// each property if it can convert.  This will convert the properties automatically.  This
            /// will double the speed.
            /// 
            /// Newtonsoft.Json.JsonConvert.SerializeObject(ensemble.EnsembleData).
            /// 
            /// </summary>
            /// <param name="writer">JSON Writer.</param>
            /// <param name="value">Object to write to JSON.</param>
            /// <param name="serializer">Serializer to convert the object.</param>
            public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
            {
                // Cast the object
                var data = value as EnsembleDataSet;

                // Start the object
                writer.Formatting = Formatting.None;            // Make the text not indented, so not as human readable.  This will save disk space
                writer.WriteStartObject();                      // Start the JSON object

                // Write the base values
                writer.WriteRaw(data.ToJsonBaseStub());
                writer.WriteRaw(",");

                // EnsembleNumber
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_ENSEMBLENUMBER);
                writer.WriteValue(data.EnsembleNumber);

                // NumBins
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_NUMBINS);
                writer.WriteValue(data.NumBins);

                // NumBeams
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_NUMBEAMS);
                writer.WriteValue(data.NumBeams);

                // DesiredPingCount
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_DESIREDPINGCOUNT);
                writer.WriteValue(data.DesiredPingCount);

                // ActualPingCount
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_ACTUALPINGCOUNT);
                writer.WriteValue(data.ActualPingCount);

                // SysSerialNumber
                writer.WritePropertyName(DataSet.BaseDataSet.STR_JSON_SERIALNUMBER_SERIALNUMBERSTRING);
                writer.WriteValue(data.SysSerialNumber.SerialNumberString);

                // Firmware Major
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_FIRMWAREMAJOR);
                writer.WriteValue(data.SysFirmware.FirmwareMajor);

                // Firmware Minor
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_FIRMWAREMINOR);
                writer.WriteValue(data.SysFirmware.FirmwareMinor);

                // Firmware Revision
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_FIRMWAREREVISION);
                writer.WriteValue(data.SysFirmware.FirmwareRevision);

                // Firmware SubsystemCode
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_SUBSYSTEMCODE);
                writer.WriteValue(data.SysFirmware.SubsystemCode);

                // Subsystem Index
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_SUBSYSTEM_INDEX);
                writer.WriteValue(data.SubsystemConfig.SubSystem.Index);

                // Subsystem Code
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_SUBSYSTEM_CODE);
                writer.WriteValue(data.SubsystemConfig.SubSystem.Code);

                // CEPO Index
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_CEPOINDEX);
                writer.WriteValue(data.SubsystemConfig.CepoIndex);

                // SubsystemConfiguration Index
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_SSCONFIG_INDEX);
                writer.WriteValue(data.SubsystemConfig.SubsystemConfigIndex);

                // Status Value
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_STATUS);
                writer.WriteValue(data.Status.Value);

                // Year
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_YEAR);
                writer.WriteValue(data.Year);

                // Month
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_MONTH);
                writer.WriteValue(data.Month);

                // Day
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_DAY);
                writer.WriteValue(data.Day);

                // Hour
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_HOUR);
                writer.WriteValue(data.Hour);
//.........这里部分代码省略.........
开发者ID:Bobfrat,项目名称:RTI,代码行数:101,代码来源:EnsembleDataSet.cs

示例11: WriteJson

            /// <summary>
            /// Write the JSON string.  This will convert all the properties to a JSON string.
            /// This is done manaully to improve conversion time.  The default serializer will check
            /// each property if it can convert.  This will convert the properties automatically.  This
            /// will double the speed.
            /// 
            /// Newtonsoft.Json.JsonConvert.SerializeObject(ensemble.InstrumentWaterMassData).
            /// 
            /// </summary>
            /// <param name="writer">JSON Writer.</param>
            /// <param name="value">Object to write to JSON.</param>
            /// <param name="serializer">Serializer to convert the object.</param>
            public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
            {
                // Cast the object
                var data = value as InstrumentWaterMassDataSet;

                // Start the object
                writer.Formatting = Formatting.None;            // Make the text not indented, so not as human readable.  This will save disk space
                writer.WriteStartObject();                      // Start the JSON object

                // Write the base values
                writer.WriteRaw(data.ToJsonBaseStub());
                writer.WriteRaw(",");

                // Velocity X
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_VELX);
                writer.WriteValue(data.VelocityX);

                // Velocity Y
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_VELY);
                writer.WriteValue(data.VelocityY);

                // Velocity Z
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_VELZ);
                writer.WriteValue(data.VelocityZ);

                // Velocity Q
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_VELQ);
                writer.WriteValue(data.VelocityQ);

                // Water Mass Depth Layer
                writer.WritePropertyName(DataSet.BaseDataSet.JSON_STR_WATERMASSDEPTHLAYER);
                writer.WriteValue(data.WaterMassDepthLayer);

                // End the object
                writer.WriteEndObject();
            }
开发者ID:Bobfrat,项目名称:RTI,代码行数:48,代码来源:InstrumentWaterMassDataSet.cs


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