예제 #1
0
        public string FormatMDX(FormatOptions fo)
        {
            StringBuilder mdx = new StringBuilder();
            Formatter     f   = new Formatter {
                Options = fo
            };

            mdx.Append(f.Prefix());
            if (this.m_SSParser.GetNode() != null)
            {
                this.m_SSParser.GetNode().AppendMDX(mdx, f, 0);
            }
            if (this.m_PostComments != null)
            {
                this.m_PostComments.AppendComment(mdx, f, 0);
            }
            if ('\n' == mdx[0])
            {
                mdx.Remove(0, 1);
            }
            if (this.m_ParamParser.m_Params.Count > 0)
            {
                mdx.Append("\n");
                XmlWriterSettings settings = new XmlWriterSettings {
                    Indent             = true,
                    IndentChars        = "  ",
                    OmitXmlDeclaration = true,
                    ConformanceLevel   = ConformanceLevel.Fragment
                };
                XmlWriter writer = XmlWriter.Create(mdx, settings);
                writer.WriteStartElement("Parameters", "urn:schemas-microsoft-com:xml-analysis");
                writer.WriteAttributeString("xmlns", "xsi", null, "http://www.w3.org/2001/XMLSchema-instance");
                writer.WriteAttributeString("xmlns", "xsd", null, "http://www.w3.org/2001/XMLSchema");
                foreach (MDXParameter parameter in this.m_ParamParser.m_Params)
                {
                    writer.WriteStartElement("Parameter");
                    writer.WriteElementString("Name", parameter.m_Name);
                    writer.WriteStartElement("Value");
                    writer.WriteAttributeString("xsi", "type", null, "xsd:string");
                    writer.WriteValue(parameter.m_Value);
                    writer.WriteEndElement();
                    writer.WriteEndElement();
                }
                writer.WriteEndElement();
                writer.Flush();
            }
            mdx.Append(f.Postfix());
            return(mdx.ToString());
        }