Exemplo n.º 1
0
        private SomeData transformBytesToData(byte[] arg)
        {
            if (!this.StopWatch.IsRunning)
            {
                this.StopWatch.Restart();
            }

            if (arg.Length != this.dataSize)
            {
                return(new SomeData(1));
            }

            var      dataSpan    = new Span <byte>(arg);
            SomeData data        = new SomeData();
            var      globalSlice = dataSpan.Slice(this.sizeOfSeperator, this.sizeOfGlobal);
            var      gdata       = MemoryMarshal.AsRef <Global>(globalSlice);

            data.Global = gdata;

            var contentSilce = dataSpan.Slice(this.sizeOfGlobal + this.sizeOfSeperator);

            data.Content = new AmpTof[this.numberOfItems];

            for (var i = 0; i < this.numberOfItems; i++)
            {
                var amp_silice = contentSilce.Slice(i * sizeOfAmp, sizeOfAmp);
                var ampdata    = MemoryMarshal.AsRef <AmpTof>(amp_silice);
                data.Content[i] = ampdata;
            }

            return(data);
        }
Exemplo n.º 2
0
        public SocketWriter()
        {
            var small = new SomeData(Constants.SIZEOF_SMALL);
            var big   = new SomeData(Constants.SIZEOF_BIG);


            var sepSpan  = new Span <Seperator>(new Seperator[] { small.Seperator });
            var sepBytes = MemoryMarshal.AsBytes(sepSpan).ToArray();

            var globSpan  = new Span <Global>(new Global[] { small.Global });
            var globBytes = MemoryMarshal.AsBytes(globSpan).ToArray();

            var smallSpan  = new Span <AmpTof>(small.Content);
            var smallBytes = MemoryMarshal.AsBytes(smallSpan).ToArray();

            var bigSpan       = new Span <AmpTof>(big.Content);
            var bigBytes      = MemoryMarshal.AsBytes(bigSpan).ToArray();
            var smallByteList = new List <byte>();

            smallByteList.AddRange(sepBytes);
            smallByteList.AddRange(globBytes);
            smallByteList.AddRange(smallBytes);
            this.smallBuffer = smallByteList.ToArray();

            var bigByteList = new List <byte>();

            bigByteList.AddRange(sepBytes);
            bigByteList.AddRange(globBytes);
            bigByteList.AddRange(bigBytes);
            this.bigBuffer = bigByteList.ToArray();
        }
Exemplo n.º 3
0
        private SomeData transformBytesToDataBf(byte[] arg)
        {
            if (!this.StopWatch.IsRunning)
            {
                this.StopWatch.Restart();
            }

            var data = new SomeData(this.numberOfItems);

            using (var ms = new MemoryStream(arg))
            {
                var bf = new BinaryFormatter();
                data = (SomeData)bf.Deserialize(ms);
            }

            return(data);
        }
Exemplo n.º 4
0
 public void StoreDataAction(SomeData obj)
 {
     this.dataStore.Add(obj);
 }