Example #1
0
        /// <summary>
        /// Writes a DocumentObjectCollection type object to string. Indent a new block by
        /// indent + initialIndent characters.
        /// </summary>
        public static string WriteToString(DocumentObjectCollection docObjectContainer, int indent, int initialIndent)
        {
            StringBuilder strBuilder = new StringBuilder();
            StringWriter  writer     = null;
            DdlWriter     wrt        = null;

            try
            {
                writer = new StringWriter(strBuilder);

                wrt               = new DdlWriter(writer);
                wrt.Indent        = indent;
                wrt.InitialIndent = initialIndent;

                wrt.WriteDocument(docObjectContainer);
                wrt.Close();
            }
            finally
            {
                if (wrt != null)
                {
                    wrt.Close();
                }
                if (writer != null)
                {
#if !NETFX_CORE
                    writer.Close();
#else
                    writer.Dispose();
#endif
                }
            }
            return(strBuilder.ToString());
        }
Example #2
0
        /// <summary>
        /// Writes a DocumentObjectCollection type object to a DDL file. Indent a new block by
        /// indent + initialIndent characters.
        /// </summary>
        public static void WriteToFile(DocumentObjectCollection docObjectContainer, string filename, int indent, int initialIndent)
        {
            DdlWriter wrt = null;

            try
            {
                wrt               = new DdlWriter(filename);
                wrt.Indent        = indent;
                wrt.InitialIndent = initialIndent;

                wrt.WriteDocument(docObjectContainer);
            }
            finally
            {
                if (wrt != null)
                {
                    wrt.Close();
                }
            }
        }