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


C# JsonTextWriter.WriteMember方法代码示例

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


在下文中一共展示了JsonTextWriter.WriteMember方法的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());
            }
        }
开发者ID:rndthoughts,项目名称:ipimpplus,代码行数:32,代码来源:ProgramDetails.aspx.cs

示例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());
            }
        }
开发者ID:rndthoughts,项目名称:ipimpplus,代码行数:28,代码来源:RecordProgram.aspx.cs

示例3: 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();
        }
开发者ID:rndthoughts,项目名称:ipimpplus,代码行数:25,代码来源:MPClientRemoting.cs

示例4: 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;
                    }
                }
            }
        }
开发者ID:cupsster,项目名称:litjson,代码行数:57,代码来源:BmJayrockWriter.cs

示例5: 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();
        }
开发者ID:rndthoughts,项目名称:ipimpplus,代码行数:11,代码来源:MPClientRemoting.cs

示例6: Write

        public static void Write(MultiPolygon areas, JsonTextWriter jwriter)
        {
            if (areas == null)
                return;
            if (jwriter == null)
                throw new ArgumentNullException("jwriter", "A valid JSON writer object is required.");

            jwriter.WriteStartObject();

                jwriter.WriteMember("type");
                jwriter.WriteString("MultiPolygon");

                jwriter.WriteMember("coordinates");
                jwriter.WriteStartArray();

                    foreach (Polygon area in areas.Geometries)
                    {
                        jwriter.WriteStartArray();

                        //Write the exterior boundary or shell
                        Write(area.Shell.Coordinates, jwriter);

                        //Write all the holes
                        foreach (LineString hole in area.Holes)
                        {
                            Write(hole.Coordinates, jwriter);
                        }

                        jwriter.WriteEndArray();
                    }

                jwriter.WriteEndArray();

            jwriter.WriteEndObject();
        }
开发者ID:dtsagile,项目名称:arcstache,代码行数:35,代码来源:GeoJSONWriter.cs

示例7: 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);
        }
开发者ID:BackupTheBerlios,项目名称:tamjb,代码行数:70,代码来源:JsonRpcGetProtocol.cs

示例8: 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();
        }
开发者ID:dtsagile,项目名称:arcstache,代码行数:34,代码来源:GISSerializableDictionary.cs

示例9: 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());
        }
开发者ID:wasabii,项目名称:BitMaker,代码行数:28,代码来源:Pool.cs

示例10: Request

        private JsonTextWriter Request(int id, string method, params string[] list)
        {
            JsonTextWriter writer = new JsonTextWriter();
            string ID = id.ToString();
            
            writer.WriteStartObject();
            writer.WriteMember("jsonrpc");
            writer.WriteString("2.0");
            writer.WriteMember("id");
            writer.WriteString(ID);
            writer.WriteMember("method");
            writer.WriteString(method);
            writer.WriteMember("params");
            writer.WriteStartArray();

            foreach (string param in list)
                writer.WriteString(param);

            return writer;
        }
开发者ID:Jazzeroki,项目名称:JazzTools,代码行数:20,代码来源:LEWrapper.cs

示例11: 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;
            }
        }
开发者ID:wasabii,项目名称:BitMaker,代码行数:67,代码来源:Pool.cs

示例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();
                }
            }
        }
开发者ID:tyzmodo,项目名称:chan-archiver,代码行数:19,代码来源:CacheProvider.cs

示例13: 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();
     }
 }
开发者ID:Aleksask,项目名称:Altitude,代码行数:19,代码来源:request.ashx.cs

示例14: Request

        public JsonTextWriter Request(string method, params string [] list)
        {
            JsonTextWriter writer = new JsonTextWriter();

            writer.WriteStartObject ();
            writer.WriteMember ("jsonrpc");
            writer.WriteString ("2.0");
            writer.WriteMember ("id");
            writer.WriteString ("1");
            writer.WriteMember ("method");
            writer.WriteString (method);
            writer.WriteMember ("params");
            writer.WriteStartArray ();

            foreach (string param in list)
                writer.WriteString (param);

            return writer;
        }
开发者ID:remy22,项目名称:C--Games-Lacuna-Client,代码行数:19,代码来源:Session.cs

示例15: 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");
        }
开发者ID:zacglenn,项目名称:GroupActivityFeed,代码行数:23,代码来源:GroupActivityFeedConnector.cs


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