示例#1
0
        public void InitializeTest()
        {
            BaseStream = new MemoryStream();
            for (var n = 0; n < 16; n++)
            {
                BaseStream.WriteByte((byte)n);
            }
            BaseStream.Position = 0;

            SliceStream = SliceStream.CreateWithBounds(BaseStream, 2, 6);
        }
示例#2
0
文件: TSS.cs 项目: talestra/tov
        public TSS Load(Stream Stream)
        {
            this.Stream = Stream;
            var BinaryReader = new BinaryReader(Stream);

            Header = Stream.ReadStruct <HeaderStruct>();

            if (Header.Magic != "TSS")
            {
                throw(new Exception("Not a TSS file!"));
            }

            this.CodeStream = new MemoryStream(SliceStream.CreateWithBounds(Stream, Header.CodeStart, Header.TextStart).ReadAll());

            var TextData = SliceStream.CreateWithLength(Stream, Header.TextStart, Header.TextLen).ReadAll();

            this.TextStream = new MemoryStream();
            this.TextStream.WriteBytes(TextData);
            this.TextStream.Position = 0;

            return(this);
        }
示例#3
0
 private void SpaceAssigner1DUniqueAllocatorStream_OnAllocate(byte[] bytes, SpaceAssigner1D.Space space)
 {
     SliceStream.CreateWithBounds(Stream, space.Min, space.Max).WriteBytes(bytes);
 }
 void SpaceAssigner1DUniqueAllocatorStream_OnAllocate(byte[] Bytes, SpaceAssigner1D.Space Space)
 {
     SliceStream.CreateWithBounds(this.Stream, Space.Min, Space.Max).WriteBytes(Bytes);
 }
示例#5
0
 static public SliceStream SliceWithBounds(this Stream BaseStream, long LowerBound, long UpperBound, bool?CanWrite = null)
 {
     return(SliceStream.CreateWithBounds(BaseStream, LowerBound, UpperBound, CanWrite));
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="baseStream"></param>
 /// <param name="lowerBound"></param>
 /// <param name="upperBound"></param>
 /// <param name="canWrite"></param>
 /// <returns></returns>
 public static SliceStream SliceWithBounds(this Stream baseStream, long lowerBound, long upperBound,
                                           bool?canWrite = null)
 {
     return(SliceStream.CreateWithBounds(baseStream, lowerBound, upperBound, canWrite));
 }