示例#1
1
文件: Marshal.cs 项目: TerabyteX/main
 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;
 }
示例#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);
        }
示例#3
0
文件: Marshal.cs 项目: TerabyteX/main
 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());
 }
示例#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()));
        }
示例#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);
            }
示例#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);
        }
示例#7
0
 public static MutableString Dump(WriterSites /*!*/ sites, RubyModule /*!*/ self, object obj)
 {
     return(Dump(sites, self, obj, -1));
 }
示例#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);
            }
示例#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;
        }
示例#10
0
 public static MutableString Dump(WriterSites/*!*/ sites, RubyModule/*!*/ self, object obj) {
     return Dump(sites, self, obj, -1);
 }
示例#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
            }