本文整理汇总了C#中Jayrock.Json.JsonTextWriter.WriteNumber方法的典型用法代码示例。如果您正苦于以下问题:C# JsonTextWriter.WriteNumber方法的具体用法?C# JsonTextWriter.WriteNumber怎么用?C# JsonTextWriter.WriteNumber使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Jayrock.Json.JsonTextWriter
的用法示例。
在下文中一共展示了JsonTextWriter.WriteNumber方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: JayrockWriterObjects
public static void JayrockWriterObjects ()
{
for (int j = 0; j < Common.Iterations; j++) {
StringBuilder output = new StringBuilder ();
JsonWriter writer = new JsonTextWriter (new StringWriter (output));
int n = Common.SampleObject.Length;
for (int i = 0; i < n; i += 2) {
switch ((char) Common.SampleObject[i]) {
case '{':
writer.WriteStartObject ();
break;
case '}':
writer.WriteEndObject ();
break;
case '[':
writer.WriteStartArray ();
break;
case ']':
writer.WriteEndArray ();
break;
case 'P':
writer.WriteMember (
(string) Common.SampleObject[i + 1]);
break;
case 'I':
writer.WriteNumber (
(int) Common.SampleObject[i + 1]);
break;
case 'D':
writer.WriteNumber (
(double) Common.SampleObject[i + 1]);
break;
case 'S':
writer.WriteString (
(string) Common.SampleObject[i + 1]);
break;
case 'B':
writer.WriteBoolean (
(bool) Common.SampleObject[i + 1]);
break;
case 'N':
writer.WriteNull ();
break;
}
}
}
}
示例2: Write
public static void Write(Coordinate coordinate, JsonTextWriter jwriter)
{
if (coordinate == null)
return;
if (jwriter == null)
throw new ArgumentNullException("jwriter", "A valid JSON writer object is required.");
jwriter.WriteStartArray();
jwriter.WriteNumber(coordinate.X);
jwriter.WriteNumber(coordinate.Y);
if (!double.IsNaN(coordinate.Z))
jwriter.WriteNumber(coordinate.Z);
jwriter.WriteEndArray();
}
示例3: JayrockWriterNumbers
public static void JayrockWriterNumbers ()
{
for (int i = 0; i < Common.Iterations; i++) {
StringBuilder output = new StringBuilder ();
JsonWriter writer = new JsonTextWriter (new StringWriter (output));
writer.WriteStartArray ();
foreach (int n in Common.SampleInts)
writer.WriteNumber (n);
foreach (double n in Common.SampleDoubles)
writer.WriteNumber (n);
writer.WriteEndArray ();
}
}
示例4: SubscribeDailyGroupStatistics
public int SubscribeDailyGroupStatistics()
{
int nReqID = GetUniqueReqID();
foreach (int groupId in m_groupIds)
{
Jayrock.Json.JsonTextWriter jsonWriter = new Jayrock.Json.JsonTextWriter();
jsonWriter.WriteStartObject();
jsonWriter.WriteMember("version");
jsonWriter.WriteNumber(1);
jsonWriter.WriteMember("topic");
jsonWriter.WriteString("contact-center");
jsonWriter.WriteMember("request-id");
jsonWriter.WriteNumber(nReqID);
jsonWriter.WriteMember("message");
jsonWriter.WriteString("subscribe-events");
jsonWriter.WriteMember("subscribe");
jsonWriter.WriteStartArray();
jsonWriter.WriteStartArray();
jsonWriter.WriteString("ecc");
jsonWriter.WriteString("daily-group-stats");
jsonWriter.WriteStartArray();
jsonWriter.WriteString(groupId.ToString());
jsonWriter.WriteEndArray();
jsonWriter.WriteEndArray();
jsonWriter.WriteEndArray();
jsonWriter.WriteEndObject();
if (!SendRequest(jsonWriter.ToString()))
return -1;
}
return nReqID;
}
示例5: Authenticate
internal bool Authenticate()
{
Jayrock.Json.JsonTextWriter jsonWriter = new Jayrock.Json.JsonTextWriter();
jsonWriter.WriteStartObject();
jsonWriter.WriteMember("version");
jsonWriter.WriteNumber(1);
jsonWriter.WriteMember("topic");
jsonWriter.WriteString("contact-center");
jsonWriter.WriteMember("request-id");
jsonWriter.WriteNumber(GetUniqueReqID());
jsonWriter.WriteMember("message");
jsonWriter.WriteString("authenticate");
jsonWriter.WriteMember("user");
jsonWriter.WriteString(strAdapterUserName);
jsonWriter.WriteMember("password");
jsonWriter.WriteString(strAdapterPassword);
jsonWriter.WriteEndObject();
if (!SendRequest(jsonWriter.ToString()))
return false;
return ReceiveResponse("authenticate");
}
示例6: ProcessRequest
protected override void ProcessRequest()
{
string httpMethod = Request.RequestType;
if (!CaselessString.Equals(httpMethod, "GET") &&
!CaselessString.Equals(httpMethod, "HEAD"))
{
throw new JsonRpcException(string.Format("HTTP {0} is not supported for RPC execution. Use HTTP GET or HEAD only.", httpMethod));
}
string callback = Mask.NullString(Request.QueryString["jsonp"]);
bool padded = callback.Length > 0;
//
// The response type depends on whether JSONP (JSON with
// Padding) is in effect or not.
//
Response.ContentType = padded ? "text/javascript" : "application/json";
//
// Validate that the JSONP callback method conforms to the
// allowed syntax. If not, issue a client-side exception
// that will certainly help to bring problem to light, even if
// a little too aggressively.
//
if (padded)
{
if (!_jsonpex.IsMatch(callback))
{
Response.Write("throw new Error('Invalid JSONP callback parameter value.');");
Response.End();
}
}
//
// Convert the query string into a call object.
//
JsonWriter writer = new JsonTextWriter();
writer.WriteStartObject();
writer.WriteMember("id");
writer.WriteNumber(-1);
writer.WriteMember("method");
string methodName = Mask.NullString(Request.PathInfo);
if (methodName.Length == 0)
{
writer.WriteNull();
}
else
{
//
// If the method name contains periods then we replace it
// with dashes to mean the one and same thing. This is
// done to provide dashes as an alternative to some periods
// since some web servers may block requests (for security
// reasons) if a path component of the URL contains more
// than one period.
//
writer.WriteString(methodName.Substring(1).Replace('-', '.'));
}
writer.WriteMember("params");
NameValueCollection query = new NameValueCollection(Request.QueryString);
query.Remove(string.Empty);
JsonConvert.Export(Request.QueryString, writer);
writer.WriteEndObject();
//
// Delegate rest of the work to JsonRpcDispatcher.
//
JsonRpcDispatcher dispatcher = new JsonRpcDispatcher(Service);
using (new JsonRpcDispatchScope(dispatcher, Context))
{
dispatcher.RequireIdempotency = true;
if (padded)
{
//
// For JSONP, see details here:
// http://bob.pythonmac.org/archives/2005/12/05/remote-json-jsonp/
//
Response.Write(callback);
Response.Write('(');
}
dispatcher.Process(new StringReader(writer.ToString()), Response.Output);
if (padded)
Response.Write(')');
//.........这里部分代码省略.........
示例7: WriteObject
public void WriteObject()
{
JsonTextWriter writer = new JsonTextWriter(new StringWriter());
writer.WriteStartObject();
writer.WriteMember("Name");
writer.WriteString("John Doe");
writer.WriteMember("Salary");
writer.WriteNumber(123456789);
writer.WriteEndObject();
Assert.AreEqual("{\"Name\":\"John Doe\",\"Salary\":123456789}", writer.ToString());
}
示例8: WriteNumber
public void WriteNumber()
{
JsonTextWriter writer = new JsonTextWriter(new StringWriter());
writer.WriteNumber(123);
Assert.AreEqual("[123]", writer.ToString());
}
示例9: ProcessRequest
protected override void ProcessRequest()
{
string httpMethod = Request.RequestType;
if (!CaselessString.Equals(httpMethod, "GET") &&
!CaselessString.Equals(httpMethod, "HEAD"))
{
throw new JsonRpcException(string.Format("HTTP {0} is not supported for RPC execution. Use HTTP GET or HEAD only.", httpMethod));
}
//
// Response will be plain text, though it would have been nice to
// be more specific, like text/json.
//
Response.ContentType = "text/plain";
//
// Convert the query string into a call object.
//
JsonWriter writer = new JsonTextWriter();
writer.WriteStartObject();
writer.WriteMember("id");
writer.WriteNumber(-1);
writer.WriteMember("method");
string methodName = Mask.NullString(Request.PathInfo);
if (methodName.Length == 0)
{
writer.WriteNull();
}
else
{
//
// If the method name contains periods then we replace it
// with dashes to mean the one and same thing. This is
// done to provide dashes as an alternative to some periods
// since some web servers may block requests (for security
// reasons) if a path component of the URL contains more
// than one period.
//
writer.WriteString(methodName.Substring(1).Replace('-', '.'));
}
writer.WriteMember("params");
NameValueCollection query = new NameValueCollection(Request.QueryString);
query.Remove(string.Empty);
JsonConvert.Export(Request.QueryString, writer);
writer.WriteEndObject();
//
// Delegate rest of the work to JsonRpcDispatcher.
//
JsonRpcDispatcher dispatcher = new JsonRpcDispatcher(Service);
dispatcher.RequireIdempotency = true;
if (HttpRequestSecurity.IsLocal(Request))
dispatcher.SetLocalExecution();
dispatcher.Process(new StringReader(writer.ToString()), Response.Output);
}
示例10: save_index
private static void save_index()
{
lock (l)
{
using (TextWriter tw = File.CreateText(FileIndexSaveFile))
{
using (JsonTextWriter jw = new JsonTextWriter(tw))
{
jw.PrettyPrint = false;
jw.WriteStartArray();
foreach (var kvp in file_index)
{
jw.WriteStartObject();
jw.WriteMember(FILE_HASH);
jw.WriteString(kvp.Key);
jw.WriteMember(DATA);
jw.WriteStartArray();
foreach (var i in kvp.Value.GetRepostsData())
{
jw.WriteStartObject();
jw.WriteMember(BOARD);
jw.WriteString(i.Board);
jw.WriteMember(FILE_NAME);
jw.WriteString(i.FileName);
jw.WriteMember(THREAD_ID);
jw.WriteNumber(i.ThreadID);
jw.WriteMember(POST_ID);
jw.WriteNumber(i.PostID);
jw.WriteEndObject();
}
jw.WriteEndArray();
jw.WriteEndObject();
}
jw.WriteEndArray();
}
}
}
need_save = false;
}
示例11: JayrockOutputFile
public static void JayrockOutputFile ()
{
using (FileStream fs = new FileStream ("jayrock_out.txt",
FileMode.Create)) {
StreamWriter out_stream = new StreamWriter (fs);
StringReader sr = new StringReader (Common.JsonText);
JsonReader reader = new JsonTextReader (sr);
out_stream.WriteLine (
"*** Reading with Jayrock.Json.JsonReader");
while (reader.Read ()) {
out_stream.Write ("Token: {0}", reader.TokenClass);
if (reader.Text != null)
out_stream.WriteLine (" Value: {0}", reader.Text);
else
out_stream.WriteLine ("");
}
out_stream.WriteLine (
"\n*** Writing with Jayrock.Json.JsonWriter");
JsonWriter writer = new JsonTextWriter (out_stream);
int n = Common.SampleObject.Length;
for (int i = 0; i < n; i += 2) {
switch ((char) Common.SampleObject[i]) {
case '{':
writer.WriteStartObject ();
break;
case '}':
writer.WriteEndObject ();
break;
case '[':
writer.WriteStartArray ();
break;
case ']':
writer.WriteEndArray ();
break;
case 'P':
writer.WriteMember (
(string) Common.SampleObject[i + 1]);
break;
case 'I':
writer.WriteNumber (
(int) Common.SampleObject[i + 1]);
break;
case 'D':
writer.WriteNumber (
(double) Common.SampleObject[i + 1]);
break;
case 'S':
writer.WriteString (
(string) Common.SampleObject[i + 1]);
break;
case 'B':
writer.WriteBoolean (
(bool) Common.SampleObject[i + 1]);
break;
case 'N':
writer.WriteNull ();
break;
}
}
out_stream.WriteLine (
"\n\n*** Data imported with " +
"Jayrock.Json.Conversion.JsonConvert\n");
Person art = (Person) JsonConvert.Import (typeof (Person),
Common.PersonJson);
out_stream.Write (art.ToString ());
out_stream.WriteLine (
"\n\n*** Object exported with " +
"Jayrock.Json.Conversion.JsonConvert\n");
out_stream.Write (JsonConvert.ExportToString (
Common.SamplePerson));
out_stream.WriteLine (
"\n\n*** Generic object exported with " +
"Jayrock.Json.Conversion.JsonConvert\n");
//.........这里部分代码省略.........