本文整理汇总了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);
}
示例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;
}
示例3: CrcConnection
public CrcConnection(Connection connection, BufferManager bufferManager)
{
_connection = connection;
_bufferManager = bufferManager;
_connect = true;
}
示例4: BitmapManager
public BitmapManager(BufferManager bufferManager)
{
_bitmapStream = new BufferStream(bufferManager);
_bufferManager = bufferManager;
_cacheBuffer = _bufferManager.TakeBuffer(BitmapManager.SectorSize);
}
示例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);
}
示例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());
}
示例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;
};
}
示例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;
}
示例9: BinaryArray
public BinaryArray(int length, BufferManager bufferManager)
{
_length = length;
_bufferManager = bufferManager;
_buffer = _bufferManager.TakeBuffer((_length + (8 - 1)) / 8);
Unsafe.Zero(_buffer);
}
示例10: BinaryArray
public BinaryArray(int length, BufferManager bufferManager)
{
_length = length;
_bufferManager = bufferManager;
_buffer = _bufferManager.TakeBuffer((int)BinaryArray.Roundup(_length, 8));
Unsafe.Zero(_buffer);
}
示例11: CompressConnection
public CompressConnection(Connection connection, int maxReceiveCount, BufferManager bufferManager)
{
_connection = connection;
_maxReceiveCount = maxReceiveCount;
_bufferManager = bufferManager;
_myCompressAlgorithm = CompressAlgorithm.Deflate;
}
示例12: ServerManager
public ServerManager(BufferManager bufferManager)
{
_bufferManager = bufferManager;
_settings = new Settings(this.ThisLock);
_watchTimer = new WatchTimer(this.WatchTimer, Timeout.Infinite);
}
示例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;
};
}
示例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;
}
示例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);
}