Beispiel #1
1
 public static object Dump(WriterSites/*!*/ sites, RubyModule/*!*/ self, object obj, [NotNull]RubyIO/*!*/ io, [Optional]int? limit)
 {
     BinaryWriter writer = io.GetBinaryWriter();
     MarshalWriter dumper = new MarshalWriter(sites, writer, self.Context, limit);
     dumper.Dump(obj);
     return io;
 }
Beispiel #2
0
        public static object Dump(WriterSites /*!*/ sites, RubyModule /*!*/ self, object obj, [NotNull] RubyIO /*!*/ io, [Optional] int?limit)
        {
            BinaryWriter  writer = io.GetBinaryWriter();
            MarshalWriter dumper = new MarshalWriter(sites, writer, self.Context, limit);

            dumper.Dump(obj);
            return(io);
        }
Beispiel #3
0
 public static MutableString Dump(WriterSites/*!*/ sites, RubyModule/*!*/ self, object obj, int limit)
 {
     MemoryStream buffer = new MemoryStream();
     BinaryWriter writer = new BinaryWriter(buffer);
     MarshalWriter dumper = new MarshalWriter(sites, writer, self.Context, limit);
     dumper.Dump(obj);
     return MutableString.CreateBinary(buffer.ToArray());
 }
Beispiel #4
0
        public static MutableString Dump(WriterSites /*!*/ sites, RubyModule /*!*/ self, object obj, int limit)
        {
            MemoryStream  buffer = new MemoryStream();
            BinaryWriter  writer = new BinaryWriter(buffer);
            MarshalWriter dumper = new MarshalWriter(sites, writer, self.Context, limit);

            dumper.Dump(obj);
            return(MutableString.CreateBinary(buffer.ToArray()));
        }
Beispiel #5
0
            internal MarshalWriter(WriterSites /*!*/ sites, BinaryWriter /*!*/ writer, RubyContext /*!*/ context, int?limit)
            {
                Assert.NotNull(sites, writer, context);

                _sites          = sites;
                _writer         = writer;
                _context        = context;
                _recursionLimit = (limit.HasValue ? limit.Value : -1);
                _symbols        = new Dictionary <string, int>();
                _objects        = new Dictionary <object, int>(ReferenceEqualityComparer.Instance);
            }
Beispiel #6
0
        public static object Dump(WriterSites /*!*/ sites, RespondToStorage /*!*/ respondToStorage,
                                  RubyModule /*!*/ self, object obj, object io, [Optional] int?limit)
        {
            Stream stream = null;

            if (io != null)
            {
                stream = RubyIOOps.CreateIOWrapper(respondToStorage, io, FileAccess.Write);
            }
            if (stream == null || !stream.CanWrite)
            {
                throw RubyExceptions.CreateTypeError("instance of IO needed");
            }

            BinaryWriter  writer = new BinaryWriter(stream);
            MarshalWriter dumper = new MarshalWriter(sites, writer, self.Context, limit);

            dumper.Dump(obj);
            return(io);
        }
Beispiel #7
0
 public static MutableString Dump(WriterSites /*!*/ sites, RubyModule /*!*/ self, object obj)
 {
     return(Dump(sites, self, obj, -1));
 }
Beispiel #8
0
            internal MarshalWriter(WriterSites/*!*/ sites, BinaryWriter/*!*/ writer, RubyContext/*!*/ context, int? limit) {
                Assert.NotNull(sites, writer, context);

                _sites = sites;
                _writer = writer;
                _context = context;
                _recursionLimit = (limit.HasValue ? limit.Value : -1);
                _symbols = new Dictionary<string, int>();
                _encodingNames = new Dictionary<RubyEncoding, MutableString>();
                _objects = new Dictionary<object, int>(ReferenceEqualityComparer<object>.Instance);
            }
Beispiel #9
0
        public static object Dump(WriterSites/*!*/ sites, RespondToStorage/*!*/ respondToStorage, 
            RubyModule/*!*/ self, object obj, object io, [Optional]int? limit) {
            Stream stream = null;
            if (io != null) {
                stream = RubyIOOps.CreateIOWrapper(respondToStorage, io, FileAccess.Write);
            }
            if (stream == null || !stream.CanWrite) {
                throw RubyExceptions.CreateTypeError("instance of IO needed");
            }

            BinaryWriter writer = new BinaryWriter(stream);
            MarshalWriter dumper = new MarshalWriter(sites, writer, self.Context, limit);
            dumper.Dump(obj);
            return io;
        }
Beispiel #10
0
 public static MutableString Dump(WriterSites/*!*/ sites, RubyModule/*!*/ self, object obj) {
     return Dump(sites, self, obj, -1);
 }
Beispiel #11
0
            internal MarshalWriter(WriterSites/*!*/ sites, BinaryWriter/*!*/ writer, RubyContext/*!*/ context, int? limit) {
                Assert.NotNull(sites, writer, context);

                _sites = sites;
                _writer = writer;
                _context = context;
                _recursionLimit = (limit.HasValue ? limit.Value : -1);
                _symbols = new Dictionary<string, int>();
                _objects = new Dictionary<object, int>(ReferenceEqualityComparer.Instance);
#if !SILVERLIGHT
                _streamingContext = new StreamingContext(StreamingContextStates.Other, _context);
#endif
            }