本文整理汇总了C#中Adaptive.SimpleBinaryEncoding.DirectBuffer类的典型用法代码示例。如果您正苦于以下问题:C# DirectBuffer类的具体用法?C# DirectBuffer怎么用?C# DirectBuffer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DirectBuffer类属于Adaptive.SimpleBinaryEncoding命名空间,在下文中一共展示了DirectBuffer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WrapForEncode
public void WrapForEncode(DirectBuffer buffer, int offset)
{
_buffer = buffer;
_offset = offset;
_actingBlockLength = BlockLength;
_actingVersion = Schema_Version;
Limit = offset + _actingBlockLength;
}
示例2: WrapForDecode
public void WrapForDecode(DirectBuffer buffer, int offset, int actingBlockLength, int actingVersion)
{
_buffer = buffer;
_offset = offset;
_actingBlockLength = actingBlockLength;
_actingVersion = actingVersion;
Limit = offset + _actingBlockLength;
}
示例3: Wrap
public void Wrap(DirectBuffer buffer, int offset, int actingVersion)
{
_offset = offset;
_actingVersion = actingVersion;
_buffer = buffer;
}
示例4: WrapForDecode
public void WrapForDecode(MarketDataIncrementalRefreshTrades parentMessage, DirectBuffer buffer, int actingVersion)
{
_parentMessage = parentMessage;
_buffer = buffer;
_dimensions.Wrap(buffer, parentMessage.Limit, actingVersion);
_count = _dimensions.NumInGroup;
_blockLength = _dimensions.BlockLength;
_actingVersion = actingVersion;
_index = -1;
_parentMessage.Limit = parentMessage.Limit + HeaderSize;
}
示例5: WrapForEncode
public void WrapForEncode(MarketDataIncrementalRefreshTrades parentMessage, DirectBuffer buffer, int count)
{
_parentMessage = parentMessage;
_buffer = buffer;
_dimensions.Wrap(buffer, parentMessage.Limit, _actingVersion);
_dimensions.NumInGroup = (byte)count;
_dimensions.BlockLength = (ushort)34;
_index = -1;
_count = count;
_blockLength = 34;
parentMessage.Limit = parentMessage.Limit + HeaderSize;
}
示例6: WrapForDecode
public void WrapForDecode(MassQuote parentMessage, DirectBuffer buffer, int actingVersion)
{
_parentMessage = parentMessage;
_buffer = buffer;
_dimensions.Wrap(buffer, parentMessage.Limit, actingVersion);
_count = _dimensions.NumInGroup;
_blockLength = _dimensions.BlockLength;
_actingVersion = actingVersion;
_index = -1;
_parentMessage.Limit = parentMessage.Limit + 3;
}
示例7: WrapForEncode
public void WrapForEncode(MassQuote parentMessage, DirectBuffer buffer, int count)
{
_parentMessage = parentMessage;
_buffer = buffer;
_dimensions.Wrap(buffer, parentMessage.Limit, _actingVersion);
_dimensions.NumInGroup = (byte)count;
_dimensions.BlockLength = (ushort)24;
_index = -1;
_count = count;
_blockLength = 24;
parentMessage.Limit = parentMessage.Limit + 3;
}
示例8: WrapForEncode
public void WrapForEncode(MDIncrementalRefreshLimtsBanding parentMessage, DirectBuffer buffer, int count)
{
_parentMessage = parentMessage;
_buffer = buffer;
_dimensions.Wrap(buffer, parentMessage.Limit, _actingVersion);
_dimensions.NumInGroup = (byte)count;
_dimensions.BlockLength = (ushort)32;
_index = -1;
_count = count;
_blockLength = 32;
parentMessage.Limit = parentMessage.Limit + 3;
}
示例9: WrapForEncode
public void WrapForEncode(Car parentMessage, DirectBuffer buffer, int count)
{
_parentMessage = parentMessage;
_buffer = buffer;
_dimensions.Wrap(buffer, parentMessage.Limit, _actingVersion);
_dimensions.BlockLength = (ushort)6;
_dimensions.NumInGroup = (byte)count;
_index = -1;
_count = count;
_blockLength = 6;
parentMessage.Limit = parentMessage.Limit + SbeHeaderSize;
}
示例10: WrapForDecode
public void WrapForDecode(Car parentMessage, DirectBuffer buffer, int actingVersion)
{
_parentMessage = parentMessage;
_buffer = buffer;
_dimensions.Wrap(buffer, parentMessage.Position, actingVersion);
_count = _dimensions.NumInGroup;
_blockLength = _dimensions.BlockLength;
_actingVersion = actingVersion;
_index = -1;
const int dimensionsHeaderSize = 3;
_parentMessage.Position = parentMessage.Position + dimensionsHeaderSize;
}
示例11: WrapForEncode
public void WrapForEncode(MDInstrumentDefinitionFuture parentMessage, DirectBuffer buffer, int count)
{
_parentMessage = parentMessage;
_buffer = buffer;
_dimensions.Wrap(buffer, parentMessage.Limit, _actingVersion);
_dimensions.NumInGroup = (byte)count;
_dimensions.BlockLength = (ushort)5;
_index = -1;
_count = count;
_blockLength = 5;
parentMessage.Limit = parentMessage.Limit + 3;
}
示例12: WrapForEncode
public void WrapForEncode(Car parentMessage, DirectBuffer buffer, int count)
{
_parentMessage = parentMessage;
_buffer = buffer;
_dimensions.Wrap(buffer, parentMessage.Position, _actingVersion);
_dimensions.NumInGroup = (byte)count;
_dimensions.BlockLength = (ushort)1;
_index = -1;
_count = count;
_blockLength = 1;
const int dimensionsHeaderSize = 3;
parentMessage.Position = parentMessage.Position + dimensionsHeaderSize;
}
示例13: Decode
private static void Decode(Car car,
DirectBuffer directBuffer,
int bufferOffset,
int actingBlockLength,
int actingVersion)
{
var buffer = new byte[128];
var sb = new StringBuilder();
car.WrapForDecode(directBuffer, bufferOffset, actingBlockLength, actingVersion);
sb.Append("\ncar.templateId=").Append(Car.TemplateId);
sb.Append("\ncar.serialNumber=").Append(car.SerialNumber);
sb.Append("\ncar.modelYear=").Append(car.ModelYear);
sb.Append("\ncar.available=").Append(car.Available);
sb.Append("\ncar.code=").Append(car.Code);
sb.Append("\ncar.someNumbers=");
for (int i = 0, size = Car.SomeNumbersLength; i < size; i++)
{
sb.Append(car.GetSomeNumbers(i)).Append(", ");
}
sb.Append("\ncar.vehicleCode=");
for (int i = 0, size = Car.VehicleCodeLength; i < size; i++)
{
sb.Append((char) car.GetVehicleCode(i));
}
OptionalExtras extras = car.Extras;
sb.Append("\ncar.extras.cruiseControl=").Append((extras & OptionalExtras.CruiseControl) == OptionalExtras.CruiseControl);
sb.Append("\ncar.extras.sportsPack=").Append((extras & OptionalExtras.SportsPack) == OptionalExtras.SportsPack);
sb.Append("\ncar.extras.sunRoof=").Append((extras & OptionalExtras.SunRoof) == OptionalExtras.SunRoof);
Engine engine = car.Engine;
sb.Append("\ncar.engine.capacity=").Append(engine.Capacity);
sb.Append("\ncar.engine.numCylinders=").Append(engine.NumCylinders);
sb.Append("\ncar.engine.maxRpm=").Append(engine.MaxRpm);
sb.Append("\ncar.engine.manufacturerCode=");
for (int i = 0, size = Engine.ManufacturerCodeLength; i < size; i++)
{
sb.Append((char) engine.GetManufacturerCode(i));
}
int length = engine.GetFuel(buffer, 0, buffer.Length);
sb.Append("\ncar.engine.fuel=").Append(Encoding.ASCII.GetString(buffer, 0, length));
var fuelFiguresGroup = car.FuelFigures;
while (fuelFiguresGroup.HasNext)
{
var fuelFigures = fuelFiguresGroup.Next();
sb.Append("\ncar.fuelFigures.speed=").Append(fuelFigures.Speed);
sb.Append("\ncar.fuelFigures.mpg=").Append(fuelFigures.Mpg);
}
var performanceFiguresGroup = car.PerformanceFigures;
while (performanceFiguresGroup.HasNext)
{
var performanceFigures = performanceFiguresGroup.Next();
sb.Append("\ncar.performanceFigures.octaneRating=").Append(performanceFigures.OctaneRating);
var accelerationGroup = performanceFigures.Acceleration;
while (accelerationGroup.HasNext)
{
var acceleration = accelerationGroup.Next();
sb.Append("\ncar.performanceFigures.acceleration.mph=").Append(acceleration.Mph);
sb.Append("\ncar.performanceFigures.acceleration.seconds=").Append(acceleration.Seconds);
}
}
length = car.GetMake(buffer, 0, buffer.Length);
sb.Append("\ncar.make=").Append(Encoding.GetEncoding(Car.MakeCharacterEncoding).GetString(buffer, 0, length));
length = car.GetModel(buffer, 0, buffer.Length);
sb.Append("\ncar.model=").Append(Encoding.GetEncoding(Car.ModelCharacterEncoding).GetString(buffer, 0, length));
sb.Append("\ncar.size=").Append(car.Size);
Console.WriteLine(sb.ToString());
}
示例14: Main
private static void Main()
{
var byteBuffer = new byte[4096];
var directBuffer = new DirectBuffer(byteBuffer);
const short messageTemplateVersion = 0;
int bufferOffset = 0;
int encodingLength = 0;
// Setup for encoding a message
MessageHeader.Wrap(directBuffer, bufferOffset, messageTemplateVersion);
MessageHeader.BlockLength = Car.BlockLength;
MessageHeader.TemplateId = Car.TemplateId;
MessageHeader.Version = Car.TemplateVersion;
bufferOffset += MessageHeader.Size;
encodingLength += MessageHeader.Size;
encodingLength += Encode(Car, directBuffer, bufferOffset);
// Decode the encoded message
bufferOffset = 0;
MessageHeader.Wrap(directBuffer, bufferOffset, messageTemplateVersion);
// Lookup the applicable flyweight to decode this type of message based on templateId and version.
int templateId = MessageHeader.TemplateId;
short actingVersion = MessageHeader.Version;
int actingBlockLength = MessageHeader.BlockLength;
bufferOffset += MessageHeader.Size;
Decode(Car, directBuffer, bufferOffset, actingBlockLength, actingVersion);
Console.ReadKey();
}
示例15: Encode
private static int Encode(Car car, DirectBuffer directBuffer, int bufferOffset)
{
int srcOffset = 0;
car.WrapForEncode(directBuffer, bufferOffset);
car.SerialNumber = 1234;
car.ModelYear = 2013;
car.Available = BooleanType.TRUE;
car.Code = Model.A;
car.SetVehicleCode(_vehicleCode, srcOffset);
for (int i = 0, size = Car.SomeNumbersLength; i < size; i++)
{
car.SetSomeNumbers(i, i);
}
car.Extras = OptionalExtras.CruiseControl | OptionalExtras.SunRoof;
car.Engine.Capacity = 2000;
car.Engine.NumCylinders = 4;
car.Engine.SetManufacturerCode(_manufacturerCode, srcOffset);
var fuelFigures = car.FuelFiguresCount(3);
fuelFigures.Next();
fuelFigures.Speed = 30;
fuelFigures.Mpg = 35.9f;
fuelFigures.Next();
fuelFigures.Speed = 55;
fuelFigures.Mpg = 49.0f;
fuelFigures.Next();
fuelFigures.Speed = 75;
fuelFigures.Mpg = 40.0f;
Car.PerformanceFiguresGroup perfFigures = car.PerformanceFiguresCount(2);
perfFigures.Next();
perfFigures.OctaneRating = 95;
Car.PerformanceFiguresGroup.AccelerationGroup acceleration = perfFigures.AccelerationCount(3).Next();
acceleration.Mph = 30;
acceleration.Seconds = 4.0f;
acceleration.Next();
acceleration.Mph = 60;
acceleration.Seconds = 7.5f;
acceleration.Next();
acceleration.Mph = 100;
acceleration.Seconds = 12.2f;
perfFigures.Next();
perfFigures.OctaneRating = 99;
acceleration = perfFigures.AccelerationCount(3).Next();
acceleration.Mph = 30;
acceleration.Seconds = 3.8f;
acceleration.Next();
acceleration.Mph = 60;
acceleration.Seconds = 7.1f;
acceleration.Next();
acceleration.Mph = 100;
acceleration.Seconds = 11.8f;
car.SetMake(_make, srcOffset, _make.Length);
car.SetMake(_model, srcOffset, _model.Length);
return car.Size;
}