GetYamlStyle() private method

private GetYamlStyle ( object obj ) : ScalarQuotingStyle
obj object
return ScalarQuotingStyle
示例#1
0
 public static Node ToYamlNode(RubyContext /*!*/ context, RubyArray /*!*/ self, [NotNull] RubyRepresenter /*!*/ rep)
 {
     return(rep.Sequence(
                rep.GetTagUri(self, Tags.Seq, typeof(RubyArray)),
                self,
                rep.GetYamlStyle(self) != ScalarQuotingStyle.None ? FlowStyle.Inline : FlowStyle.Block
                ));
 }
示例#2
0
        public static Node /*!*/ ToYamlNode(MutableString /*!*/ self, [NotNull] RubyRepresenter /*!*/ rep)
        {
            if (!self.IsEmpty && ContainsBinaryData(self))
            {
                return(rep.BaseCreateNode(self.ToByteArray()));
            }

            Debug.Assert(self.IsAscii());
            string str = self.ToString();

            ScalarQuotingStyle style = ScalarQuotingStyle.None;

            if (str.StartsWith(":", StringComparison.Ordinal))
            {
                style = ScalarQuotingStyle.Double;
            }
            else
            {
                style = rep.GetYamlStyle(self);
            }

            var   tag = rep.GetTagUri(self, Tags.Str, typeof(MutableString));
            IList instanceVariableNames = rep.ToYamlProperties(self);

            if (instanceVariableNames.Count == 0)
            {
                return(rep.Scalar(tag, str, style));
            }

            var map = new Dictionary <object, object>();

            rep.AddYamlProperties(map, self, instanceVariableNames, false);
            return(rep.Map(
                       new Dictionary <Node, Node> {
                { rep.Scalar(null, "str", style), rep.Scalar(null, str, style) }
            },
                       tag,
                       map,
                       FlowStyle.Block
                       ));
        }