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


C# JsonTextWriter.WriteEndArray方法代码示例

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


在下文中一共展示了JsonTextWriter.WriteEndArray方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
                    }
                }
            }
        }
开发者ID:cupsster,项目名称:litjson,代码行数:57,代码来源:BmJayrockWriter.cs

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

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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

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

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

示例10: 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");
//.........这里部分代码省略.........
开发者ID:chenchen2015,项目名称:litjson,代码行数:101,代码来源:BmJayrockOutput.cs


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