예제 #1
0
 /// <summary> Write to YAML </summary>
 protected internal override void Write(WriteStream stream)
 {
     if (Content)
     {
         stream.Append("y");
     }
     else
     {
         stream.Append("n");
     }
 }
예제 #2
0
파일: Binary.cs 프로젝트: JerryXia/Yaml.Net
        /// <summary>
        ///   Write the base64 content to YAML
        /// </summary>
        /// <remarks> The lines are splitted in blocks of 20 bytes </remarks>
        protected internal override void Write(WriteStream stream)
        {
            stream.Append("!!binary |" + "\n");

            string bin = System.Convert.ToBase64String(content);

            while (bin.Length > 75)
            {
                stream.Append("  " + bin.Substring(0, 75) + "\n");
                bin = bin.Substring(75);
            }
            stream.Append("  " + bin);

            // Old coden, everything on one line
            // stream.Append ("!!binary \"" + System.Convert.ToBase64String (content) + "\"");
        }
예제 #3
0
        /// <summary> Write to YAML </summary>
        protected internal override void Write(WriteStream stream)
        {
            foreach (MappingNode node in childNodes)
            {
                stream.Append("? ");

                stream.Indent();
                Yaml.Net.Node key = node.Key;
                key.Write(stream);
                stream.UnIndent();

                stream.Append(": ");

                stream.Indent();
                node.Value.Write(stream);
                stream.UnIndent();
            }
        }
예제 #4
0
        /// <summary> Write back to a stream </summary>
        protected internal override void Write(WriteStream stream)
        {
            foreach (Node node in childNodes)
            {
                stream.Append("- ");

                stream.Indent();
                node.Write(stream);
                stream.UnIndent();
            }
        }
예제 #5
0
파일: Float.cs 프로젝트: JerryXia/Yaml.Net
        /// <summary> Write to a YAML node </summary>
        protected internal override void Write(WriteStream stream)
        {
            if (content.Equals(double.NaN))
            {
                stream.Append("!!float .NaN");
            }

            else if (content.Equals(double.NegativeInfinity))
            {
                stream.Append("!!float -.Inf");
            }

            else if (content.Equals(double.PositiveInfinity))
            {
                stream.Append("!!float +.Inf");
            }

            else
            {
                stream.Append("!!float " + content);
            }
        }
예제 #6
0
파일: String.cs 프로젝트: JerryXia/Yaml.Net
        /// <summary> Write </summary>
        protected internal override void Write(WriteStream stream)
        {
            // TODO, not required, but writing to block or folded scalars
            //       generates a little more neat code.

            // Analyze string
            bool multiline = false;
            bool mustbequoted = false;

            for (int i = 0; i < content.Length; i++)
            {
                char c = content[i];

                if (c == '\n')
                    multiline = true;

                // We quote everything except strings like /[a-zA-Z]*/
                // However there are more strings which don't require
                // quotes.
                if (!(c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z'))
                    mustbequoted = true;
            }

            // Double quoted strings
            if (mustbequoted)
            {
                stream.Append("\"");

                for (int i = 0; i < content.Length; i++)
                {
                    char c = content[i];

                    // Backslash
                    if (c == '\\') stream.Append("\\" + "\\");

                    // Double quote
                    else if (c == '\"') stream.Append("\\" + "\"");

                    // Single quote
                    else if (c == '\'') stream.Append("\\" + "\'");

                    // ASCII null
                    else if (c == '\0') stream.Append("\\0");

                    // ASCII bell
                    else if (c == (char)0x7) stream.Append("\\a");

                    // ASCII backspace
                    else if (c == (char)0x8) stream.Append("\\b");

                    // ASCII horizontal tab
                    else if (c == (char)0x9) stream.Append("\\t");

                    // ASCII newline
                    else if (c == (char)0xA) stream.Append("\\n");

                    // ASCII vertical tab
                    else if (c == (char)0xB) stream.Append("\\v");

                    // ASCII form feed
                    else if (c == (char)0xC) stream.Append("\\f");

                    // ASCII carriage return
                    else if (c == (char)0xD) stream.Append("\\r");

                    // ASCII escape
                    else if (c == (char)0x1D) stream.Append("\\e");

                    // Unicode next line
                    else if (c == (char)0x85) stream.Append("\\N");

                    // Unicode non breaking space
                    else if (c == (char)0xA0) stream.Append("\\_");

                    // TODO larger unicode characters

                    else
                        stream.Append("" + c);
                }
                stream.Append("\"");
            }

            // Simple non-quoted strings
            else
                stream.Append(content);
        }
예제 #7
0
 /// <summary> Write to YAML </summary>
 protected internal override void Write(WriteStream stream)
 {
     stream.Append(content.ToString());
 }
예제 #8
0
파일: Null.cs 프로젝트: JerryXia/Yaml.Net
 /// <summary> Write to YAML </summary>
 protected internal override void Write(WriteStream stream)
 {
     stream.Append("~");
 }
예제 #9
0
        /// <summary> Write back to a stream </summary>
        protected internal override void Write(WriteStream stream)
        {
            foreach (Node node in childNodes)
            {
                stream.Append("- ");

                stream.Indent();
                node.Write(stream);
                stream.UnIndent();
            }
        }
예제 #10
0
        /// <summary> Write </summary>
        protected internal override void Write(WriteStream stream)
        {
            // TODO, not required, but writing to block or folded scalars
            //       generates a little more neat code.

            // Analyze string
            bool multiline    = false;
            bool mustbequoted = false;

            for (int i = 0; i < content.Length; i++)
            {
                char c = content[i];

                if (c == '\n')
                {
                    multiline = true;
                }

                // We quote everything except strings like /[a-zA-Z]*/
                // However there are more strings which don't require
                // quotes.
                if (!(c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z'))
                {
                    mustbequoted = true;
                }
            }

            // Double quoted strings
            if (mustbequoted)
            {
                stream.Append("\"");

                for (int i = 0; i < content.Length; i++)
                {
                    char c = content[i];

                    // Backslash
                    if (c == '\\')
                    {
                        stream.Append("\\" + "\\");
                    }

                    // Double quote
                    else if (c == '\"')
                    {
                        stream.Append("\\" + "\"");
                    }

                    // Single quote
                    else if (c == '\'')
                    {
                        stream.Append("\\" + "\'");
                    }

                    // ASCII null
                    else if (c == '\0')
                    {
                        stream.Append("\\0");
                    }

                    // ASCII bell
                    else if (c == (char)0x7)
                    {
                        stream.Append("\\a");
                    }

                    // ASCII backspace
                    else if (c == (char)0x8)
                    {
                        stream.Append("\\b");
                    }

                    // ASCII horizontal tab
                    else if (c == (char)0x9)
                    {
                        stream.Append("\\t");
                    }

                    // ASCII newline
                    else if (c == (char)0xA)
                    {
                        stream.Append("\\n");
                    }

                    // ASCII vertical tab
                    else if (c == (char)0xB)
                    {
                        stream.Append("\\v");
                    }

                    // ASCII form feed
                    else if (c == (char)0xC)
                    {
                        stream.Append("\\f");
                    }

                    // ASCII carriage return
                    else if (c == (char)0xD)
                    {
                        stream.Append("\\r");
                    }

                    // ASCII escape
                    else if (c == (char)0x1D)
                    {
                        stream.Append("\\e");
                    }

                    // Unicode next line
                    else if (c == (char)0x85)
                    {
                        stream.Append("\\N");
                    }

                    // Unicode non breaking space
                    else if (c == (char)0xA0)
                    {
                        stream.Append("\\_");
                    }

                    // TODO larger unicode characters

                    else
                    {
                        stream.Append("" + c);
                    }
                }
                stream.Append("\"");
            }

            // Simple non-quoted strings
            else
            {
                stream.Append(content);
            }
        }
예제 #11
0
 /// <summary> Write to YAML </summary>
 protected internal override void Write(WriteStream stream)
 {
     stream.Append(YamlString());
 }
예제 #12
0
 /// <summary> Write to YAML </summary>
 protected internal override void Write(WriteStream stream)
 {
     stream.Append(YamlString());
 }
예제 #13
0
파일: Null.cs 프로젝트: JerryXia/Yaml.Net
 /// <summary> Write to YAML </summary>
 protected internal override void Write(WriteStream stream)
 {
     stream.Append("~");
 }
예제 #14
0
파일: Float.cs 프로젝트: JerryXia/Yaml.Net
        /// <summary> Write to a YAML node </summary>
        protected internal override void Write(WriteStream stream)
        {
            if (content.Equals(double.NaN))
                stream.Append("!!float .NaN");

            else if (content.Equals(double.NegativeInfinity))
                stream.Append("!!float -.Inf");

            else if (content.Equals(double.PositiveInfinity))
                stream.Append("!!float +.Inf");

            else stream.Append("!!float " + content);
        }
예제 #15
0
 /// <summary> Write to YAML </summary>
 protected internal override void Write(WriteStream stream)
 {
     stream.Append(content.ToString());
 }
예제 #16
0
파일: Binary.cs 프로젝트: JerryXia/Yaml.Net
        /// <summary>
        ///   Write the base64 content to YAML
        /// </summary>
        /// <remarks> The lines are splitted in blocks of 20 bytes </remarks>
        protected internal override void Write(WriteStream stream)
        {
            stream.Append("!!binary |" + "\n");

            string bin = System.Convert.ToBase64String(content);

            while (bin.Length > 75)
            {
                stream.Append("  " + bin.Substring(0, 75) + "\n");
                bin = bin.Substring(75);
            }
            stream.Append("  " + bin);

            // Old coden, everything on one line
            // stream.Append ("!!binary \"" + System.Convert.ToBase64String (content) + "\"");
        }
예제 #17
0
 /// <summary> Write to YAML </summary>
 protected internal override void Write(WriteStream stream)
 {
     if (Content)
         stream.Append("y");
     else
         stream.Append("n");
 }
예제 #18
0
        /// <summary> Write to YAML </summary>
        protected internal override void Write(WriteStream stream)
        {
            foreach (MappingNode node in childNodes)
            {
                stream.Append("? ");

                stream.Indent();
                Yaml.Net.Node key = node.Key;
                key.Write(stream);
                stream.UnIndent();

                stream.Append(": ");

                stream.Indent();
                node.Value.Write(stream);
                stream.UnIndent();
            }
        }