本文整理汇总了C#中Newtonsoft.Json.JsonWriter.WriteWhitespace方法的典型用法代码示例。如果您正苦于以下问题:C# JsonWriter.WriteWhitespace方法的具体用法?C# JsonWriter.WriteWhitespace怎么用?C# JsonWriter.WriteWhitespace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Newtonsoft.Json.JsonWriter
的用法示例。
在下文中一共展示了JsonWriter.WriteWhitespace方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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) {
writer.WriteStartObject();
if (this.WithComment) {
var lPath = writer.Path;
var lState = writer.WriteState;
StringBuilder lComments = new StringBuilder();
int lLevel = (lPath.Split('.').Length + 1) * 2;
if (lPath == "") lLevel = 2;
writer.WriteWhitespace("\r\n");
for (int lCount = 0; lCount < mComment.Count; lCount++) {
if (lLevel > 0) writer.WriteWhitespace(new string(' ', lLevel));
writer.WriteRaw("//" + mComment[lCount]);
if (lCount + 1 < mComment.Count) writer.WriteWhitespace("\r\n");
}
}
var _properties = base.Properties();
foreach (var lProperty in _properties) {
lProperty.WriteTo(writer, converters);
}
writer.WriteEndObject();
//base.WriteTo(writer, converters);
}
示例2: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
//if (value is hAxis)
//{
// writer.WritePropertyName("hAxis");
//}
//else if (value is vAxis)
//{
// writer.WritePropertyName("hAxis");
//}
writer.WriteWhitespace(" ");
string json = ((Axis)value).ToString();
writer.WriteRawValue(json);
}
示例3: GetTestResultFromOpsDB
//.........这里部分代码省略.........
if (timeStamp != previousTestReferenceID)
{
if (testResult == null)
{
testResult = new List<TestResult>();
}
var userDetails = UserInfo.GetUserDetails((string) record["uuid"]);
testResult.Add(new TestResult
{
UUID = (string)record["uuid"],
CapbName = (string)record["capb.name"],
CapbVers = (string)record["capb.version"],
CapbServer = (string)record["capb.server"],
//ProdName = (string)record["prod.name"], // 62
//ProdVers = (string)record["prod.vers"], // 127EIKON
ProdComponentName = (string)record["prod.component.name"],
//ProdComponentVers = (string)record["prod.component.vers"], // 127ST
//TestID = Convert.ToInt32(record["testID"]), null
UserProfileUUID = (string)record["userProfile.uuid"],
//UserProfileAccountDomain = (string)record["userProfile.accountDomain"], null
UserProfileUserName = (userDetails != null) ? userDetails.UserID : "",// UIS
UserProfileEmail = (userDetails != null) ? userDetails.Email : "", // UIS
//UserProfileContactName = (string)record["userProfile.contactName"], => null
//UserProfileLocation = (string)record["userProfile.location"], => null
//UserProfileCID = (string)record["userProfile.CID"], => null
UserProfileGeoCountry = (userDetails != null) ? userDetails.Country : "", // UIS
ServerName = (string)record["server.name"],
ServerVersion = (string)record["server.version"],
ServerCompName = (string)record["server.compName"],
ServerDatacenter = (string)record["server.dataCenter"],
ServerWasDateTime = (DateTime)record["server.wasDateTime"],
ServerDbsDateTime = (DateTime)record["server.dbsDateTime"],
ClientName = (string)record["client.name"],
//ClientVersion = (string)record["client.version"], // 127ST
MachineID = record["machineID"].ToString(),
RunningMode = (string)record["runningMode"], // blank
//LocalDateTime = (DateTime)record["localDateTime"], // 73
TestCases = new List<TestCase>()
});
previousTestReferenceID = timeStamp;
numberOfTestID++;
}
var statCode = DataMapper.MapStatCode((string)record["testcase.id"]);
var statValue = (string)record["testcase.value"];
testResult[numberOfTestID - 1].TestCases.Add(
new TestCase
{
ID = statCode,
Title = (string)record["testcase.title"], // blank
Group = (string)record["testcase.group"], // blank
Valid = (string)record["testcase.valid"], // blank
Value = statValue,
Description = (string)record["testcase.description"], // blank
Recommendation = (string)record["testcase.recommendation"], // blank
RphURL = (string)record["testcase.rphURL"], // blank
ResultID = (string)record["testcase.resultID"] // blank
}
);
switch (statCode)
{
case "62":
testResult[numberOfTestID - 1].ProdName = statValue;
break;
case "127EIKON":
testResult[numberOfTestID - 1].ProdVers = statValue;
break;
case "127ST":
testResult[numberOfTestID - 1].ProdComponentVers = statValue;
testResult[numberOfTestID - 1].ClientVersion = statValue;
break;
case "27": // timezone
testResult[numberOfTestID - 1].LocalDateTime = GetLocalTestTime(testResult[numberOfTestID - 1].ServerWasDateTime, statValue);
break;
/*case "73": // local time
break;*/
}
}
if (numberOfTestID == 0)
{
ALogger.LogWarn("DataDumper.GetTestResultFromOpsDB(): no any test data in specific peroid [{0} until {1}]", startTime, endTime);
return testResult;
}
for (var i = 0; i < numberOfTestID; i++)
{
var json = JsonConvert.SerializeObject(testResult[i]);
serializer.WriteStartObject();
serializer.WriteRaw(json);
serializer.WriteEndObject();
serializer.WriteWhitespace(Environment.NewLine);
}
}
return testResult;
}
示例4: GetTestResultFromSTDB
//.........这里部分代码省略.........
"AND TR.geoLocationKey = GL.geoLocationKey " +
"AND TR.productKey = PD.productKey " +
"AND TR.clientKey = CL.clientKey " +
"AND TR.runMOdeKey = RU.runMOdeKey " +
"AND TR.serverKey = SE.serverKey " +
"AND TR.testKey = TCS.testKey " +
"AND TCS.validKey = VL.validKey " +
"AND TCS.testGroupKey = TG.testGroupKey " +
"AND TCS.testCaseKey = TC.testCaseKey " +
"AND TR.dbsDateTime >= convert(datetime, '" + startTime + "') " +
"AND TR.dbsDateTime <= convert(datetime, '" + endTime + "') " +
"ORDER BY TR.testID,testCaseOrd,testCaseName "
);
int numberOfTestID = 0;
List<TestResult> testResult = null;
using (var dataReader = command.ExecuteReader())
{
var previousTestReferenceID = string.Empty;
while (dataReader.Read())
{
var record = dataReader as IDataRecord;
var testID = (string)record["testID"];
if (testID != previousTestReferenceID)
{
if (testResult == null)
{
testResult = new List<TestResult>();
}
testResult.Add(new TestResult
{
UUID = (string)record["uuid"],
CapbName = (string)record["capb.name"],
CapbVers = (string)record["capb.version"],
CapbServer = (string)record["capb.server"],
ProdName = (string)record["prod.name"],
ProdVers = (string)record["prod.vers"],
ProdComponentName = (string)record["prod.component.name"],
ProdComponentVers = (string)record["prod.component.vers"],
TestID = Convert.ToInt32(record["testID"]),
UserProfileUUID = (string)record["userProfile.uuid"],
//UserProfileAccountDomain = (string)record["userProfile.accountDomain"],
UserProfileUserName = (string)record["userProfile.userName"],
UserProfileEmail = (string)record["userProfile.email"],
//UserProfileContactName = (string)record["userProfile.contactName"],
//UserProfileLocation = (string)record["userProfile.location"],
//UserProfileCID = (string)record["userProfile.CID"],
UserProfileGeoCountry = (string)record["userProfile.geoCountry"],
ServerName = (string)record["server.name"],
ServerVersion = (string)record["server.version"],
ServerCompName = (string)record["server.compName"],
ServerDatacenter = (string)record["server.dataCenter"],
ServerWasDateTime = (DateTime)record["server.wasDateTime"],
ServerDbsDateTime = (DateTime)record["server.dbsDateTime"],
ClientName = (string)record["client.name"],
ClientVersion = (string)record["client.version"],
MachineID = (string)record["machineID"],
RunningMode = (string)record["runningMode"],
LocalDateTime = (DateTime)record["localDateTime"],
TestCases = new List<TestCase>()
});
previousTestReferenceID = testID;
numberOfTestID++;
}
testResult[numberOfTestID - 1].TestCases.Add(
new TestCase
{
ID = (string) record["testcase.id"],
Title = (string) record["testcase.title"],
Group = (string) record["testcase.group"],
Valid = (string) record["testcase.valid"],
Value = (string) record["testcase.value"],
Description = (string) record["testcase.description"],
Recommendation = (string) record["testcase.recommendation"],
RphURL = (string) record["testcase.rphURL"],
ResultID = (string) record["testcase.resultID"]
}
);
}
if (numberOfTestID != 0)
{
for (var i = 0; i < numberOfTestID; i++)
{
var json = JsonConvert.SerializeObject(testResult[i]);
serializer.WriteStartObject();
serializer.WriteRaw(json);
serializer.WriteEndObject();
serializer.WriteWhitespace(Environment.NewLine);
}
}
}
return testResult;
}