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


C# JsonTextWriter.WriteStringArray方法代码示例

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


在下文中一共展示了JsonTextWriter.WriteStringArray方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WriteEmptyArray

 public void WriteEmptyArray()
 {
     JsonTextWriter writer = new JsonTextWriter(new StringWriter());
     writer.WriteStringArray(new string[0]);
     Assert.AreEqual("[]", writer.ToString());
 }
开发者ID:db48x,项目名称:KeeFox,代码行数:6,代码来源:TestJsonTextWriter.cs

示例2: Version1


//.........这里部分代码省略.........
                    writer.Write(parameter.Name);
                    writer.Write(", ");
                }

                writer.WriteLine("callback)");
                writer.WriteLine("{");
                writer.Indent++;

                writer.Write("return call(\"");
                writer.Write(method.Name);
                writer.Write("\", [");

                foreach (Parameter parameter in parameters)
                {
                    if (parameter.Position > 0)
                        writer.Write(',');
                    writer.Write(' ');
                    writer.Write(parameter.Name);
                }

                writer.WriteLine(" ], callback);");

                writer.Indent--;
                writer.WriteLine("}");
                writer.WriteLine();
            }

            writer.Write("var url = typeof(url) === 'string' ? url : '");
            writer.Write(url);
            writer.WriteLine("';");
            writer.WriteLine(@"var self = this;
            var nextId = 0;

            function call(method, params, callback)
            {
            var request = { id : nextId++, method : method, params : params };
            return callback == null ?
            callSync(method, request) : callAsync(method, request, callback);
            }

            function callSync(method, request)
            {
            var http = newHTTP();
            http.open('POST', url, false, self.httpUserName, self.httpPassword);
            setupHeaders(http, method);
            http.send(JSON.stringify(request));
            if (http.status != 200)
            throw { message : http.status + ' ' + http.statusText, toString : function() { return message; } };
            var response = JSON.eval(http.responseText);
            if (response.error != null) throw response.error;
            return response.result;
            }

            function callAsync(method, request, callback)
            {
            var http = newHTTP();
            http.open('POST', url, true, self.httpUserName, self.httpPassword);
            setupHeaders(http, method);
            http.onreadystatechange = function() { http_onreadystatechange(http, callback); }
            http.send(JSON.stringify(request));
            return request.id;
            }

            function setupHeaders(http, method)
            {
            http.setRequestHeader('Content-Type', 'text/plain; charset=utf-8');
            http.setRequestHeader('X-JSON-RPC', method);
            }

            function http_onreadystatechange(sender, callback)
            {
            if (sender.readyState == /* complete */ 4)
            {
            var response = sender.status == 200 ?
                JSON.eval(sender.responseText) : {};

            response.xmlHTTP = sender;

            callback(response);
            }
            }

            function newHTTP()
            {
            if (typeof(window) != 'undefined' && window.XMLHttpRequest)
            return new XMLHttpRequest(); /* IE7, Safari 1.2, Mozilla 1.0/Firefox, and Netscape 7 */
            else
            return new ActiveXObject('Microsoft.XMLHTTP'); /* WSH and IE 5 to IE 6 */
            }");

            writer.Indent--;
            writer.WriteLine("}");

            writer.WriteLine();
            writer.Write(service.Name);
            writer.Write(".rpcMethods = ");
            JsonTextWriter jsonWriter = new JsonTextWriter(writer);
            jsonWriter.WriteStringArray(methodNames);
            writer.WriteLine(";");
        }
开发者ID:bubbafat,项目名称:Hebo,代码行数:101,代码来源:JsonRpcProxyGenerator.cs

示例3: WriteArray

 public void WriteArray()
 {
     JsonTextWriter writer = new JsonTextWriter(new StringWriter());
     writer.WriteStringArray(new object[] { 123, "Hello \"Old\" World", true });
     Assert.AreEqual("[\"123\",\"Hello \\\"Old\\\" World\",\"True\"]", writer.ToString());
 }
开发者ID:db48x,项目名称:KeeFox,代码行数:6,代码来源:TestJsonTextWriter.cs

示例4: Version1


//.........这里部分代码省略.........
                }

                writer.WriteLine("callback)");
                writer.WriteLine("{");
                writer.Indent++;

                writer.Write("return rpc(new Call(\"");
                writer.Write(method.Name);
                writer.Write("\", [");

                foreach (Parameter parameter in parameters)
                {
                    if (parameter.Position > 0)
                        writer.Write(',');
                    writer.Write(' ');
                    writer.Write(parameter.Name);
                }

                writer.WriteLine(" ], callback));");

                writer.Indent--;
                writer.WriteLine("}");
                writer.WriteLine();
            }
    
            writer.Write("var url = typeof(url) === 'string' ? url : '");
            writer.Write(url);
            writer.WriteLine("';");
            writer.WriteLine(@"var self = this;
    var nextId = 0;

    function Call(method, params, callback)
    {
        this.url = url;
        this.callback = callback;
        this.request = 
        { 
            id     : ++nextId, 
            method : method, 
            params : params 
        };
    }

    function rpc(call)
    {
        return self.channel != null && typeof(self.channel.rpc) === 'function' ?
            self.channel.rpc(call) : call;
    }

    this.channel = new JayrockChannel();

    function JayrockChannel()
    {
        this.rpc = function(call)
        {
            var async = typeof(call.callback) === 'function';
            var xhr = newXHR();
            xhr.open('POST', call.url, async, this.httpUserName, this.httpPassword);
            xhr.setRequestHeader('Content-Type', this.contentType || 'application/json; charset=utf-8');
            xhr.setRequestHeader('X-JSON-RPC', call.request.method);
            if (async) xhr.onreadystatechange = function() { xhr_onreadystatechange(xhr, call.callback); }
            xhr.send(JSON.stringify(call.request));
            call.handler = xhr;
            if (async) return call;
            if (xhr.status != 200) throw new Error(xhr.status + ' ' + xhr.statusText);
            var response = JSON.eval(xhr.responseText);
            if (response.error != null) throw response.error;
            return response.result;
        }

        function xhr_onreadystatechange(sender, callback)
        {
            if (sender.readyState == /* complete */ 4)
            {
                var response = sender.status == 200 ? 
                    JSON.eval(sender.responseText) : {};
                
                callback(response, sender);
            }
        }

        function newXHR()
        {
            if (typeof(window) !== 'undefined' && window.XMLHttpRequest)
                return new XMLHttpRequest(); /* IE7, Safari 1.2, Mozilla 1.0/Firefox, and Netscape 7 */
            else
                return new ActiveXObject('Microsoft.XMLHTTP'); /* WSH and IE 5 to IE 6 */
        }
    }");
    
            writer.Indent--;
            writer.WriteLine("}");
    
            writer.WriteLine();
            writer.Write(service.Name);
            writer.Write(".rpcMethods = ");
            JsonTextWriter jsonWriter = new JsonTextWriter(writer);
            jsonWriter.WriteStringArray(methodNames);
            writer.WriteLine(";");
        }
开发者ID:BackupTheBerlios,项目名称:jayrock-svn,代码行数:101,代码来源:JsonRpcProxyGenerator.cs


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