Exemplo n.º 1
0
        public static object YamlAs(RubyScope /*!*/ scope, RubyModule /*!*/ self, object tag)
        {
            RubyModule yamlModule;

            scope.RubyContext.TryGetModule(scope.GlobalScope, "YAML", out yamlModule);
            return(RubyYaml.TagClass(yamlModule, tag, self));
        }
Exemplo n.º 2
0
        private static object ParseObject(RubyConstructor /*!*/ ctor, string /*!*/ value)
        {
            Composer composer = RubyYaml.MakeComposer(new StringReader(value), ctor.Encoding);

            if (composer.CheckNode())
            {
                return(ctor.ConstructObject(composer.GetNode()));
            }
            else
            {
                throw new ConstructorException("Invalid YAML element: " + value);
            }
        }
Exemplo n.º 3
0
 public static object ToYaml(object self, [NotNull] RubyRepresenter /*!*/ emitter)
 {
     if (emitter.Level > 0)
     {
         // return a node:
         return(emitter.Represent(self));
     }
     else
     {
         // return a string:
         return(RubyYaml.DumpAll(emitter, new object[] { self }, null));
     }
 }
Exemplo n.º 4
0
                public static object CreateSequence([NotNull] BlockParam /*!*/ block, Out /*!*/ self, [DefaultProtocol] MutableString taguri, object yamlStyle)
                {
                    var rep = self._representer;
                    var seq = new SequenceNode(rep.ToTag(taguri), new List <Node>(), RubyYaml.ToYamlFlowStyle(yamlStyle));

                    object blockResult;

                    if (block.Yield(seq, out blockResult))
                    {
                        return(blockResult);
                    }

                    return(seq);
                }
Exemplo n.º 5
0
 public static MutableString /*!*/ TagUri(RubyContext /*!*/ context, RubyTime /*!*/ self)
 {
     return(RubyYaml.GetTagUri(context, self, Tags.Timestamp, typeof(RubyTime)));
 }
Exemplo n.º 6
0
 public static MutableString /*!*/ TagUri(RubyContext /*!*/ context, RubyRegex /*!*/ self)
 {
     return(RubyYaml.GetTagUri(context, self, Tags.RubyRegexp, typeof(RubyRegex)));
 }
Exemplo n.º 7
0
 public static MutableString /*!*/ TagUri(RubyContext /*!*/ context, MutableString /*!*/ self)
 {
     return(RubyYaml.GetTagUri(context, self, Tags.Str, typeof(MutableString)));
 }
Exemplo n.º 8
0
 public static MutableString TagUri(RubyContext /*!*/ context, object self)
 {
     return(RubyYaml.GetTagUri(context, self, Tags.RubyException, typeof(Exception)));
 }
Exemplo n.º 9
0
 public static MutableString /*!*/ TagUri(RubyContext /*!*/ context, RubyArray /*!*/ self)
 {
     return(RubyYaml.GetTagUri(context, self, Tags.Seq, typeof(RubyArray)));
 }
Exemplo n.º 10
0
 public static object Transform(RubyScope /*!*/ scope, Node /*!*/ self)
 {
     return(new RubyConstructor(scope.GlobalScope, new SimpleNodeProvider(self, RubyYaml.GetEncoding(scope.RubyContext))).GetData());
 }
Exemplo n.º 11
0
        internal ScalarQuotingStyle GetYamlStyle(object obj)
        {
            var site = _siteStorage.ToYamlStyle;

            return(RubyYaml.ToYamlStyle(Context, site.Target(site, obj)));
        }
Exemplo n.º 12
0
 public static object Emit(YamlCallSiteStorage /*!*/ siteStorage, YamlStream /*!*/ self, [Optional] RubyIO io)
 {
     return(RubyYaml.DumpAll(siteStorage, self._documents, io));
 }
Exemplo n.º 13
0
                public static object CreateMap([NotNull] BlockParam /*!*/ block, Out /*!*/ self, [DefaultProtocol] MutableString taguri, object yamlStyle)
                {
                    var rep = self._representer;
                    var map = new MappingNode(rep.ToTag(taguri), new Dictionary <Node, Node>(), RubyYaml.ToYamlFlowStyle(yamlStyle));

                    object blockResult;

                    if (block.Yield(map, out blockResult))
                    {
                        return(blockResult);
                    }

                    return(map);
                }
Exemplo n.º 14
0
 public static object SetStyle(RubyContext /*!*/ context, ScalarNode /*!*/ self, object value)
 {
     self.Style = RubyYaml.ToYamlStyle(context, value);
     return(value);
 }
Exemplo n.º 15
0
 public static object SetStyle(SequenceNode /*!*/ self, object value)
 {
     self.FlowStyle = RubyYaml.ToYamlFlowStyle(value);
     return(value);
 }
Exemplo n.º 16
0
 public static object ToYaml(YamlCallSiteStorage /*!*/ siteStorage, object self, [DefaultParameterValue(null)] object options)
 {
     return(RubyYaml.DumpAll(siteStorage, new object[] { self }, null));
 }
Exemplo n.º 17
0
 public static MutableString /*!*/ TagUri(RubyContext /*!*/ context, object /*!*/ self)
 {
     return(RubyYaml.GetTagUri(context, self, Tags.Map, typeof(Hash)));
 }
Exemplo n.º 18
0
 public static object ToYaml(RubyContext /*!*/ context, object self, params object[] args)
 {
     return(RubyYaml.DumpAll(context, new object[] { self }, null));
 }
Exemplo n.º 19
0
 public static object Emit(RubyContext /*!*/ context, YamlStream /*!*/ self, [Optional] RubyIO io)
 {
     return(RubyYaml.DumpAll(context, self.Documents, io));
 }