コード例 #1
0
        internal void WriteObject(YamlObject obj)
        {
            if (obj == null)
            {
                WriteInline("~");
            }
            else
            {
                switch (obj.Kind)
                {
                case YamlObjectKind.Scalar:
                    WriteScalar((YamlScalar)obj);
                    break;

                case YamlObjectKind.Map:
                    WriteMap((YamlMap)obj);
                    break;

                case YamlObjectKind.Sequence:
                    WriteSequence((YamlSequence)obj);
                    break;

                default:
                    throw new InvalidOperationException();
                }
            }
        }
コード例 #2
0
        bool TryInlineObject(YamlObject obj, int maximumWidth, out string result)
        {
            if (maximumWidth < 1)
            {
                result = null;
                return(false);
            }
            else if (obj == null)
            {
                result = "~";
                return(true);
            }
            else
            {
                switch (obj.Kind)
                {
                case YamlObjectKind.Scalar:
                    return(TryInlineScalar((YamlScalar)obj, maximumWidth, out result));

                case YamlObjectKind.Map:
                    return(TryInlineMap((YamlMap)obj, maximumWidth, out result));

                case YamlObjectKind.Sequence:
                    return(TryInlineSequence((YamlSequence)obj, maximumWidth, out result));

                default:
                    throw new InvalidOperationException();
                }
            }
        }