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


C# StreamWriterLevel.Flush方法代码示例

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


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

示例1: PrintHtml

        public virtual void PrintHtml(string f)
        {
            if (m_files.Count > 0)
            {
                string fileName = null;
                if (f == null)
                {
                    fileName = m_files[0].m_fileName;

                    if (fileName.ToUpper().EndsWith(".ASN1"))
                        fileName = fileName.Substring(0, fileName.Length - 5) + ".html";
                    else if (fileName.ToUpper().EndsWith(".ASN"))
                        fileName = fileName.Substring(0, fileName.Length - 4) + ".html";
                    else
                        fileName += ".html";
                }
                else
                    fileName = f;

                StreamWriterLevel wr = null;
                try
                {
                    wr = new StreamWriterLevel(fileName);
                }
                catch (Exception ex)
                {
                    Console.Error.WriteLine(ex.Message);
                    return;
                }
                wr.WriteLine("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"");
                wr.WriteLine("        \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">");

                wr.WriteLine("<html xmlns=\"http://www.w3.org/1999/xhtml\" >");
                wr.WriteLine("<head>");
                wr.WriteLine("    <title>ICD</title>");
                wr.WriteLine("    <style type=\"text/css\"> {0} </style>", ICDFile.css);
                wr.WriteLine("</head>");
                wr.WriteLine("<body>");
                wr.WriteLine("<em>The following tables describe the binary encodings of the data model using the ASN.1 Unaligned Packed Encoding Rules <a href=\"http://www.itu.int/ITU-T/studygroups/com17/languages/X.691-0207.pdf\">(PER)</a> - ITU-T Rec. X.691 (2002) | ISO/IEC 8825-2:2002 ASN.1 encoding rules.");
                wr.WriteLine(" This page was created by the ");
                wr.WriteLine("<a href=\"http://www.semantix.gr/DataModelling/OnlineDemo/icdDemo.htm\">Automatic ICD Generator tool</a></em><br/><br/>");

                foreach (ICDFile file in m_files)
                    file.PrintHtml(wr, 0);

                if (m_HtmlIntegerSizeMustBeExplained || m_HtmlLengthSizeMustBeExplained || m_HtmlRealSizeMustBeExplained || m_WithComponentMustBeExplained)
                {

                    wr.WriteLine("<hr />");
                    if (m_HtmlIntegerSizeMustBeExplained)
                    {
                        wr.WriteLine("<a name=\"INT_SIZE_EXPLAINED123\"></a>");
                        wr.WriteLine("<em>Unconstraint integer's size explained</em><br/>");
                        wr.WriteLine("In unaligned PER, unconstraint integers are encoded into the minimum number of octets (using non negative binary integer or 2's-complement binary integer encoding) and a length determinant, containing the number of value octets, is added at the beginning of the encoding. Therefore uPER can support integers of any size, even of infinity value. However, in almost all processors, integers have limited capacity which is usually four or eight octets. Therefore, the reported maximum size in octets for an unconstraint integer is 1 (for the length determinant) plus the word size for the target processor which is specified in the command line by the wordSize argument. In this invocation, wordSize was specified to be {0} octets and therefore the maximum size of the unconstraint integers is {1} octets or {2} bits", Config.IntegerSize, Config.IntegerSize + 1, (Config.IntegerSize + 1) * 8);
                        wr.WriteLine("<br/>");
                        wr.WriteLine("<br/>");
                    }
                    if (m_HtmlRealSizeMustBeExplained)
                    {
                        wr.WriteLine("<a name=\"REAL_SIZE_EXPLAINED123\"></a>");
                        wr.WriteLine("<em>Real's size explained</em><br/>");
                        wr.WriteLine("In both uPER and aPER, real values are encoded as a pair of integers which represent the mantissa and exponent (real value = mantissa* 2<span style=\"vertical-align: super\">exponent</span>). In particular, a real is encoded into a length determinant field, a header field (always one octet), the exponent field using 2's complement binary integer and the mantissa field. Therefore uPER can support reals with infinity precision since both exponent and mantissa can, theoretically, have infinity length. However, in almost all processors, integers have limited capacity which is usually four or eight octets. Therefore, the reported maximum size in octets for a real is 1 for the length determinant plus 1 for header field plus 3 octets for exponent and finally plus the word size for the target processor which is specified in the command line by the wordSize argument. In this invocation, wordSize was specified to be {0} octets and therefore the maximum size of a real is {1} octets or {2} bits.", Config.IntegerSize, RealType.uPerMaxSize / 8, RealType.uPerMaxSize);
                        wr.WriteLine("<br/>");
                        wr.WriteLine("<br/>");
                    }
                    if (m_HtmlLengthSizeMustBeExplained)
                    {
                        wr.WriteLine("<a name=\"ARRAYS_SIZE_EXPLAINED123\"></a>");
                        wr.WriteLine("<em>Length's size explained</em><br/>");
                        wr.WriteLine("In uPER, the length determinant field, which used in the encoding of sizeable types such as SEQUENCE OFs, SET OFs, BIT STRINGs, OCTET STRINGs and character types, is at most two octets provided that (a) there is a SIZE constraint which limits the length count to a value less than 64K or (b) there is no size constraint, but in the given instance of the sizeable type the number of the elements is less than 16K. In all other cases, the sizeable type is encoded using fragmentation where the length determinant is encoded interstitially with the actual data. In this particular case (i.e. when fragmentation is applicable), the table produced by the autoICD generator does not represent correctly the physical PER encoding.");
                    }

                    if (m_WithComponentMustBeExplained)
                    {
                        wr.WriteLine("<a name=\"WITH_COMPONENT_EXPLAINED123\"></a>");
                        wr.WriteLine("<em>Constraint ignored in encoding</em><br/>");
                        wr.WriteLine("The constraint with the yellow color is not PER visible, as it derives from a WITH COMPONENT or WITH COMPONENTS contraint in the parent type, and therefore is ignored in the encoding/decoding.");
                    }
                    if (m_ZeroBitsMustBeExplained)
                    {
                        wr.WriteLine("<a name=\"ZERO_BITS_EXPLAINED123\"></a>");
                        wr.WriteLine("<em>Field with zero size explained</em><br/>");
                        wr.WriteLine("An integer type that is contraint to a single value (i.e. INTEGER (5) or INTEGER (1..10)(10..20)) requires zero bits when encoded in uPER since the decoder can always determine its value. In other words, a integer field which is contraint to a single value is never transmitted in uPER.");
                    }

                    wr.WriteLine("<hr />");
                }

                foreach (ICDFile file in m_files)
                    file.PrintAsn1InHtml(wr, 0);

                wr.WriteLine("</body>");
                wr.WriteLine("</html>");

                wr.Flush();
                wr.Close();

            }
        }
开发者ID:kia92798,项目名称:tinyasn1,代码行数:99,代码来源:ICDFile.cs


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