当前位置: 首页>>代码示例>>C#>>正文


C# BufferManager类代码示例

本文整理汇总了C#中BufferManager的典型用法代码示例。如果您正苦于以下问题:C# BufferManager类的具体用法?C# BufferManager怎么用?C# BufferManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


BufferManager类属于命名空间,在下文中一共展示了BufferManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AppendPayloadAsHeader

        public static ArraySegment<byte> AppendPayloadAsHeader(ArraySegment<byte> buffer, ArraySegment<byte> payload, BufferManager bufferManager)
        {
            // We will insert at the beginning of the buffer just before the dictionary or any message content
            int posToInsert = buffer.Offset;
             
            int frameSize = PayloadMarkLength + PayloadLengthByteCount + payload.Count;
 
            byte[] newBuffer = bufferManager.TakeBuffer(buffer.Count + frameSize + buffer.Offset);
 
            int afterContent = posToInsert + frameSize;
 
            // Insert our custom mark 0xBE
            int insertPoint = posToInsert;
            newBuffer[insertPoint++] = PayloadMark;
 
            // Insert the length of the payload
            byte[] lenInBytes = BitConverter.GetBytes(payload.Count);
            newBuffer[insertPoint++] = lenInBytes[0];
            newBuffer[insertPoint++] = lenInBytes[1];
            newBuffer[insertPoint++] = lenInBytes[2];
            newBuffer[insertPoint++] = lenInBytes[3];
 
            Buffer.BlockCopy(payload.Array, payload.Offset, newBuffer, insertPoint, payload.Count);
 
            // Copy from old to new array
            Buffer.BlockCopy(buffer.Array, 0, newBuffer, 0, posToInsert); // Copy until the subheader pointer
            Buffer.BlockCopy(buffer.Array, posToInsert, newBuffer, afterContent, buffer.Count - posToInsert + buffer.Offset); // Now copy the rest
 
            return new ArraySegment<byte>(newBuffer, buffer.Offset, buffer.Count + frameSize);
        }
开发者ID:krolth,项目名称:CustomWcfEncoder,代码行数:30,代码来源:BinaryFormatHelper.cs

示例2: GetAndRemoveHeaderPayload

        public static bool GetAndRemoveHeaderPayload(ref ArraySegment<byte> buffer, BufferManager bufferManager, out OutOfBandPayloadProperty payload)
        {
            int ptrPayload;
            if (DoesBufferContainPayload(buffer, out ptrPayload))
            {
                int endOfPayload;
 
                // Get the payload content
                ArraySegment<byte> payloadSegment = BinaryFormatHelper.GetPayloadSegment(buffer, ptrPayload, out endOfPayload);
                payload = new OutOfBandPayloadProperty(payloadSegment);
 
                // Remove it from the message (In place)
                int totalPayloadSize = endOfPayload - ptrPayload;
                int newBufferSize = buffer.Offset + buffer.Count - totalPayloadSize;
 
                Buffer.BlockCopy(buffer.Array, endOfPayload, buffer.Array, ptrPayload, buffer.Count - endOfPayload);
                 
                // Return the new buffer without the payload
                buffer = new ArraySegment<byte>(buffer.Array, buffer.Offset, buffer.Count - totalPayloadSize);
 
                return true;
            }
 
            payload = null;
            return false;
        }
开发者ID:krolth,项目名称:CustomWcfEncoder,代码行数:26,代码来源:BinaryFormatHelper.cs

示例3: CrcConnection

        public CrcConnection(Connection connection, BufferManager bufferManager)
        {
            _connection = connection;
            _bufferManager = bufferManager;

            _connect = true;
        }
开发者ID:Alliance-Network,项目名称:Library,代码行数:7,代码来源:CrcConnection.cs

示例4: BitmapManager

        public BitmapManager(BufferManager bufferManager)
        {
            _bitmapStream = new BufferStream(bufferManager);
            _bufferManager = bufferManager;

            _cacheBuffer = _bufferManager.TakeBuffer(BitmapManager.SectorSize);
        }
开发者ID:Alliance-Network,项目名称:Library,代码行数:7,代码来源:BitmapManager.cs

示例5: Bot

            public Bot(BotManager manager,BotDescriptor BotDesc, int BotId)
            {
                FBotId = BotId;
                FManager = manager;
                FBotDesc = BotDesc;
                FBufferManager = new BufferManager();
                FBufferManager.Initialize(100, 100);

                FPacketSpliter = new PacketSpliter();

                FPacketSpliter.OnPacket += OnPacket;

                FConnArg = new SocketAsyncEventArgs();
                FConnArg.Completed += new EventHandler<SocketAsyncEventArgs>(IO_Completed);
                FConnArg.UserToken = this;
                FConnArg.RemoteEndPoint = FBotDesc.Host;

                FDisconnArg = new SocketAsyncEventArgs();
                FDisconnArg.Completed += new EventHandler<SocketAsyncEventArgs>(IO_Completed);
                FDisconnArg.UserToken = this;
                FDisconnArg.DisconnectReuseSocket = true;

                FSock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

                FTimer = new Timer(OnTimer);
            }
开发者ID:lythm,项目名称:orb3d,代码行数:26,代码来源:Bot.cs

示例6: should_throw_an_unabletocreatememoryexception_if_acquiring_memory_is_disabled_and_out_of_memory

 public void should_throw_an_unabletocreatememoryexception_if_acquiring_memory_is_disabled_and_out_of_memory()
 {
     BufferManager manager = new BufferManager(1, 1000, 1, false);
     manager.CheckOut();
     //should be none left, boom
     Assert.Throws<UnableToCreateMemoryException>(() => manager.CheckOut());
 }
开发者ID:danieldeb,项目名称:EventStore,代码行数:7,代码来源:BufferManagerTests.cs

示例7: AmoebaManager

        public AmoebaManager(string blocksPath, BufferManager bufferManager)
        {
            _blocksPath = blocksPath;
            _bufferManager = bufferManager;

            _clientManager = new ClientManager(_bufferManager);
            _serverManager = new ServerManager(_bufferManager);
            _cacheManager = new CacheManager(_blocksPath, _bufferManager);
            _connectionsManager = new ConnectionsManager(_clientManager, _serverManager, _cacheManager, _bufferManager);
            _downloadManager = new DownloadManager(_connectionsManager, _cacheManager, _bufferManager);
            _uploadManager = new UploadManager(_connectionsManager, _cacheManager, _bufferManager);
            _backgroundDownloadManager = new BackgroundDownloadManager(_connectionsManager, _cacheManager, _bufferManager);
            _backgroundUploadManager = new BackgroundUploadManager(_connectionsManager, _cacheManager, _bufferManager);

            _clientManager.CreateCapEvent = (object sender, string uri) =>
            {
                return _createCapEvent?.Invoke(this, uri);
            };

            _serverManager.AcceptCapEvent = (object sender, out string uri) =>
            {
                uri = null;
                return _acceptCapEvent?.Invoke(this, out uri);
            };

            _clientManager.CheckUriEvent = (object sender, string uri) =>
            {
                return _checkUriEvent?.Invoke(this, uri) ?? true;
            };

            _serverManager.CheckUriEvent = (object sender, string uri) =>
            {
                return _checkUriEvent?.Invoke(this, uri) ?? true;
            };
        }
开发者ID:Alliance-Network,项目名称:Library,代码行数:35,代码来源:AmoebaManager.cs

示例8: TcpServerChannel

 public TcpServerChannel(IPipeline serverPipeline, IPipeline childPipeline, int maxNumberOfClients)
 {
     _bufferManager = new BufferManager(maxNumberOfClients, 65535);
     _argsPool = new ObjectPool<SocketAsyncEventArgs>(AllocateArgs);
     Pipeline = serverPipeline;
     _contexts = new ContextCollection(this);
     ChildPipeline = childPipeline;
 }
开发者ID:jmptrader,项目名称:griffin,代码行数:8,代码来源:TcpServerChannel.cs

示例9: BinaryArray

        public BinaryArray(int length, BufferManager bufferManager)
        {
            _length = length;
            _bufferManager = bufferManager;

            _buffer = _bufferManager.TakeBuffer((_length + (8 - 1)) / 8);
            Unsafe.Zero(_buffer);
        }
开发者ID:networkelements,项目名称:Library,代码行数:8,代码来源:BinaryArray.cs

示例10: BinaryArray

        public BinaryArray(int length, BufferManager bufferManager)
        {
            _length = length;
            _bufferManager = bufferManager;

            _buffer = _bufferManager.TakeBuffer((int)BinaryArray.Roundup(_length, 8));
            Unsafe.Zero(_buffer);
        }
开发者ID:Alliance-Network,项目名称:Library,代码行数:8,代码来源:BinaryArray.cs

示例11: CompressConnection

        public CompressConnection(Connection connection, int maxReceiveCount, BufferManager bufferManager)
        {
            _connection = connection;
            _maxReceiveCount = maxReceiveCount;
            _bufferManager = bufferManager;

            _myCompressAlgorithm = CompressAlgorithm.Deflate;
        }
开发者ID:Alliance-Network,项目名称:Library,代码行数:8,代码来源:CompressConnection.cs

示例12: ServerManager

        public ServerManager(BufferManager bufferManager)
        {
            _bufferManager = bufferManager;

            _settings = new Settings(this.ThisLock);

            _watchTimer = new WatchTimer(this.WatchTimer, Timeout.Infinite);
        }
开发者ID:networkelements,项目名称:Library,代码行数:8,代码来源:ServerManager.cs

示例13: AmoebaManager

        public AmoebaManager(string bitmapPath, string cachePath, BufferManager bufferManager)
        {
            _bitmapPath = bitmapPath;
            _cachePath = cachePath;
            _bufferManager = bufferManager;

            _clientManager = new ClientManager(_bufferManager);
            _serverManager = new ServerManager(_bufferManager);
            _bitmapManager = new BitmapManager(_bitmapPath, _bufferManager);
            _cacheManager = new CacheManager(_cachePath, _bitmapManager, _bufferManager);
            _connectionsManager = new ConnectionsManager(_clientManager, _serverManager, _cacheManager, _bufferManager);
            _downloadManager = new DownloadManager(_connectionsManager, _cacheManager, _bufferManager);
            _uploadManager = new UploadManager(_connectionsManager, _cacheManager, _bufferManager);
            _backgroundDownloadManager = new BackgroundDownloadManager(_connectionsManager, _cacheManager, _bufferManager);
            _backgroundUploadManager = new BackgroundUploadManager(_connectionsManager, _cacheManager, _bufferManager);

            _clientManager.CreateCapEvent = (object sender, string uri) =>
            {
                if (_createCapEvent != null)
                {
                    return _createCapEvent(this, uri);
                }

                return null;
            };

            _serverManager.AcceptCapEvent = (object sender, out string uri) =>
            {
                uri = null;

                if (_acceptCapEvent != null)
                {
                    return _acceptCapEvent(this, out uri);
                }

                return null;
            };

            _clientManager.CheckUriEvent = (object sender, string uri) =>
            {
                if (_checkUriEvent != null)
                {
                    return _checkUriEvent(this, uri);
                }

                return true;
            };

            _serverManager.CheckUriEvent = (object sender, string uri) =>
            {
                if (_checkUriEvent != null)
                {
                    return _checkUriEvent(this, uri);
                }

                return true;
            };
        }
开发者ID:networkelements,项目名称:Library,代码行数:58,代码来源:AmoebaManager.cs

示例14: CacheManagerStreamWriter

 public CacheManagerStreamWriter(out KeyCollection keys, int blockLength, HashAlgorithm hashAlgorithm, CacheManager cacheManager, BufferManager bufferManager)
 {
     keys = _keyList;
     _hashAlgorithm = hashAlgorithm;
     _cacheManager = cacheManager;
     _bufferManager = bufferManager;
     _blockBuffer = bufferManager.TakeBuffer(blockLength);
     _blockBufferLength = blockLength;
 }
开发者ID:networkelements,项目名称:Library,代码行数:9,代码来源:CacheManagerStreamWriter.cs

示例15: GettingADifferentSizeThenConfigured

 public void GettingADifferentSizeThenConfigured()
 {
     var settings = CreateSettings(1, 10, 1);
     var manager = new BufferManager(settings);
     byte[] test = manager.GetBuffer(11);
     Assert.NotNull(test);
     test = manager.GetBuffer(10);
     Assert.NotNull(test);
 }
开发者ID:basespace,项目名称:TerminalVelocity,代码行数:9,代码来源:BufferManagerTests.cs


注:本文中的BufferManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。