本文整理汇总了C#中Message.SetInteger方法的典型用法代码示例。如果您正苦于以下问题:C# Message.SetInteger方法的具体用法?C# Message.SetInteger怎么用?C# Message.SetInteger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Message
的用法示例。
在下文中一共展示了Message.SetInteger方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestEncodeMessageWithAllFieldTypes
public void TestEncodeMessageWithAllFieldTypes()
{
var template = new MessageTemplate(
"",
new Field[]
{
new Scalar("1", FastType.String, Operator.Copy, ScalarValue.Undefined, false),
new Scalar("2", FastType.ByteVector, Operator.Copy, ScalarValue.Undefined, false),
new Scalar("3", FastType.Decimal, Operator.Copy, ScalarValue.Undefined, false),
new Scalar("4", FastType.I32, Operator.Copy, ScalarValue.Undefined, false),
new Scalar("5", FastType.String, Operator.Copy, ScalarValue.Undefined, false),
new Scalar("6", FastType.U32, Operator.Copy, ScalarValue.Undefined, false),
});
var context = new Context();
context.RegisterTemplate(113, template);
var message = new Message(template);
message.SetString(1, "H");
message.SetByteVector(2, new[] {(byte) 0xFF});
message.SetDecimal(3, 1.201);
message.SetInteger(4, -1);
message.SetString(5, "abc");
message.SetInteger(6, 2);
// --PMAP-- --TID--- ---#1--- -------#2-------- ------------#3------------ ---#4--- ------------#5------------ ---#6---
const string msgstr =
"11111111 11110001 11001000 10000001 11111111 11111101 00001001 10110001 11111111 01100001 01100010 11100011 10000010";
AssertEquals(msgstr, new FastEncoder(context).Encode(message));
}
示例2: TestDecodeMessageWithAllFieldTypes
public void TestDecodeMessageWithAllFieldTypes()
{
// --PMAP-- --TID--- ---#1--- -------#2-------- ------------#3------------ ---#4--- ------------#5------------ ---#6---
const string msgstr =
"11111111 11110001 11001000 10000001 11111111 11111101 00001001 10110001 11111111 01100001 01100010 11100011 10000010";
Stream input = ByteUtil.CreateByteStream(msgstr);
var template = new MessageTemplate(
"",
new Field[]
{
new Scalar("1", FastType.Ascii, Operator.Copy, ScalarValue.Undefined, false),
new Scalar("2", FastType.ByteVector, Operator.Copy, ScalarValue.Undefined, false),
new Scalar("3", FastType.Decimal, Operator.Copy, ScalarValue.Undefined, false),
new Scalar("4", FastType.I32, Operator.Copy, ScalarValue.Undefined, false),
new Scalar("5", FastType.Ascii, Operator.Copy, ScalarValue.Undefined, false),
new Scalar("6", FastType.U32, Operator.Copy, ScalarValue.Undefined, false),
});
var context = new Context();
context.RegisterTemplate(113, template);
GroupValue message = new Message(template);
message.SetString(1, "H");
message.SetByteVector(2, new[] {(byte) 0xFF});
message.SetDecimal(3, 1.201);
message.SetInteger(4, -1);
message.SetString(5, "abc");
message.SetInteger(6, 2);
Assert.AreEqual(message, new FastDecoder(context, input).ReadMessage());
}
示例3: CreateFastAlertMessage
public static Message CreateFastAlertMessage(DynError code)
{
ErrorInfoAttribute attr = code.GetErrorInfo();
var alert = new Message(AlertTemplate);
alert.SetInteger(1, (int) attr.Severity);
alert.SetInteger(2, (int) code);
alert.SetString(4, attr.Description);
return alert;
}
示例4: SendMessage
public void SendMessage(string symbol)
{
var message = new Message(_ses.MessageOutputStream.TemplateRegistry["Arbitry"]);
message.SetInteger(1, _rnd.Next()%1000);
message.SetInteger(2, _rnd.Next()%1000);
message.SetInteger(3, _rnd.Next()%1000);
message.SetInteger(4, _rnd.Next()%1000);
message.SetInteger(6, _rnd.Next()%1000);
_ses.MessageOutputStream.WriteMessage(message);
}
示例5: Convert
public override GroupValue Convert(Field field, ConversionContext context)
{
var composedScalar = (ComposedScalar) field;
var message = new Message(SessionControlProtocol_1_1.COMP_DECIMAL_INSTR);
SetNameAndId(field, message);
message.SetInteger("Optional", field.Optional?1:0);
var exponentDef = CreateComponent(composedScalar.Fields[0], "Exponent");
var mantissaDef = CreateComponent(composedScalar.Fields[1], "Mantissa");
message.SetFieldValue("Exponent", exponentDef);
message.SetFieldValue("Mantissa", mantissaDef);
return message;
}
示例6: TestEquals
public void TestEquals()
{
var template = new MessageTemplate(
"",
new Field[]
{
new Scalar("1", FastType.U32, Operator.Copy, ScalarValue.Undefined, false)
});
GroupValue message = new Message(template);
message.SetInteger(1, 1);
GroupValue other = new Message(template);
other.SetInteger(1, 1);
Assert.AreEqual(message, other);
//Assert.AreEqual(message.GetHashCode(), other.GetHashCode());
}
示例7: TestNotEquals
public void TestNotEquals()
{
var template = new MessageTemplate(
"",
new Field[]
{
new Scalar("1", FastType.U32, Operator.Copy, ScalarValue.Undefined, false)
});
var message = new Message(template);
var other = new Message(template);
message.SetInteger(1, 2);
Assert.IsFalse(message.Equals(other));
Assert.IsFalse(other.Equals(message));
other.SetInteger(1, 1);
Assert.IsFalse(message.Equals(other));
Assert.IsFalse(other.Equals(message));
}
示例8: NewSession
public void NewSession(Session session)
{
//session.IsListening = true;
session.ErrorHandler = new FastServer.ServerErrorHandler();
session.MessageHandler = new MessageListener();
//register a template
var template = new MessageTemplate(
"Arbitry",
new Field[]
{
new Scalar("1", FastType.I32, Operator.Copy, ScalarValue.Undefined, false),
new Scalar("2", FastType.I32, Operator.Delta, ScalarValue.Undefined, false),
new Scalar("3", FastType.I32, Operator.Increment, new IntegerValue(10), false),
new Scalar("4", FastType.I32, Operator.Increment, ScalarValue.Undefined, false),
new Scalar("5", FastType.I32, Operator.Constant, new IntegerValue(1), false),
/* NON-TRANSFERRABLE */
new Scalar("6", FastType.I32, Operator.Default, new IntegerValue(2), false)
});
ITemplateRegistry registry = new BasicTemplateRegistry {{24, template}};
session.MessageInputStream.RegisterTemplate(24, template);
//send that template
session.SendTemplates(registry);
while (true)
{
DateTime startTime = DateTime.Now;
for (int i = 0; i < 64000; i++)
{
//make a message
var message = new Message(template);
message.SetInteger(1, 109);
message.SetInteger(2, 29470);
message.SetInteger(3, 10);
message.SetInteger(4, 3);
message.SetInteger(5, 1);
message.SetInteger(6, 2);
//send it to client
session.MessageOutputStream.WriteMessage(message);
}
double seconds = (DateTime.Now - startTime).TotalSeconds;
Console.WriteLine(seconds);
Console.WriteLine("MSG/S:" + (64000/seconds).ToString("0"));
}
}
示例9: SetUp
protected void SetUp()
{
_nameTemplate = Template("<template>" +
" <string name='name'/>" +
"</template>");
_template = Template("<template>" +
" <uInt32 name='quantity'/>" +
" <templateRef/>" +
" <decimal name='price'/>" +
"</template>");
_message = new Message(_template);
_message.SetInteger(1, 15);
_message.SetDecimal(3, 102.0);
_name = new Message(_nameTemplate);
_name.SetString(1, "IBM");
_message.SetFieldValue(2, _name);
_context = new Context();
_context.RegisterTemplate(1, _template);
_context.RegisterTemplate(2, _nameTemplate);
}
示例10: TestConstantOperatorWithMandatoryField
public void TestConstantOperatorWithMandatoryField()
{
var field = new Scalar("", FastType.U32, Operator.Constant, new IntegerValue(16), false);
MessageTemplate template = RegisterTemplate(field);
var msg1 = new Message(template);
// msg1.setInteger(1, 16);
var msg2 = new Message(template);
msg2.SetInteger(1, 16);
// --PMAP-- --TID---
EncodeAndAssertEquals("11000000 11110001", msg1);
// --PMAP--
EncodeAndAssertEquals("10000000", msg2);
GroupValue readMessage = _decoder.ReadMessage();
Assert.AreEqual(msg1, readMessage);
readMessage = _decoder.ReadMessage();
Assert.AreEqual(msg2, readMessage);
}
示例11: Encode
public byte[] Encode(Message message, Context context)
{
if (!context.TemplateRegistry.IsRegistered(message.Template))
{
throw new FastException("Cannot encode message: The template " + message.Template + " has not been registered.", Error.FastConstants.D9_TEMPLATE_NOT_REGISTERED);
}
message.SetInteger(0, context.GetTemplateId(message.Template));
return Encode(message, this, context);
}
示例12: TestEncodeMessageWithOverlongPmap
public void TestEncodeMessageWithOverlongPmap()
{
var template = new MessageTemplate(
"",
new Field[]
{
new Scalar("1", FastType.U32, Operator.Copy, new IntegerValue(1), false),
new Scalar("1", FastType.U32, Operator.Copy, new IntegerValue(1), false),
new Scalar("1", FastType.U32, Operator.Copy, new IntegerValue(1), false),
new Scalar("1", FastType.U32, Operator.Copy, new IntegerValue(1), false),
new Scalar("1", FastType.U32, Operator.Copy, new IntegerValue(1), false),
new Scalar("1", FastType.U32, Operator.Copy, new IntegerValue(1), false),
new Scalar("1", FastType.U32, Operator.Copy, new IntegerValue(1), false)
});
var context = new Context();
context.RegisterTemplate(113, template);
var message = new Message(template);
message.SetInteger(1, 1);
message.SetInteger(2, 1);
message.SetInteger(3, 1);
message.SetInteger(4, 1);
message.SetInteger(5, 1);
message.SetInteger(6, 1);
message.SetInteger(7, 1);
// --PMAP-- --PMAP-- --PMAP-- --TID---
//WHAT IT THINKS 01000000 00000000 10000000 11110001
const string msgstr = "11000000 11110001";
AssertEquals(msgstr, new FastEncoder(context).Encode(message));
}
示例13: CreateFastAlertMessage
public static Message CreateFastAlertMessage(ErrorCode code)
{
var alert = new Message(FAST_ALERT_TEMPLATE);
alert.SetInteger(1, code.Severity.Code);
alert.SetInteger(2, code.Code);
alert.SetString(4, code.Description);
return alert;
}
示例14: TestEncodeSimpleMessage
public void TestEncodeSimpleMessage()
{
var template = new MessageTemplate(
"",
new Field[]
{
new Scalar("1", FastType.U32, Operator.Copy, ScalarValue.Undefined, false)
});
var context = new Context();
context.RegisterTemplate(113, template);
var message = new Message(template);
message.SetInteger(1, 1);
var encoder = new FastEncoder(context);
AssertEquals("11100000 11110001 10000001", encoder.Encode(message));
}
示例15: TestEncodeMessageWithUnsignedIntegerFieldTypesAndAllOperators
public void TestEncodeMessageWithUnsignedIntegerFieldTypesAndAllOperators()
{
var template = new MessageTemplate(
"",
new Field[]
{
new Scalar("1", FastType.U32, Operator.Copy, ScalarValue.Undefined, false),
new Scalar("2", FastType.U32, Operator.Delta, ScalarValue.Undefined, false),
new Scalar("3", FastType.I32, Operator.Increment, new IntegerValue(10), false),
new Scalar("4", FastType.I32, Operator.Increment, ScalarValue.Undefined, false),
new Scalar("5", FastType.I32, Operator.Constant, new IntegerValue(1), false),
/* NON-TRANSFERRABLE */
new Scalar("6", FastType.I32, Operator.Default, new IntegerValue(2), false)
});
var context = new Context();
context.RegisterTemplate(113, template);
var encoder = new FastEncoder(context);
var message = new Message(template);
message.SetInteger(1, 109);
message.SetInteger(2, 29470);
message.SetInteger(3, 10);
message.SetInteger(4, 3);
message.SetInteger(5, 1);
message.SetInteger(6, 2);
// --PMAP-- --TID--- ---#1--- ------------#2------------ ---#4---
const string msg1 = "11101000 11110001 11101101 00000001 01100110 10011110 10000011";
AssertEquals(msg1, encoder.Encode(message));
message.SetInteger(2, 29471);
message.SetInteger(3, 11);
message.SetInteger(4, 4);
message.SetInteger(6, 3);
// --PMAP-- ---#2--- ---#6---
const string msg2 = "10000100 10000001 10000011";
AssertEquals(msg2, encoder.Encode(message));
message.SetInteger(1, 96);
message.SetInteger(2, 30500);
message.SetInteger(3, 12);
message.SetInteger(4, 1);
// --PMAP-- ---#1--- --------#2------- ---#4--- ---#6---
const string msg3 = "10101100 11100000 00001000 10000101 10000001 10000011";
AssertEquals(msg3, encoder.Encode(message));
}