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 )); }
public static Node /*!*/ ToYaml(RubyRegex /*!*/ self, [NotNull] RubyRepresenter /*!*/ rep) { return(rep.Scalar( rep.GetTagUri(self), self.Inspect().ToAsciiString(), ScalarQuotingStyle.None )); }
public static Node /*!*/ ToYaml(RubyRegex /*!*/ self, [NotNull] RubyRepresenter /*!*/ rep) { return(rep.Scalar( rep.GetTagUri(self), self.Inspect().ToAsciiString(rep.Context.RubyOptions.Compatibility < RubyCompatibility.Ruby19), ScalarQuotingStyle.None )); }
public static Node /*!*/ ToYaml(RubyTime /*!*/ self, [NotNull] RubyRepresenter /*!*/ rep) { TimeSpan offset = self.GetCurrentZoneOffset(); long fractional = self.Microseconds; string value = String.Format(CultureInfo.InvariantCulture, "{0:yyyy-MM-dd HH:mm:ss}" + (fractional == 0 ? "" : ".{1:D6}") + (self.Kind == DateTimeKind.Utc ? " Z" : " {2}{3:D2}:{4:D2}"), self.DateTime, fractional, offset.Hours >= 0 ? "+" : "", offset.Hours, offset.Minutes ); return(rep.Scalar(rep.GetTagUri(self), value, ScalarQuotingStyle.None)); }
public static Node ToYamlNode(UnaryOpStorage /*!*/ messageStorage, Exception /*!*/ self, [NotNull] RubyRepresenter /*!*/ rep) { var site = messageStorage.GetCallSite("message", 0); var map = new Dictionary <object, object>(); rep.AddYamlProperties(map, self, false); return(rep.Map( new Dictionary <Node, Node> { { rep.Scalar(null, "message", ScalarQuotingStyle.None), rep.RepresentItem(site.Target(site, self)) } }, rep.GetTagUri(self), map, FlowStyle.Block )); }
public static Node /*!*/ ToYamlNode(RubyStruct /*!*/ self, [NotNull] RubyRepresenter /*!*/ rep) { var fieldNames = self.GetNames(); var fields = new Dictionary <Node, Node>(fieldNames.Count); for (int i = 0; i < fieldNames.Count; i++) { fields[rep.Scalar(null, fieldNames[i], ScalarQuotingStyle.None)] = rep.RepresentItem(self.Values[i]); } var map = new Dictionary <object, object>(); rep.AddYamlProperties(map, self, false); return(rep.Map(fields, rep.GetTagUri(self), map, FlowStyle.Block)); }
public static Node /*!*/ ToYaml(UnaryOpStorage /*!*/ beginStorage, UnaryOpStorage /*!*/ endStorage, UnaryOpStorage /*!*/ exclStorage, Range /*!*/ self, [NotNull] RubyRepresenter /*!*/ rep) { var begin = beginStorage.GetCallSite("begin"); var end = endStorage.GetCallSite("end"); var map = new Dictionary <object, object>(); rep.AddYamlProperties(map, self, false); return(rep.Map( new Dictionary <Node, Node> { { rep.Scalar(null, "begin", ScalarQuotingStyle.None), rep.RepresentItem(begin.Target(begin, self)) }, { rep.Scalar(null, "end", ScalarQuotingStyle.None), rep.RepresentItem(end.Target(end, self)) }, { rep.Scalar(null, "excl", ScalarQuotingStyle.None), rep.Scalar(self.ExcludeEnd) }, }, rep.GetTagUri(self), map, FlowStyle.Block )); }
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 )); }
public static Node /*!*/ ToYaml(ConversionStorage <MutableString> /*!*/ tosConversion, object /*!*/ self, [NotNull] RubyRepresenter /*!*/ rep) { string value = Protocols.ConvertToString(tosConversion, self).ToString(); return(rep.Scalar(rep.GetTagUri(self), value, ScalarQuotingStyle.None)); }