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


C# XmlWriterSettings.GetType方法代码示例

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


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

示例1: Transform

        public static string Transform( string xmlPath, XsltArgumentList argList )
        {
            string html = null;

            try
            {
                string transformFile = RulesEngineUtils.GetResourcePath( RulesEngineUtils.ReportBuilderFolder.Resources, "InstanceReport.xslt" );

                XslCompiledTransform transform = new XslCompiledTransform();
                transform.Load( transformFile );

                using( MemoryStream ms = new MemoryStream() )
                {
                    XmlWriterSettings xSettings = new XmlWriterSettings();
                    xSettings.ConformanceLevel = ConformanceLevel.Fragment;
                    xSettings.Encoding = Encoding.ASCII;
                    xSettings.Indent = true;
                    xSettings.OmitXmlDeclaration = true;

                    //we REALLY need to set this to HTML
                    xSettings.GetType().GetProperty( "OutputMethod" ).SetValue( xSettings, XmlOutputMethod.Html, null );

                    using( XmlWriter xWriter = XmlWriter.Create( ms, xSettings ) )
                    {
                        transform.Transform( xmlPath, argList, xWriter );
                    }

                    ms.Flush();
                    html = Encoding.ASCII.GetString( ms.ToArray() );
                }
            }
            catch( Exception ex )
            {
                html = "<h2>Error <small>generating preview</small></h2>"+
                    "<pre>"+ ex.Message +"</pre>";
            }

            return html;
        }
开发者ID:plamikcho,项目名称:xbrlpoc,代码行数:39,代码来源:Test_Abstract.cs

示例2: GenerateHtmlFiles

        /// <summary>
        /// Generates HTML report files if allowed by this.<see cref="ReportFormat"/> and as specified by this.<see cref="HtmlReportFormat"/>.
        /// </summary>
        /// <returns>True on success, false on fail.</returns>
        private bool GenerateHtmlFiles()
        {
            // Use custom XSLT if provided
            string transformFile = String.Empty;
            if (!String.IsNullOrEmpty(this.xsltStylesheetPath))
            {
                //executor.Invoke(this.xsltStylesheetPath);
                transformFile = this.xsltStylesheetPath;
            }
            else
            {
                transformFile = RulesEngineUtils.GetResourcePath( RulesEngineUtils.ReportBuilderFolder.Resources, RulesEngineUtils.TransformFile );
                //executor.Invoke(transformFile);
            }

            if( !File.Exists( transformFile ) )
            {
                executor.Invoke("Conversion aborted");
                Trace.TraceError( "Error: Transform File not found at:\n\t" + transformFile + "\nHtml Conversion aborted." );
                return false;
            }

            bool anyFiles = false;

            //load the transform once for all R-files
            XslCompiledTransform transform = new XslCompiledTransform();
            try
            {
                transform.Load(transformFile);
            }
            catch ( XmlException )
            {
                Trace.TraceError("Error: Transform File contains invalid XML:\n\t" + transformFile + "\nHtml Conversion aborted.");
                return false;
            }
            catch ( XsltException )
            {
                Trace.TraceError("Error: Transform File contains invalid XSLT:\n\t" + transformFile + "\nHtml Conversion aborted.");
                return false;
            }

            XsltArgumentList argList = new XsltArgumentList();
            argList.Clear();

            if( this.HtmlReportFormat == HtmlReportFormat.Complete )
            {
                argList.AddParam( "asPage", string.Empty, "true" );

            }

            argList.AddParam( "numberDecimalSeparator", string.Empty, Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator );
            argList.AddParam( "numberGroupSeparator", string.Empty, Thread.CurrentThread.CurrentCulture.NumberFormat.NumberGroupSeparator );
            argList.AddParam( "numberGroupSize", string.Empty, Thread.CurrentThread.CurrentCulture.NumberFormat.NumberGroupSizes[ 0 ].ToString() );

            XmlWriterSettings writerSettings = new XmlWriterSettings();
            writerSettings.Encoding = InstanceReport.Encoding;
            writerSettings.Indent = true;
            writerSettings.OmitXmlDeclaration = true;

            //set intelligent HTML output
            writerSettings.GetType().GetProperty( "OutputMethod" ).SetValue( writerSettings, XmlOutputMethod.Html, null );

            foreach( ReportHeader header in this.currentFilingSummary.MyReports )
            {
                switch( header.ReportType )
                {
                    case ReportHeaderType.Notes:
                    case ReportHeaderType.Sheet:
                        break;
                    default:
                        continue;
                }

                string inFile = Path.Combine( this.currentReportDirectory, header.XmlFileName );
                if( !File.Exists( inFile ) )
                {
                    Trace.TraceWarning( "Warning: The FilingSummary provided '"+ header.XmlFileName +"' but the file was not found." +
                        separator +"\tReport skipped: "+ header.LongName );
                    continue;
                }

                int extLen = Path.GetExtension( header.XmlFileName ).Length;
                string outFile = inFile.Substring( 0, inFile.Length - extLen ) +".htm";

                using( XmlReader xReader = XmlReader.Create( inFile ) )
                {
                    using( FileStream msOut = new FileStream( outFile, FileMode.Create, FileAccess.Write ) )
                    {
                        try
                        {
                            using( RivetXmlWriter xWriter = new RivetXmlWriter( msOut, writerSettings ) )
                            {
                                transform.Transform( xReader, argList, xWriter );
                            }

                            anyFiles = true;
//.........这里部分代码省略.........
开发者ID:plamikcho,项目名称:xbrlpoc,代码行数:101,代码来源:ReportBuilder.cs


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