本文整理汇总了C#中DataFormat.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# DataFormat.ToString方法的具体用法?C# DataFormat.ToString怎么用?C# DataFormat.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataFormat
的用法示例。
在下文中一共展示了DataFormat.ToString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateHttpContentTestInput
private static void CreateHttpContentTestInput(DataFormat inputFormat, DataFormat outputFormat, Random rndGen, out HttpMethod method, out HttpContent content, out JObject expectedResult, out Dictionary<string, string> headers, out Dictionary<string, string> query, out HttpStatusCode expectedStatus)
{
method = CreateHttpMethod(rndGen);
content = null;
expectedResult = new JObject();
expectedResult.Add("method", method.Method);
expectedResult.Add("user", new JObject(new JProperty("level", "anonymous")));
JToken body = null;
string textBody = null;
if (method.Method != "GET" && method.Method != "DELETE")
{
body = CreateJson(rndGen);
if (outputFormat == DataFormat.Xml || inputFormat == DataFormat.Xml)
{
// to prevent non-XML names from interfering with checks
body = SanitizeJsonXml(body);
}
switch (inputFormat)
{
case DataFormat.Json:
// JSON
content = new StringContent(body.ToString(), Encoding.UTF8, "application/json");
break;
case DataFormat.Xml:
textBody = JsonToXml(body);
content = new StringContent(textBody, Encoding.UTF8, "text/xml");
break;
default:
textBody = body.ToString().Replace("{", "<").Replace("}", ">").Replace("[", "__[__").Replace("]", "__]__");
content = new StringContent(textBody, Encoding.UTF8, "text/plain");
break;
}
}
if (body != null)
{
if (inputFormat == DataFormat.Json)
{
expectedResult.Add("body", body);
}
else
{
expectedResult.Add("body", textBody);
}
}
headers = new Dictionary<string, string>();
var choice = rndGen.Next(5);
for (int j = 0; j < choice; j++)
{
string name = "x-test-zumo-" + j;
string value = CreateString(rndGen, 1, 10, Letters);
headers.Add(name, value);
}
query = CreateQueryParams(rndGen) ?? new Dictionary<string, string>();
if (query.Count > 0)
{
JObject outputQuery = new JObject();
expectedResult.Add("query", outputQuery);
foreach (var kvp in query)
{
outputQuery.Add(kvp.Key, kvp.Value);
}
}
query.Add("format", outputFormat.ToString().ToLowerInvariant());
expectedStatus = HttpStatusCode.OK;
if (rndGen.Next(4) == 0)
{
// non-200 responses
int[] options = new[] { 400, 404, 500, 201 };
int status = options[rndGen.Next(options.Length)];
expectedStatus = (HttpStatusCode)status;
query.Add("status", status.ToString(CultureInfo.InvariantCulture));
}
}
示例2: SetData
/// <summary>
/// This method to set the data for the chart
/// </summary>
/// <param name="dataSource">Data for the chart</param>
/// <param name="dataFormat">Data format. e.g. json, jsonurl, csv, xml, xmlurl</param>
public void SetData(string dataSource, DataFormat format)
{
SetChartParameter("dataSource", dataSource);
SetChartParameter("dataFormat", format.ToString());
}