public static Camera CreateCamera(IOutputBuffer output) => new Camera(output, MathF.PI / 3)
 {
     Transform = CreateViewTransform(
         from: CreatePoint(-5, 3, -5),
         to: CreatePoint(0, 1, 0),
         up: CreateVector(0, 1, 0)),
 };
Beispiel #2
0
        public ChunkProcessor Create(BlockingCollection <FileChunk> jobQueue, IOutputBuffer outputBuffer,
                                     CountdownEvent countdown, CancellationTokenSource cancellationTokenSource)
        {
            var processor = jobContext.Operation == Operation.Compress
                ? new Compressor(recyclableMemoryStreamManager) as IByteProcessor
                : new Decompressor(recyclableMemoryStreamManager);

            return(new ChunkProcessor(jobQueue, outputBuffer, processor, jobContext, cancellationTokenSource,
                                      countdown));
        }
 public ChunkProcessor(BlockingCollection <FileChunk> jobQueue, IOutputBuffer outputBuffer,
                       IByteProcessor byteProcessor, IJobContext jobContext, CancellationTokenSource cancellationTokenSource,
                       CountdownEvent countdown)
 {
     this.jobQueue                = jobQueue;
     this.outputBuffer            = outputBuffer;
     this.byteProcessor           = byteProcessor;
     this.jobContext              = jobContext;
     this.cancellationTokenSource = cancellationTokenSource;
     this.countdown               = countdown;
 }
        public void EncodeText(IOutputBuffer output, string message)
        {
            var maxByteCount = Encoding.UTF8.GetMaxByteCount(message.Length) + 2;
            var sendBuffer   = new byte[maxByteCount];

            sendBuffer[0] = WebSocketConstant.StartByte;
            int bytesCount = Encoding.UTF8.GetBytes(message, 0, message.Length, sendBuffer, 1);

            sendBuffer[1 + bytesCount] = WebSocketConstant.EndByte;
            output.Add(new ArraySegment <byte>(sendBuffer, 0, bytesCount + 2));
        }
Beispiel #5
0
 private void getIOBuffers(out IInputBuffer[] inputBuffers, out IOutputBuffer[] outputBuffers,
                           int numberOfBuffers)
 {
     inputBuffers  = new IInputBuffer[numberOfBuffers];
     outputBuffers = new IOutputBuffer[numberOfBuffers];
     for (var i = 0; i < numberOfBuffers; i++)
     {
         inputBuffers[i]  = Substitute.For <IInputBuffer>();
         outputBuffers[i] = Substitute.For <IOutputBuffer>();
     }
 }
Beispiel #6
0
        public void EncodeData(IOutputBuffer output, IList <ArraySegment <byte> > data)
        {
            var result    = new List <ArraySegment <byte> >(data.Count);
            var lastIndex = data.Count - 1;

            for (var i = 0; i < data.Count; i++)
            {
                data[i] = EncodeData(i == 0 ? OpCode.Binary : OpCode.Continuation, i == lastIndex, data[i]);
            }

            output.AddRange(data);
        }
        public void EncodeData(IOutputBuffer output, IList<ArraySegment<byte>> data)
        {
            var result = new List<ArraySegment<byte>>(data.Count);
            var lastIndex = data.Count - 1;

            for(var i = 0; i < data.Count; i++)
            {
                data[i] = EncodeData(i == 0 ? OpCode.Binary : OpCode.Continuation, i == lastIndex, data[i]);
            }

            output.AddRange(data);
        }
Beispiel #8
0
        public override void Print(IOutputBuffer buffer)
        {
            string line;
            if (Code == TTokenCode.Identifier)
            {
                line = string.Format("\t{0,-18} {1}", ">> identifier:", TokenString);
            }
            else
            {
                line = string.Format("\t{0, -18} {1}", ">> reserved word:", TokenString);
            }

            buffer.PutLine(line);
        }
Beispiel #9
0
        public void getNextRecordValueFromSourceInputBuffer()
        {
            var goodRecord = new Record(new double[] { 1, 1, 1, });
            var badRecord  = new Record(new double[] { 0, 0, 0 });

            var sourceInputBuffer = Substitute.For <IInputBuffer>();

            sourceInputBuffer.GetNextRecord().Returns(goodRecord);
            sourceInputBuffer.HasNext().Returns(true);
            sourceInputBuffer.RemoveDummyRecord().Throws(new Exception("No dummy records should be removed here!"));
            var sourceOutputBuffer = Substitute.For <IOutputBuffer>();

            sourceOutputBuffer.LastAppendedRecord.Returns(goodRecord);

            var tempInputBuffers  = new IInputBuffer[4];
            var tempOutputBuffers = new IOutputBuffer[4];

            for (var i = 0; i < 3; i++)
            {
                tempInputBuffers[i] = Substitute.For <IInputBuffer>();
                tempInputBuffers[i].GetNextRecord().Returns(badRecord);
                tempInputBuffers[i].HasNext().Returns(true);
                tempOutputBuffers[i] = Substitute.For <IOutputBuffer>();
                tempOutputBuffers[i].LastAppendedRecord.Returns(badRecord);
            }

            tempInputBuffers[3]  = sourceInputBuffer;
            tempOutputBuffers[3] = sourceOutputBuffer;

            var fileBufferIO = new DistributionBufferingIO(ref tempInputBuffers, ref tempOutputBuffers, 3);

            var actualRecord = fileBufferIO.GetNextFromCurrentInputBuffer();

            Assert.AreEqual(false, actualRecord.IsDummy);
            Assert.AreEqual(goodRecord.Value, actualRecord.Value);
        }
Beispiel #10
0
 public override void Print(IOutputBuffer buffer)
 {
     throw new NotImplementedException();
 }
Beispiel #11
0
 public abstract void Print(IOutputBuffer buffer);
 public void EncodeText(IOutputBuffer outout, string message)
 {
     outout.Add(new ArraySegment<byte>(m_Encoding.GetBytes(message + s_NewLine)));
 }
Beispiel #13
0
        public override void Print(IOutputBuffer buffer)
        {
            string lineText;
            if (type == TDataType.tyInteger)
            {
                lineText = string.Format("\t{0, -18} {1}", ">> integer:", value.integerValue);
            }
            else
            {
                lineText = string.Format("\t{0, -18} {1:g}", ">> real:", value.realValue);
            }

            buffer.PutLine(lineText);
        }
 public void EncodeData(IOutputBuffer output, ArraySegment<byte> data)
 {
     output.Add(EncodeData(OpCode.Binary, true, data));
 }
Beispiel #15
0
 public override void Print(IOutputBuffer buffer)
 {
     string lineText = string.Format("\t{0, -18} {1}", ">> string:", TokenString);
     buffer.PutLine(lineText);
 }
Beispiel #16
0
 public virtual void Print(IOutputBuffer buffer)
 {
 }
Beispiel #17
0
 public void EncodeText(IOutputBuffer outout, string message)
 {
     outout.Add(new ArraySegment <byte>(m_Encoding.GetBytes(message + s_NewLine)));
 }
Beispiel #18
0
 public void EncodeData(IOutputBuffer output, ArraySegment <byte> data)
 {
     output.Add(EncodeData(OpCode.Binary, true, data));
 }
 public void EncodeData(IOutputBuffer output, ArraySegment<byte> data)
 {
     throw new NotSupportedException(c_NotSupportErrorMessage);
 }
 public void EncodeData(IOutputBuffer output, ArraySegment <byte> data)
 {
     throw new NotSupportedException(c_NotSupportErrorMessage);
 }
Beispiel #21
0
 public PermutationGenerator(IOutputBuffer buffer, string permutationContent, int sizeOfPermutations)
 {
     _buffer             = buffer;
     _permutationContent = permutationContent;
     _sizeOfPermutations = sizeOfPermutations;
 }