• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# BufferManager类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: SecureConnection

        public SecureConnection(SecureConnectionVersion version, SecureConnectionType type, Connection connection, DigitalSignature digitalSignature, BufferManager bufferManager)
        {
            _type = type;
            _connection = connection;
            _digitalSignature = digitalSignature;
            _bufferManager = bufferManager;

            _myVersion = version;
        }
开发者ID:networkelements,项目名称:Library,代码行数:9,代码来源:SecureConnection.cs


示例17: GettingMoreThanInitiallyAllocatedWorks

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


示例18: ReedSolomon8

        public ReedSolomon8(int k, int n, int threadCount, BufferManager bufferManager)
        {
            _fecMath = new Math();
            _k = k;
            _n = n;
            _threadCount = threadCount;
            _bufferManager = bufferManager;

            _encMatrix = _fecMath.CreateEncodeMatrix(k, n);
        }
开发者ID:networkelements,项目名称:Library,代码行数:10,代码来源:ReedSolomon8.cs


示例19: TCPServer

        public TCPServer(TCPServerSettings settings)
        {
            _settings = settings;

            _clients = new ClientToken[_settings.MaxConnections];
            _bufferManager = new BufferManager(_settings.BufferSize, _settings.MaxConnections*2);
            _poolOfDataEventArgs = new Pool<ClientToken>(_settings.MaxConnections, false);
            _poolOfAcceptEventArgs = new Pool<SocketAsyncEventArgs>(_settings.MaxAcceptOps, false);
            _maxConnectionsEnforcer = new Semaphore(_settings.MaxConnections, _settings.MaxConnections);
        }
开发者ID:PsychoTeras,项目名称:RatKing,代码行数:10,代码来源:TCPServer.cs


示例20: BackgroundUploadManager

        public BackgroundUploadManager(ConnectionsManager connectionsManager, CacheManager cacheManager, BufferManager bufferManager)
        {
            _connectionsManager = connectionsManager;
            _cacheManager = cacheManager;
            _bufferManager = bufferManager;

            _settings = new Settings();

            _watchTimer = new WatchTimer(this.WatchTimer, Timeout.Infinite);
        }
开发者ID:Alliance-Network,项目名称:Library,代码行数:10,代码来源:BackgroundUploadManager.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# BufferPool类代码示例发布时间:2022-05-24
下一篇:
C# BufferDescription类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap