本文整理汇总了C#中Message.SetFieldValue方法的典型用法代码示例。如果您正苦于以下问题:C# Message.SetFieldValue方法的具体用法?C# Message.SetFieldValue怎么用?C# Message.SetFieldValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Message
的用法示例。
在下文中一共展示了Message.SetFieldValue方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Convert
public override GroupValue Convert(Field field, ConversionContext context)
{
var composedScalar = (ComposedScalar) field;
var message = new Message(SessionControlProtocol11.CompDecimalInstr);
SetNameAndId(field, message);
message.SetInteger("Optional", field.IsOptional ? 1 : 0);
GroupValue exponentDef = CreateComponent(composedScalar.Fields[0], "Exponent");
GroupValue mantissaDef = CreateComponent(composedScalar.Fields[1], "Mantissa");
message.SetFieldValue("Exponent", exponentDef);
message.SetFieldValue("Mantissa", mantissaDef);
return message;
}
示例2: TestMultipleDictionaryTypes
public void TestMultipleDictionaryTypes()
{
var bid = new Scalar("bid", FastType.Decimal, Operator.Copy, ScalarValue.Undefined, false)
{Dictionary = DictionaryFields.Template};
var quote = new MessageTemplate("quote", new Field[] {bid});
var bidR = new Scalar("bid", FastType.Decimal, Operator.Copy, ScalarValue.Undefined, false);
var request = new MessageTemplate("request", new Field[] {bidR});
var quote1 = new Message(quote);
quote1.SetFieldValue(1, new DecimalValue(10.2));
var request1 = new Message(request);
request1.SetFieldValue(1, new DecimalValue(10.3));
var quote2 = new Message(quote);
quote2.SetFieldValue(1, new DecimalValue(10.2));
var request2 = new Message(request);
request2.SetFieldValue(1, new DecimalValue(10.2));
_session.MessageOutputStream.RegisterTemplate(1, request);
_session.MessageOutputStream.RegisterTemplate(2, quote);
_session.MessageOutputStream.WriteMessage(quote1);
_session.MessageOutputStream.WriteMessage(request1);
_session.MessageOutputStream.WriteMessage(quote2);
_session.MessageOutputStream.WriteMessage(request2);
const string expected = "11100000 10000010 11111111 00000000 11100110 " +
"11100000 10000001 11111111 00000000 11100111 " +
"11000000 10000010 " +
"11100000 10000001 11111111 00000000 11100110";
TestUtil.AssertBitVectorEquals(expected, TestUtil.ToByte(_output));
}
示例3: Convert
public static Message Convert(Group group, Message groupMsg, ConversionContext context)
{
SetNameAndId(group, groupMsg);
if (group.TypeReference != null && !FastConstants.AnyType.Equals(group.TypeReference))
{
var typeRef =
new GroupValue(
(Group) SessionControlProtocol11
.TypeRef
.GetField(new QName("TypeRef", SessionControlProtocol11.Namespace)));
SetName(typeRef, group.TypeReference);
groupMsg.SetFieldValue("TypeRef", typeRef);
}
var instructions = new SequenceValue(
SessionControlProtocol11.TemplateDefinition.GetSequence("Instructions"));
if (group.TypeReference != null && !FastConstants.AnyType.Equals(group.TypeReference))
{
var typeRef =
new GroupValue(
(Group)
SessionControlProtocol11
.TypeRef
.GetField(new QName("TypeRef", SessionControlProtocol11.Namespace)));
SetName(typeRef, group.TypeReference);
groupMsg.SetFieldValue("TypeRef", typeRef);
}
Field[] fields = group.FieldDefinitions;
for (int i = group is MessageTemplate ? 1 : 0; i < fields.Length; i++)
{
Field field = fields[i];
IFieldInstructionConverter converter = context.GetConverter(field);
if (converter == null)
throw new InvalidOperationException("No converter found for type " + field.GetType());
IFieldValue v = converter.Convert(field, context);
instructions.Add(new[] {v});
}
groupMsg.SetFieldValue("Instructions", instructions);
return groupMsg;
}
示例4: Convert
public static Message Convert(Group group, Message groupMsg, ConversionContext context)
{
SetNameAndId(group, groupMsg);
var instructions = new SequenceValue(SessionControlProtocol_1_1.TEMPLATE_DEFINITION.GetSequence("Instructions"));
int i = group is MessageTemplate?1:0;
Field[] fields = group.FieldDefinitions;
for (; i < fields.Length; i++)
{
Field field = fields[i];
FieldInstructionConverter converter = context.GetConverter(field);
if (converter == null)
throw new System.SystemException("No converter found for type " + field.GetType());
FieldValue value_Renamed = converter.Convert(field, context);
instructions.Add(new[]{value_Renamed});
}
groupMsg.SetFieldValue("Instructions", instructions);
return groupMsg;
}
示例5: 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);
}
示例6: CreateOperator
public static GroupValue CreateOperator(Scalar scalar)
{
MessageTemplate operatorTemplate;
if (!OperatorTemplateMap.TryGetValue(scalar.Operator, out operatorTemplate))
return null;
GroupValue operatorMessage = new Message(operatorTemplate);
if (!scalar.Dictionary.Equals(DictionaryFields.Global))
operatorMessage.SetString("Dictionary", scalar.Dictionary);
if (!scalar.Key.Equals(scalar.QName))
{
Group key = operatorTemplate.GetGroup("Key");
var keyValue = new GroupValue(key);
keyValue.SetString("Name", scalar.Key.Name);
keyValue.SetString("Ns", scalar.Key.Namespace);
operatorMessage.SetFieldValue(key, keyValue);
}
return operatorMessage;
}
示例7: Convert
public override GroupValue Convert(Field field, ConversionContext context)
{
var scalar = (Scalar) field;
var scalarTemplate = (MessageTemplate) _typeTemplateMap[scalar.FastType];
var scalarMsg = new Message(scalarTemplate);
SetNameAndId(scalar, scalarMsg);
scalarMsg.SetInteger("Optional", scalar.IsOptional ? 1 : 0);
if (!scalar.Operator.Equals(Operator.None))
scalarMsg.SetFieldValue(
"Operator",
new GroupValue(scalarTemplate.GetGroup("Operator"), new IFieldValue[] {CreateOperator(scalar)}));
if (!scalar.DefaultValue.IsUndefined)
scalarMsg.SetFieldValue("InitialValue", scalar.DefaultValue);
return scalarMsg;
}
示例8: TestComplexMessage
public void TestComplexMessage()
{
var template = new MessageTemplate(
"Company",
new Field[]
{
new Scalar("Name", FastType.String, Operator.None, ScalarValue.Undefined, false),
new Scalar("Id", FastType.U32, Operator.Increment, ScalarValue.Undefined, false),
new Sequence(
"Employees",
new Field[]
{
new Scalar("First Name", FastType.String, Operator.Copy, ScalarValue.Undefined,
false),
new Scalar("Last Name", FastType.String, Operator.Copy, ScalarValue.Undefined, false)
,
new Scalar("Age", FastType.U32, Operator.Delta, ScalarValue.Undefined, false)
}, false),
new Group(
"Tax Information",
new Field[]
{
new Scalar("EIN", FastType.String, Operator.None, ScalarValue.Undefined, false)
}, false)
});
var aaaInsurance = new Message(template);
aaaInsurance.SetFieldValue(1, new StringValue("AAA Insurance"));
aaaInsurance.SetFieldValue(2, new IntegerValue(5));
var employees = new SequenceValue(template.GetSequence(
"Employees"));
employees.Add(new IFieldValue[]
{
new StringValue("John"), new StringValue("Doe"),
new IntegerValue(45)
});
employees.Add(new IFieldValue[]
{
new StringValue("Jane"), new StringValue("Doe"),
new IntegerValue(48)
});
aaaInsurance.SetFieldValue(3, employees);
aaaInsurance.SetFieldValue(4,
new GroupValue(template.GetGroup("Tax Information"),
new IFieldValue[] {new StringValue("99-99999999")}));
var outStream = new MemoryStream();
var output = new MessageOutputStream(outStream);
output.RegisterTemplate(1, template);
output.WriteMessage(aaaInsurance);
var abcBuilding = new Message(template);
abcBuilding.SetFieldValue(1, new StringValue("ABC Building"));
abcBuilding.SetFieldValue(2, new IntegerValue(6));
employees = new SequenceValue(template.GetSequence("Employees"));
employees.Add(new IFieldValue[]
{
new StringValue("Bob"), new StringValue("Builder"),
new IntegerValue(3)
});
employees.Add(new IFieldValue[]
{
new StringValue("Joe"), new StringValue("Rock"),
new IntegerValue(59)
});
abcBuilding.SetFieldValue(3, employees);
abcBuilding.SetFieldValue(4,
new GroupValue(template.GetGroup("Tax Information"),
new IFieldValue[] {new StringValue("99-99999999")}));
output.WriteMessage(abcBuilding);
var input = new MessageInputStream(new MemoryStream(outStream.ToArray()));
input.RegisterTemplate(1, template);
GroupValue message = input.ReadMessage();
Assert.AreEqual(aaaInsurance, message);
message = input.ReadMessage();
Assert.AreEqual(abcBuilding, message);
}
示例9: NewAllocInstrctn
public static Message NewAllocInstrctn(String id, int side,
double quantity, double averagePrice, GroupValue instrument,
SequenceValue allocations)
{
var allocInstrctn = new Message(AllocationInstruction);
allocInstrctn.SetFieldValue(1, allocations);
allocInstrctn.SetFieldValue(2, instrument);
allocInstrctn.SetFieldValue(3, new StringValue(id));
allocInstrctn.SetFieldValue(4, new IntegerValue(side));
allocInstrctn.SetFieldValue(5, new DecimalValue(quantity));
allocInstrctn.SetFieldValue(6, new DecimalValue(averagePrice));
return allocInstrctn;
}
示例10: CreateOperator
public static GroupValue CreateOperator(Scalar scalar)
{
if (!OPERATOR_TEMPLATE_MAP.Contains(scalar.Operator))
return null;
var operatorTemplate = (MessageTemplate) OPERATOR_TEMPLATE_MAP[scalar.Operator];
GroupValue operatorMessage = new Message(operatorTemplate);
if (!scalar.Dictionary.Equals(Dictionary_Fields.GLOBAL))
operatorMessage.SetString("Dictionary", scalar.Dictionary);
if (!scalar.Key.Equals(scalar.QName))
{
var key = operatorTemplate.GetGroup("Key");
var keyValue = new GroupValue(key);
keyValue.SetString("Name", scalar.Key.Name);
keyValue.SetString("Ns", scalar.Key.Namespace);
operatorMessage.SetFieldValue(key, keyValue);
}
return operatorMessage;
}