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


C# System.IO.StringWriter.Write方法代码示例

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


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

示例1: ToString

        /// <summary>
        /// Returns a string representation of this exception, including
        /// any inner exceptions.
        /// </summary>
        /// <returns>The string representation of this exception.</returns>
        public override string ToString()
        {
            //
            // This prints the exception Java style. That is, the outermost
            // exception, "Caused by:" to the innermost exception. The
            // stack trace is not nicely indented as with Java, but
            // without string parsing (perhaps tokenize on "\n"), it
            // doesn't appear to be possible to reformat it.
            //
            System.IO.StringWriter sw = new System.IO.StringWriter(CultureInfo.CurrentCulture);
            IceUtilInternal.OutputBase op = new IceUtilInternal.OutputBase(sw);
            op.setUseTab(false);
            op.print(GetType().FullName);
            op.inc();
            IceInternal.ValueWriter.write(this, op);
            sw.Write("\n");
            sw.Write(StackTrace);

            System.Exception curr = InnerException;
            while(curr != null)
            {
                sw.Write("\nCaused by: ");
                sw.Write(curr.GetType().FullName);
                if(!(curr is Ice.Exception))
                {
                    sw.Write(": ");
                    sw.Write(curr.Message);
                }
                sw.Write("\n");
                sw.Write(curr.StackTrace);
                curr = curr.InnerException;
            }

            return sw.ToString();
        }
开发者ID:bholl,项目名称:zeroc-ice,代码行数:40,代码来源:Exception.cs

示例2: ToString

 public override string ToString()
 {
     System.IO.StringWriter s = new System.IO.StringWriter();
     if (this.y > 0)
     { s.Write("{0} +{1}i", x, y); }
     else
     { s.Write("{0} {1}i", x, y); }
     return s.ToString();
 }
开发者ID:91xie,项目名称:Visual-Studio-2010,代码行数:9,代码来源:Program.cs

示例3: ToString

        public override string ToString()
        {
            System.IO.StringWriter s = new System.IO.StringWriter();
            s.Write("Circle ");
            s.Write(base.ToString());
            s.WriteLine("   Radius  :={0}", Radius);

            return s.ToString();
        }
开发者ID:91xie,项目名称:Visual-Studio-2010,代码行数:9,代码来源:Shapes.cs

示例4: ArrayWrite

        static string ArrayWrite(double[] a)
        {
            System.IO.StringWriter s = new System.IO.StringWriter();
            s.Write("(");
            for (int i = 0; i < a.Length; i++)
            { s.Write("{0},", a[i]); }

            s.Write(")");
            return s.ToString();
        }
开发者ID:91xie,项目名称:Visual-Studio-2010,代码行数:10,代码来源:Program.cs

示例5: TightFormat

 //Designed for emitting binding objects created by Autobind.
 public static String TightFormat(Object o)
 {
     var stream = new System.IO.StringWriter();
     if (o == null) stream.Write("null\n");
     else
     {
         var obj = o as ScriptObject;
         if (obj == null) stream.Write("Not a script object.\n");
         else foreach (var prop in obj.ListProperties())
             {
                 var val = obj.GetProperty(prop.ToString());
                 stream.Write(prop.ToString() + ": ");
                 if (val == null) stream.Write("null");
                 else if (val is ScriptObject && Function.IsFunction(val as ScriptObject))
                     stream.Write((val as ScriptObject).GetProperty("@help"));
                 else if (val is ScriptObject && (val as ScriptObject).GetProperty("@lazy-reflection") != null)
                     stream.Write("lazy bind " + (val as ScriptObject).GetProperty("@lazy-reflection") + " on " +
                         ((val as ScriptObject).GetProperty("@source-type") as System.Type).Name);
                 else
                     stream.Write(val.ToString());
                 stream.Write("\n");
             }
     }
     return stream.ToString();
 }
开发者ID:Blecki,项目名称:misp,代码行数:26,代码来源:StandardLibrary.cs

示例6: PrintConstraintCode

        public string PrintConstraintCode(string varName, string enumPrefix)
        {
            System.IO.StringWriter o = new System.IO.StringWriter();

            o.Write("new List<char>(Value).TrueForAll(delegate(char c) { return ");
            for (int i = 0; i < allowed_char_set.m_constraints.Count; i++)
            {
                o.Write(((ICSharpConstraint)allowed_char_set.m_constraints[i]).PrintConstraintCode("c", enumPrefix));
                if (i != allowed_char_set.m_constraints.Count - 1)
                    o.Write(" && ");
            }
            o.Write("; })");

            return o.ToString();
        }
开发者ID:kia92798,项目名称:tinyasn1,代码行数:15,代码来源:ICSharpConstraint.cs

示例7: CreateRegistrationFile

        /// <summary>
        /// regisztrációs file elkészítése  
        /// </summary>
        /// <param name="registrationFileNameWithPath"></param>
        /// <param name="htmlContent"></param>
        public void CreateRegistrationFile(string registrationFileNameWithPath, string htmlContent)
        {

//using (FileStream fs = new FileStream("test.htm", FileMode.Create)) 
//{ 
//    using (StreamWriter w = new StreamWriter(fs, Encoding.UTF8)) 
//    { 
//        w.WriteLine("<H1>Hello</H1>"); 
//    } 
//} 

            try
            {
                Helpers.DesignByContract.Require(!String.IsNullOrEmpty(registrationFileNameWithPath), "Registration file name with path cannot be null or empty!");

                System.IO.FileStream fs = new System.IO.FileStream(registrationFileNameWithPath, System.IO.FileMode.Create, System.IO.FileAccess.Write); //System.IO.FileShare.Write,

                System.IO.StreamWriter streamWriter = new System.IO.StreamWriter(fs, System.Text.Encoding.GetEncoding(28592));

                System.IO.StringWriter stringWriter = new System.IO.StringWriter();

                stringWriter.Write(htmlContent);

                System.Web.UI.HtmlTextWriter htw = new System.Web.UI.HtmlTextWriter(stringWriter);

                streamWriter.WriteLine(stringWriter.ToString());

                streamWriter.Close();

            }
            catch (Exception ex) 
            {
                throw ex;
            }
        }
开发者ID:juaqaai,项目名称:CompanyGroup.ServiceLayers,代码行数:40,代码来源:RegistrationFileRepository.cs

示例8: OrganizeExternalNamespaces

 void OrganizeExternalNamespaces()
 {
     foreach (Assembly asm in Parameters.References)
     {
         try
         {
             NameResolutionService.OrganizeAssemblyTypes(asm);
         }
         catch (ReflectionTypeLoadException x)
         {
             System.IO.StringWriter loadErrors = new System.IO.StringWriter();
             loadErrors.Write("'" + asm.FullName + "' - (" + GetLocation(asm) + "):");
             loadErrors.WriteLine(x.Message);
             foreach(Exception e in x.LoaderExceptions)
             {
                 loadErrors.WriteLine(e.Message);
             }
             Errors.Add(
                 CompilerErrorFactory.FailedToLoadTypesFromAssembly(
                     loadErrors.ToString(), x));
         }
         catch (Exception x)
         {
             Errors.Add(
                 CompilerErrorFactory.FailedToLoadTypesFromAssembly(
                     "'" + asm.FullName + "' - (" + GetLocation(asm) + "): " + x.Message, x));
         }
     }
 }
开发者ID:w4x,项目名称:boolangstudio,代码行数:29,代码来源:InitializeNameResolutionService.cs

示例9: ToString

        public override string ToString()
        {
            System.IO.StringWriter s = new System.IO.StringWriter();
            s.Write("Constant");
            s.Write(base.ToString());

            string SubtypeOutputString = "n/a";
            if (Subtype == 1)
            { SubtypeOutputString = "Low"; }
            else if (Subtype == 2)
            { SubtypeOutputString = "Medium"; }
            else if (Subtype == 3)
            { SubtypeOutputString = "High"; }
            s.WriteLine("   Subtype:={0}", SubtypeOutputString);

            return s.ToString();
        }
开发者ID:91xie,项目名称:Visual-Studio-2010,代码行数:17,代码来源:ValveTest.cs

示例10: array2string

 static string array2string(int [] x )
 {
     System.IO.StringWriter s = new System.IO.StringWriter();
     for ( int i = 0; i< x.Length; i++)
     {
         s.Write("  {0,2:D}", x[i]);
     }
     return s.ToString();
     //automated string writer for printing out arrays
 }
开发者ID:91xie,项目名称:Visual-Studio-2010,代码行数:10,代码来源:Program.cs

示例11: traceSlicing

 internal static void traceSlicing(string kind, string typeId, string slicingCat, Ice.Logger logger)
 {
     lock(typeof(IceInternal.TraceUtil))
     {
         if(slicingIds.Add(typeId))
         {
             using(System.IO.StringWriter s = new System.IO.StringWriter(CultureInfo.CurrentCulture))
             {
                 s.Write("unknown " + kind + " type `" + typeId + "'");
                 logger.trace(slicingCat, s.ToString());
             }
         }
     }
 }
开发者ID:Radulfr,项目名称:zeroc-ice,代码行数:14,代码来源:TraceUtil.cs

示例12: Evaluate

        public static CompileResult Evaluate(string code, bool autoCompleteComma = true)
        {
            if (autoCompleteComma && !code.EndsWith(";")) {
            code += ";";
            }

            var result = new CompileResult();
            result.code = code;

            // find commands at first and expand it if found.
            code = Commands.ConvertIntoCodeIfCommand(code);

            // if not match, eval the code using Mono.
            object ret = null;
            bool hasReturnValue = false;

            var originalOutput = Mono.CSharp.Evaluator.MessageOutput;
            var errorWriter = new System.IO.StringWriter();
            bool isPartial = false;
            Mono.CSharp.Evaluator.MessageOutput = errorWriter;
            try {
            isPartial = Mono.CSharp.Evaluator.Evaluate(code, out ret, out hasReturnValue) != null;
            } catch (System.Exception e) {
            errorWriter.Write(e.Message);
            }
            Mono.CSharp.Evaluator.MessageOutput = originalOutput;

            var error = errorWriter.ToString();
            if (!string.IsNullOrEmpty(error)) {
            error = error.Replace("{interactive}", "");
            var lastLineBreakPos = error.LastIndexOf('\n');
            if (lastLineBreakPos != -1) {
                error = error.Remove(lastLineBreakPos);
            }
            result.type  = CompileResult.Type.Error;
            result.error = error;
            return result;
            }
            errorWriter.Dispose();

            if (isPartial) {
            result.type = CompileResult.Type.Partial;
            return result;
            }

            result.type = CompileResult.Type.Success;
            result.value = (hasReturnValue && ret != null) ? ret : "null";
            return result;
        }
开发者ID:hecomi,项目名称:uREPL,代码行数:49,代码来源:Evaluator.cs

示例13: toText

        /// <summary> Returns a text representation of a byte array.
        /// Bytes in the array which don't convert to text in the range a..Z
        /// are dropped.
        /// 
        /// </summary>
        /// <param name="bytes">a byte array
        /// </param>
        /// <returns> a string containing the text equivalent of the bytes.
        /// </returns>
        public static System.String toText(byte[] bytes)
        {
            System.IO.StringWriter sw = new System.IO.StringWriter();

            int length = bytes.Length;
            if (length > 0)
            {
                for (int i = 0; i < length; i++)
                {
                    byte b = bytes[i];
                    if (b > 64 && b < 91 || b > 96 && b < 123)
                        sw.Write((char) b);
                }
            }
            return (sw.ToString());
        }
开发者ID:oo00spy00oo,项目名称:SharedTerminals,代码行数:25,代码来源:AsciiHelper.cs

示例14: trace

        internal static void trace(string heading, BasicStream str, Ice.Logger logger, TraceLevels tl)
        {
            if(tl.protocol >= 1)
            {
                int p = str.pos();
                str.pos(0);

                using(System.IO.StringWriter s = new System.IO.StringWriter(CultureInfo.CurrentCulture))
                {
                    s.Write(heading);
                    printMessage(s, str);

                    logger.trace(tl.protocolCat, s.ToString());
                }
                str.pos(p);
            }
        }
开发者ID:Radulfr,项目名称:zeroc-ice,代码行数:17,代码来源:TraceUtil.cs

示例15: GenerateHexDump

 public static string GenerateHexDump(byte[] data) {
     if (data == null || data.Length == 0)
         return "";
     int size = data.Length;
     //ByteBuffer buffer = new ByteBuffer(data);
     System.IO.MemoryStream buffer = new System.IO.MemoryStream(data);
     //long remaining = (buffer.Length - buffer.Position);
     string ascii = "";
     //StringBuilder sb = new StringBuilder((buffer.Remaining * 3) - 1);
     StringBuilder sb = new StringBuilder(((int)(buffer.Length - buffer.Position) * 3) - 1);
     System.IO.StringWriter writer = new System.IO.StringWriter(sb);
     int lineCount = 0;
     for (int i = 0; i < size; i++) {
         int val = buffer.ReadByte() & 0xFF;
         writer.Write((char)highDigits[val]);
         writer.Write((char)lowDigits[val]);
         writer.Write(" ");
         ascii += GetAsciiEquivalent(val) + " ";
         lineCount++;
         if (i == 0)
             continue;
         if ((i + 1) % 8 == 0)
             writer.Write("  ");
         if ((i + 1) % 16 == 0) {
             writer.Write(" ");
             writer.Write(ascii);
             writer.WriteLine();
             ascii = "";
             lineCount = 0;
         } else if (i == size - 1) {///HALF-ASSED ATTEMPT TO GET THE LAST LINE OF ASCII TO LINE UP CORRECTLY
             //while(lineCount < 84) {
             //    writer.Write(" ");
             //    lineCount++;
             //}
             for (int y = lineCount; y < 25; y++) {
                 writer.Write(" ");
             }
             writer.Write(ascii);
             writer.WriteLine();
         }
     }
     return sb.ToString();
 }
开发者ID:MagicWishMonkey,项目名称:aoi.net,代码行数:43,代码来源:Hex.cs


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