Esempio n. 1
0
        void EmberToXml_ProcessNode(EmberReader reader, XmlWriter writer, int indent)
        {
            var isContainer = reader.IsContainer;
            var indentStr   = new String(' ', 2 * indent);

            writer.WriteWhitespace(indentStr);
            writer.WriteStartElement(reader.Tag.ToString());

            writer.WriteStartAttribute("type");
            writer.WriteString(BerDefinitions.GetTypeName(reader.Type));
            writer.WriteEndAttribute();

            if (isContainer)
            {
                writer.WriteWhitespace(Environment.NewLine);

                EmberToXml_Recurse(new EmberReader(reader), writer, indent + 1);

                writer.WriteWhitespace(indentStr);
            }
            else
            {
                switch (reader.Type)
                {
                case BerType.Boolean:
                    writer.WriteValue(reader.GetBoolean());
                    break;

                case BerType.Integer:
                    writer.WriteValue(reader.GetLong());
                    break;

                case BerType.Real:
                    writer.WriteValue(reader.GetReal());
                    break;

                case BerType.UTF8String:
                    writer.WriteValue(reader.GetString());
                    break;
                }
            }

            writer.WriteEndElement();
            writer.WriteWhitespace(Environment.NewLine);
        }