本文整理汇总了C#中Jayrock.Json.JsonTextWriter.WriteEndObject方法的典型用法代码示例。如果您正苦于以下问题:C# JsonTextWriter.WriteEndObject方法的具体用法?C# JsonTextWriter.WriteEndObject怎么用?C# JsonTextWriter.WriteEndObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Jayrock.Json.JsonTextWriter
的用法示例。
在下文中一共展示了JsonTextWriter.WriteEndObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Page_Load
protected void Page_Load(object sender, System.EventArgs e)
{
Response.ContentType = "application/json";
string programID = Request.QueryString["programID"];
Program program = uWiMP.TVServer.Programs.GetProgramByProgramId(Convert.ToInt32(programID));
Channel channel = uWiMP.TVServer.Channels.GetChannelByChannelId(program.IdChannel);
string timetext = string.Format("<b>{0}-{1}</b><br>", program.StartTime.ToShortTimeString(), program.EndTime.ToShortTimeString());
string title = program.Title == "" ? GetGlobalResourceObject("uWiMPStrings", "unknown_title").ToString() : program.Title;
string episodeName = program.EpisodeName == "" ? timetext : timetext + "<b>" + program.EpisodeName + "</b><br>";
string description = program.Description == "" ? GetGlobalResourceObject("uWiMPStrings", "description_not_found").ToString() : episodeName + program.Description;
using (JsonTextWriter jw = new JsonTextWriter())
{
jw.PrettyPrint = true;
jw.WriteStartObject();
jw.WriteMember("title");
jw.WriteString(title);
jw.WriteMember("description");
jw.WriteString(description);
jw.WriteMember("channel");
jw.WriteString(channel.DisplayName);
jw.WriteMember("running");
jw.WriteBoolean(program.IsRunningAt(DateTime.Now));
jw.WriteMember("scheduled");
jw.WriteBoolean(uWiMP.TVServer.Schedules.IsProgramScheduled(program));
jw.WriteEndObject();
Response.Write(jw.ToString());
}
}
示例2: Page_Load
protected void Page_Load(object sender, System.EventArgs e)
{
Response.ContentType = "application/json";
string programID = Request.QueryString["programID"];
string recordOption = Request.QueryString["option"];
bool success;
if (User.IsInRole("recorder"))
{
success = uWiMP.TVServer.Recordings.RecordProgramById(Convert.ToInt32(programID), (Recordings.RecordingType)Convert.ToInt32(recordOption));
}
else
{
success = false;
}
using (JsonTextWriter jw = new JsonTextWriter())
{
jw.PrettyPrint = true;
jw.WriteStartObject();
jw.WriteMember("result");
jw.WriteBoolean(success);
jw.WriteEndObject();
Response.Write(jw.ToString());
}
}
示例3: 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;
}
}
}
}
示例4: ReturnBoolean
static internal string ReturnBoolean(bool value)
{
JsonTextWriter jw = new JsonTextWriter();
jw.PrettyPrint = true;
jw.WriteStartObject();
jw.WriteMember("result");
jw.WriteBoolean(value);
jw.WriteEndObject();
return jw.ToString();
}
示例5: Write
public static void Write(Point point, JsonTextWriter jwriter)
{
if (point == null)
return;
if (jwriter == null)
throw new ArgumentNullException("jwriter", "A valid JSON writer object is required.");
jwriter.WriteStartObject();
jwriter.WriteMember("type");
jwriter.WriteString("Point");
jwriter.WriteMember("coordinates");
jwriter.WriteStartArray();
jwriter.WriteNumber(point.X);
jwriter.WriteNumber(point.Y);
if (!double.IsNaN(point.Z))
jwriter.WriteNumber(point.Z);
jwriter.WriteEndArray();
jwriter.WriteEndObject();
}
示例6: 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");
}
示例7: ToJSON
public void ToJSON(JsonTextWriter jwriter)
{
jwriter.WriteStartArray();
foreach (DictionaryEntry item in this.Dictionary)
{
jwriter.WriteStartObject();
jwriter.WriteMember("key");
jwriter.WriteString(item.Key.ToString());
//write the qualified type name of the value
//write the value
if (item.Value == null)
{
jwriter.WriteMember("type");
jwriter.WriteNull();
jwriter.WriteMember("value");
jwriter.WriteNull();
}
else
{
TypeConverter typeConverter = TypeDescriptor.GetConverter(item.Value.GetType());
jwriter.WriteMember("type");
jwriter.WriteString(item.Value.GetType().AssemblyQualifiedName);
jwriter.WriteMember("value");
jwriter.WriteString(typeConverter.ConvertToString(item.Value));
}
jwriter.WriteEndObject();
}
jwriter.WriteEndArray();
}
示例8: AddHashedParameters
public void AddHashedParameters(JsonTextWriter writer, params string [] list)
{
if ( list.Length % 2 > 0) return;
writer.WriteStartObject ();
for (int i = 0; i < list.Length; i+=2)
{
writer.WriteMember (list[i]);
writer.WriteString (list[i+1]);
}
writer.WriteEndObject ();
}
示例9: WriteCategories
private static void WriteCategories(IEnumerable<ICategory> categories, TextWriter writer)
{
using (var jsonWriter = new JsonTextWriter(writer))
{
jsonWriter.WriteStartArray();
foreach (var category in categories)
{
jsonWriter.WriteStartObject();
jsonWriter.WriteMember("id");
jsonWriter.WriteString(category.Id.ToString());
jsonWriter.WriteMember("name");
jsonWriter.WriteString(category.Name);
jsonWriter.WriteMember("value");
jsonWriter.WriteString(category.Name);
jsonWriter.WriteEndObject();
}
jsonWriter.WriteEndArray();
}
}
示例10: 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);
}
示例11: 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;
}
示例12: StoreText
public void StoreText(string url, string text, DateTime lastModified)
{
string file_path = Path.Combine(storage_dir, Common.MD5(url));
using (TextWriter tw = File.CreateText(file_path))
{
using (Jayrock.Json.JsonTextWriter jtw = new Jayrock.Json.JsonTextWriter(tw))
{
jtw.WriteStartObject();
jtw.WriteMember("LastModified");
jtw.WriteString(datetime_tostring(lastModified));
jtw.WriteMember("Text");
jtw.WriteString(text);
jtw.WriteEndObject();
}
}
}
示例13: SubmitWorkRpc
/// <summary>
/// Invokes the 'getwork' JSON method, submitting the proposed work. Returns <c>true</c> if the service accepts
/// the proposed work.
/// </summary>
/// <param name="work"></param>
/// <returns></returns>
public bool SubmitWorkRpc(IMiner miner, Work work, string comment)
{
var req = OpenRpc(miner, comment);
if (req == null)
return false;
// header needs to have SHA-256 padding appended
var data = Sha256.AllocateInputBuffer(80);
// prepare header buffer with SHA-256
Sha256.Prepare(data, 80, 0);
Sha256.Prepare(data, 80, 1);
// dump header data on top of padding
Array.Copy(work.Header, data, 80);
// encode in proper format
var solution = Memory.Encode(data);
Console.WriteLine();
Console.WriteLine("SOLUTION: {0,10} {1}", miner.GetType().Name, Memory.Encode(work.Header));
Console.WriteLine();
Console.WriteLine();
using (var txt = new StreamWriter(req.GetRequestStream()))
using (var wrt = new JsonTextWriter(txt))
{
wrt.WriteStartObject();
wrt.WriteMember("id");
wrt.WriteString("json");
wrt.WriteMember("method");
wrt.WriteString("getwork");
wrt.WriteMember("params");
wrt.WriteStartArray();
wrt.WriteString(solution);
wrt.WriteEndArray();
wrt.WriteEndObject();
wrt.Flush();
}
using (var txt = new StreamReader(req.GetResponse().GetResponseStream()))
using (var rdr = new JsonTextReader(txt))
{
if (!rdr.MoveToContent() && rdr.Read())
throw new JsonException("Unexpected content from 'getwork <data>'.");
var response = JsonConvert.Import<JsonSubmitWork>(rdr);
if (response == null)
throw new JsonException("No response returned.");
if (response.Error != null)
Console.WriteLine("JSON-RPC: {0}", response.Error);
Console.WriteLine();
Console.WriteLine("{0}: {1,10} {2}", response.Result ? "ACCEPTED" : "REJECTED", miner.GetType().Name, Memory.Encode(work.Header));
Console.WriteLine();
Console.WriteLine();
return response.Result;
}
}
示例14: GetWorkRpc
/// <summary>
/// Invokes the 'getwork' JSON method and parses the result into a new <see cref="T:Work"/> instance.
/// </summary>
/// <returns></returns>
public Work GetWorkRpc(IMiner miner, string comment)
{
var req = OpenRpc(miner, comment);
if (req == null)
return null;
// submit method invocation
using (var txt = new StreamWriter(req.GetRequestStream()))
using (var wrt = new JsonTextWriter(txt))
{
wrt.WriteStartObject();
wrt.WriteMember("id");
wrt.WriteString("json");
wrt.WriteMember("method");
wrt.WriteString("getwork");
wrt.WriteMember("params");
wrt.WriteStartArray();
wrt.WriteEndArray();
wrt.WriteEndObject();
wrt.Flush();
}
return ParseGetWork(req.GetResponse());
}
示例15: ConvertRequestToJson
static internal string ConvertRequestToJson(uWiMP.TVServer.MPClient.Request request)
{
JsonTextWriter jw = new JsonTextWriter();
jw.PrettyPrint = true;
jw.WriteStartObject();
jw.WriteMember("action");
jw.WriteString(request.Action);
jw.WriteMember("filter");
jw.WriteString(request.Filter);
jw.WriteMember("value");
jw.WriteString(request.Value);
jw.WriteMember("start");
jw.WriteString(request.Start.ToString());
jw.WriteMember("pagesize");
jw.WriteString(request.PageSize.ToString());
jw.WriteMember("shuffle");
jw.WriteBoolean(request.Shuffle);
jw.WriteMember("enqueue");
jw.WriteBoolean(request.Enqueue);
jw.WriteMember("tracks");
jw.WriteString(request.Tracks);
jw.WriteEndObject();
return jw.ToString();
}