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


C# IndentedTextWriter.Write方法代码示例

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


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

示例1: WriteProxy

        protected override void WriteProxy(IndentedTextWriter writer)
        {
            if (writer == null)
                throw new ArgumentNullException("writer");

            writer.WriteLine("// This JavaScript was automatically generated by");
            writer.Write("// ");
            writer.WriteLine(GetType().AssemblyQualifiedName);
            writer.Write("// on ");
            DateTime now = DateTime.Now;
            TimeZone timeZone = TimeZone.CurrentTimeZone;
            writer.Write(now.ToLongDateString());
            writer.Write(" at ");
            writer.Write(now.ToLongTimeString());
            writer.Write(" (");
            writer.Write(timeZone.IsDaylightSavingTime(now) ? 
                timeZone.DaylightName : timeZone.StandardName);
            writer.WriteLine(")");
            writer.WriteLine();

            string version = Mask.EmptyString(Request.QueryString["v"], "1").Trim();

            Uri url = new Uri(Request.Url.GetLeftPart(UriPartial.Path));
            
            if (version.Equals("2"))
                Version2(Service.GetClass(), url, writer);
            else
                Version1(Service.GetClass(), url, writer);
        }
开发者ID:RyanWangTHU,项目名称:ccv2,代码行数:29,代码来源:JsonRpcProxyGenerator.cs

示例2: WriteClass

        private void WriteClass(IndentedTextWriter writer, ServiceClass serviceClass)
        {
            writer.Write("class ");
            writer.Write(serviceClass.Name);
            writer.WriteLine(":");
            writer.Indent++;

            writer.Write(_docQuotes);
            writer.Indent--;

            if (serviceClass.Description.Length > 0)
            {
                writer.WriteLine(serviceClass.Description);
                writer.WriteLine();
            }

            writer.WriteLine("This Python class was automatically generated by");
            writer.WriteLine(GetType().AssemblyQualifiedName);

            DateTime now = DateTime.Now;
            writer.Write("on ");
            writer.Write(now.ToLongDateString());
            writer.Write(" at ");
            writer.Write(now.ToLongTimeString());

            writer.Write(" (");
            TimeZone timeZone = TimeZone.CurrentTimeZone;
            writer.Write(timeZone.IsDaylightSavingTime(now) ?
                         timeZone.DaylightName : timeZone.StandardName);
            writer.WriteLine(")");

            writer.WriteLine(_docQuotes);
            writer.Indent++;

            Uri url = new Uri(Request.Url.GetLeftPart(UriPartial.Path));
            writer.WriteLine(@"def __init__(self, url = '" + url + @"'):
            self.url = url
            self.__id = 0");

            writer.WriteLine();
        }
开发者ID:BackupTheBerlios,项目名称:tamjb,代码行数:41,代码来源:JsonRpcPythonProxyGenerator.cs

示例3: ProcessRequest

        protected override void ProcessRequest()
        {
            if (!Modified())
            {
                Response.StatusCode = 304;
                return;
            }

            if (HasLastModifiedTime)
            {
                Response.Cache.SetCacheability(HttpCacheability.Public);

                //
                // Unfortunately, HttpCachePolicy.SetLastModified fails
                // if the last modified time passed has a precision higher
                // than second so we need to crop anything less than a 
                // second before setting it.
                //

                long lastModifiedTicks = LastModifiedTime.Ticks;
                Response.Cache.SetLastModified(new DateTime(lastModifiedTicks - (lastModifiedTicks % TimeSpan.TicksPerSecond)));
            }

            IRpcServiceDescriptor service = TargetService.GetDescriptor();

            Response.ContentType = "text/javascript";
            Response.AppendHeader("Content-Disposition", 
                "attachment; filename=" + service.Name + "Proxy.js");

            IndentedTextWriter writer = new IndentedTextWriter(Response.Output);

            writer.WriteLine("// This JavaScript was automatically generated by");
            writer.Write("// ");
            writer.WriteLine(GetType().AssemblyQualifiedName);
            writer.Write("// on ");
            DateTime now = DateTime.Now;
            TimeZone timeZone = TimeZone.CurrentTimeZone;
            writer.Write(now.ToLongDateString());
            writer.Write(" at ");
            writer.Write(now.ToLongTimeString());
            writer.Write(" (");
            writer.Write(timeZone.IsDaylightSavingTime(now) ? 
                timeZone.DaylightName : timeZone.StandardName);
            writer.WriteLine(")");
            writer.WriteLine();

            string version = Mask.EmptyString(Request.QueryString["v"], "1").Trim();

            if (version.Equals("2"))
                Version2(service, new Uri(Request.Url.GetLeftPart(UriPartial.Path)), writer);
            else
                Version1(service, new Uri(Request.Url.GetLeftPart(UriPartial.Path)), writer);
        }
开发者ID:BackupTheBerlios,项目名称:jayrock-svn,代码行数:53,代码来源:JsonRpcProxyGenerator.cs

示例4: ProcessRequest

        protected override void ProcessRequest()
        {
            if (!Modified())
            {
                Response.StatusCode = 304;
                return;
            }

            if (HasLastModifiedTime)
            {
                Response.Cache.SetCacheability(HttpCacheability.Public);
                Response.Cache.SetLastModified(LastModifiedTime);
            }

            JsonRpcServiceClass service = Service.GetClass();

            Response.ContentType = "text/javascript";
            Response.AppendHeader("Content-Disposition", 
                "attachment; filename=" + service.Name + "Proxy.js");

            IndentedTextWriter writer = new IndentedTextWriter(Response.Output);

            writer.WriteLine("// This JavaScript was automatically generated by");
            writer.Write("// ");
            writer.WriteLine(GetType().AssemblyQualifiedName);
            writer.Write("// on ");
            DateTime now = DateTime.Now;
            TimeZone timeZone = TimeZone.CurrentTimeZone;
            writer.Write(now.ToLongDateString());
            writer.Write(" at ");
            writer.Write(now.ToLongTimeString());
            writer.Write(" (");
            writer.Write(timeZone.IsDaylightSavingTime(now) ? 
                timeZone.DaylightName : timeZone.StandardName);
            writer.WriteLine(")");
            writer.WriteLine();

            string version = Mask.EmptyString(Request.QueryString["v"], "1").Trim();

            if (version.Equals("2"))
                Version2(service, new Uri(Request.Url.GetLeftPart(UriPartial.Path)), writer);
            else
                Version1(service, new Uri(Request.Url.GetLeftPart(UriPartial.Path)), writer);
        }
开发者ID:BackupTheBerlios,项目名称:jayrock-svn,代码行数:44,代码来源:JsonRpcProxyGenerator.cs

示例5: Version1

        private static void Version1(ServiceClass service, Uri url, IndentedTextWriter writer)
        {
            Debug.Assert(service != null);
            Debug.Assert(url!= null);
            Debug.Assert(!url.IsFile);
            Debug.Assert(writer != null);

            writer.Write("function ");
            writer.Write(service.Name);
            writer.WriteLine("(url)");
            writer.WriteLine("{");
            writer.Indent++;
            writer.WriteLine("var self = this;");
            
            Method[] methods = service.GetMethods();
            
            string[] methodNames = new string[methods.Length];
            bool[] idempotents = new bool[methods.Length];

            for (int i = 0; i < methods.Length; i++)
            {
                methodNames[i] = methods[i].Name;
                idempotents[i] = methods[i].Idempotent;
            }

            writer.Write("var m = ");
            JsonConvert.Export(methodNames, writer);
            writer.WriteLine(';');
            writer.Write("var idems = ");
            JsonConvert.Export(idempotents, writer);
            writer.WriteLine(';');
            writer.WriteLine();
    
            for (int i = 0; i < methods.Length; i++)
            {
                Method method = methods[i];
                string index = i.ToString(CultureInfo.InvariantCulture);

                if (method.Description.Length > 0)
                {
                    // TODO: What to do if summary breaks over several lines?

                    writer.Write("// ");
                    writer.WriteLine(method.Description);
                    writer.WriteLine();
                }

                writer.Write("this[m[");
                writer.Write(index);
                writer.Write("]] = function /* "); 
                writer.Write(method.Name);
                writer.Write(" */ (");

                Parameter[] parameters = method.GetParameters();
                
                foreach (Parameter parameter in parameters)
                {
                    writer.Write(parameter.Name);
                    writer.Write(", ");
                }

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

                writer.Write("if (self.kwargs) return rpc(new Call(");
                writer.Write(index);
                writer.Write(", {");

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

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

                writer.Write("return rpc(new Call(");
                writer.Write(index);
                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();
            }
    
//.........这里部分代码省略.........
开发者ID:RyanWangTHU,项目名称:ccv2,代码行数:101,代码来源:JsonRpcProxyGenerator.cs

示例6: Version2

        private void Version2(ServiceClass service, Uri url, IndentedTextWriter writer)
        {
            Debug.Assert(service != null);
            Debug.Assert(url!= null);
            Debug.Assert(!url.IsFile);
            Debug.Assert(writer != null);
            
            if (JsonRpcTrace.TraceWarning)
            {
                writer.WriteLine(@"// *** O B S O L E T E *** 
//
// You are using version 2 of the JavaScript proxy that MAY 
// be obsoleted and removed in the next release. The functionality has 
// been integrated into the original proxy version via the channel 
// property on the JavaScript proxy.
");
            }
 
            writer.WriteLine("// Proxy version 2.0");
            writer.WriteLine();
 
            writer.Write("var ");
            writer.Write(service.Name);
            writer.Write(@" = function()
{
    var nextId = 0;

    var proxy = {

        url : """);
            writer.Write(url);
            writer.Write(@""",
        rpc : {");
            writer.WriteLine();
            writer.Indent += 3;
    
            Method[] methods = service.GetMethods();
            
            string[] methodNames = new string[methods.Length];
            for (int i = 0; i < methods.Length; i++)
                methodNames[i] = methods[i].Name;
            
            Array.Sort(methodNames, methods);
    
            for (int i = 0; i < methods.Length; i++)
            {
                Method method = methods[i];

                writer.WriteLine();

                if (method.Description.Length > 0)
                {
                    // TODO: What to do if /* and */ appear in the summary?

                    writer.Write("/* ");
                    writer.Write(method.Description);
                    writer.WriteLine(" */");
                    writer.WriteLine();
                }

                writer.Write('\"');
                writer.Write(method.Name);
                writer.Write("\" : function(");

                Parameter[] parameters = method.GetParameters();
                
                foreach (Parameter parameter in parameters)
                {
                    writer.Write(parameter.Name);
                    writer.Write(", ");
                }

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

                writer.Write("return 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.Write("}");
                if (i < (methods.Length - 1))
                    writer.Write(',');
                writer.WriteLine();
            }
    
            writer.Indent--;
            writer.WriteLine(@"}
    }

//.........这里部分代码省略.........
开发者ID:RyanWangTHU,项目名称:ccv2,代码行数:101,代码来源:JsonRpcProxyGenerator.cs

示例7: WriteProxy

        protected override void WriteProxy(IndentedTextWriter writer)
        {
            if (writer == null)
                throw new ArgumentNullException("writer");

            writer.WriteLine("# This PowerShell script was automatically generated by");
            writer.Write("# ");
            writer.WriteLine(GetType().AssemblyQualifiedName);
            writer.Write("# on ");
            DateTime now = DateTime.Now;
            TimeZone timeZone = TimeZone.CurrentTimeZone;
            writer.Write(now.ToLongDateString());
            writer.Write(" at ");
            writer.Write(now.ToLongTimeString());
            writer.Write(" (");
            writer.Write(timeZone.IsDaylightSavingTime(now) ? 
                timeZone.DaylightName : timeZone.StandardName);
            writer.WriteLine(")");
            writer.WriteLine();

            Uri url = new Uri(Request.Url.GetLeftPart(UriPartial.Path));
            ServiceClass service = Service.GetClass();

            writer.Write("function ");
            writer.Write(service.Name);
            writer.WriteLine(" {");
            writer.Indent++;
            writer.Write("param($url = '");
            writer.Write(url.ToString());
            writer.WriteLine("')");
            writer.WriteLine();
            writer.WriteLine("$self = New-Object PSObject");
            writer.WriteLine("$self | Add-Member NoteProperty url $url");
            writer.WriteLine("$self | Add-Member NoteProperty id 0");
            writer.WriteLine();
    
            Method[] methods = service.GetMethods();
            string[] methodNames = new string[methods.Length];
    
            for (int i = 0; i < methods.Length; i++)
            {
                Method method = methods[i];
                methodNames[i] = method.Name;

                if (method.Description.Length > 0)
                {
                    writer.Write("# ");
                    writer.WriteLine(Regex.Replace(method.Description, "(\r\n)|\r|\n", "$0 #", RegexOptions.None));
                    writer.WriteLine();
                }

                writer.Write("$self | Add-Member ScriptMethod ");
                writer.Write(method.Name.Replace(".", "_"));
                writer.WriteLine(" {");
                writer.Indent++;
                writer.Write("$this.jayrock_rpc('");
                writer.Write(method.Name);
                writer.Write("', @{");

                Parameter[] parameters = method.GetParameters();
                
                foreach (Parameter parameter in parameters)
                {
                    if (parameter.Position > 0)
                        writer.Write(';');
                    writer.Write(' ');
                    writer.Write(parameter.Name);
                    writer.Write(" = $args[");
                    writer.Write(parameter.Position.ToString(CultureInfo.InvariantCulture));
                    writer.Write(']');
                }

                writer.WriteLine(" })");
                writer.Indent--;
                writer.WriteLine("}");
                writer.WriteLine();
            }
    
            writer.WriteLine();
            writer.WriteLine(@"$self | Add-Member ScriptMethod jayrock_rpc {
        $this.id++
        $req = [Jayrock.Json.Conversion.JsonConvert]::ExportToString(@{ 
            'id' = $this.id; 'method' = $args[0]; 'params' = $args[1]})
        $form = New-Object Collections.Specialized.NameValueCollection
        $form.Add('JSON-RPC', $req)
        $wc = New-Object Net.WebClient
        $bytes = $wc.UploadValues($this.url, $form)
        if ($bytes) {
            # TODO: Get the encoding from the charset in the Content-Type response header
            $rsp = [Jayrock.Json.Conversion.JsonConvert]::Import([Text.Encoding]::UTF8.GetString($bytes))
            if ($rsp.error) {
                throw $rsp.error.message
            }
            else {
                $rsp.result
            }
        }
    }

    $self");
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:jayrock-svn,代码行数:101,代码来源:JsonRpcMonadProxyGenerator.cs

示例8: WriteMethod

        private void WriteMethod(IndentedTextWriter writer, Method method)
        {
            string clientMethodName = method.Name.Replace(".", "_");

            writer.Write("def ");
            writer.Write(clientMethodName);
            writer.Write("(self");

            Parameter[] parameters = method.GetParameters();

            foreach (Parameter parameter in parameters)
            {
                writer.Write(", ");
                writer.Write(parameter.Name);
            }

            writer.WriteLine("):");
            writer.Indent++;

            if (method.Description.Length > 0)
            {
                // TODO: What to do if /* and */ appear in the summary?

                writer.Write(_docQuotes);
                writer.WriteLine(method.Description);
                writer.WriteLine(_docQuotes);
            }

            writer.Write("return self.__call('");
            writer.Write(method.Name);
            writer.Write("', (");

            foreach (Parameter parameter in parameters)
            {
                writer.Write(parameter.Name);
                writer.Write(", ");
            }

            writer.WriteLine("))");
            writer.Indent--;
            writer.WriteLine();
        }
开发者ID:BackupTheBerlios,项目名称:tamjb,代码行数:42,代码来源:JsonRpcPythonProxyGenerator.cs

示例9: Version1

        private static void Version1(JsonRpcServiceClass service, Uri url, IndentedTextWriter writer)
        {
            Debug.Assert(service != null);
            Debug.Assert(url!= null);
            Debug.Assert(!url.IsFile);
            Debug.Assert(writer != null);

            writer.WriteLine("// Proxy version 1.0");
            writer.WriteLine();

            writer.Write("function ");
            writer.Write(service.Name);
            writer.WriteLine("(url)");
            writer.WriteLine("{");
            writer.Indent++;
    
            JsonRpcMethod[] methods = service.GetMethods();
            string[] methodNames = new string[methods.Length];
    
            for (int i = 0; i < methods.Length; i++)
            {
                JsonRpcMethod method = methods[i];
                methodNames[i] = method.Name;

                if (method.Description.Length > 0)
                {
                    // TODO: What to do if /* and */ appear in the summary?

                    writer.Write("/* ");
                    writer.Write(method.Description);
                    writer.WriteLine(" */");
                    writer.WriteLine();
                }

                writer.Write("this[\"");
                writer.Write(method.Name);
                writer.Write("\"] = function(");

                JsonRpcParameter[] parameters = method.GetParameters();
                
                foreach (JsonRpcParameter parameter in parameters)
                {
                    writer.Write(parameter.Name);
                    writer.Write(", ");
                }

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

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

                foreach (JsonRpcParameter 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);
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:jayrock-svn,代码行数:101,代码来源:JsonRpcProxyGenerator.cs

示例10: Version2

        private void Version2(JsonRpcServiceClass service, Uri url, IndentedTextWriter writer)
        {
            Debug.Assert(service != null);
            Debug.Assert(url!= null);
            Debug.Assert(!url.IsFile);
            Debug.Assert(writer != null);
 
            writer.WriteLine("// Proxy version 2.0");
            writer.WriteLine();
 
            writer.Write("var ");
            writer.Write(service.Name);
            writer.Write(@" = function()
{
    var nextId = 0;

    var proxy = {

        url : """);
            writer.Write(url);
            writer.Write(@""",
        rpc : {");
            writer.WriteLine();
            writer.Indent += 3;
    
            JsonRpcMethod[] methods = service.GetMethods();
            
            string[] methodNames = new string[methods.Length];
            for (int i = 0; i < methods.Length; i++)
                methodNames[i] = methods[i].Name;
            
            Array.Sort(methodNames, methods);
    
            for (int i = 0; i < methods.Length; i++)
            {
                JsonRpcMethod method = methods[i];

                writer.WriteLine();

                if (method.Description.Length > 0)
                {
                    // TODO: What to do if /* and */ appear in the summary?

                    writer.Write("/* ");
                    writer.Write(method.Description);
                    writer.WriteLine(" */");
                    writer.WriteLine();
                }

                writer.Write('\"');
                writer.Write(method.Name);
                writer.Write("\" : function(");

                JsonRpcParameter[] parameters = method.GetParameters();
                
                foreach (JsonRpcParameter parameter in parameters)
                {
                    writer.Write(parameter.Name);
                    writer.Write(", ");
                }

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

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

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

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

                writer.Indent--;
                writer.Write("}");
                if (i < (methods.Length - 1))
                    writer.Write(',');
                writer.WriteLine();
            }
    
            writer.Indent--;
            writer.WriteLine(@"}
    }

    function Call(method, params, callback)
    {
        this.url = proxy.url;
        this.callback = callback;
        this.request = 
        { 
            id     : ++nextId, 
            method : method, 
            params : params 
        };
    }
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:jayrock-svn,代码行数:101,代码来源:JsonRpcProxyGenerator.cs


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