当前位置: 首页>>代码示例>>C#>>正文


C# Message.SetDecimal方法代码示例

本文整理汇总了C#中Message.SetDecimal方法的典型用法代码示例。如果您正苦于以下问题:C# Message.SetDecimal方法的具体用法?C# Message.SetDecimal怎么用?C# Message.SetDecimal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Message的用法示例。


在下文中一共展示了Message.SetDecimal方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestDictionaryNotInherited

        public void TestDictionaryNotInherited()
        {
            const string templateDef = "<template name='OptDeltaDec' id='58' dictionary='template'>" +
                                       "    <string name='desc'/>" +
                                       "    <decimal id='1' presence='optional' name='Line1'>" +
                                       "         <exponent><copy/></exponent>" +
                                       "         <mantissa><copy/></mantissa>" +
                                       "    </decimal>" +
                                       "    <decimal id='1' presence='optional' name='Line2'>" +
                                       "         <exponent><copy/></exponent>" +
                                       "         <mantissa><copy/></mantissa>" +
                                       "    </decimal>    " +
                                       "    <decimal id='1' presence='optional' name='Line3'>" +
                                       "         <exponent><copy/></exponent> " +
                                       "         <mantissa><copy/></mantissa>" +
                                       "    </decimal>" +
                                       "</template>";

            MessageTemplate template = Template(templateDef);

            var m = new Message(template);

            m.SetString("desc", "prev");
            m.SetDecimal("Line2", 9427.61);
            m.SetDecimal("Line3", 9427.6);

            byte[] bytes = Encoder(template).Encode(m);
            Message m2 = Decoder(template, bytes).ReadMessage();

            Assert.AreEqual(m, m2);
        }
开发者ID:shariqkudcs,项目名称:openfastdotnet,代码行数:31,代码来源:ErrorCasesTest.cs

示例2: 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));
        }
开发者ID:shariqkudcs,项目名称:openfastdotnet,代码行数:30,代码来源:FastEncoderTest.cs

示例3: TestConversions

        public void TestConversions()
        {
            MessageTemplate template = Template(
                "<template>" +
                "  <string name='string'/>" +
                "  <uInt32 name='uint'/>" +
                "  <int8 name='byte'/>" +
                "  <int16 name='short'/>" +
                "  <int64 name='long'/>" +
                "  <byteVector name='bytevector'/>" +
                "  <decimal name='decimal'/>" +
                "</template>");

            var message = new Message(template);
            message.SetByteVector("string", Byte("7f001a"));
            message.SetDecimal("uint", 150.0);
            message.SetString("byte", "4");
            message.SetString("short", "-5");
            message.SetString("long", "1000000000000000000");
            message.SetString("bytevector", "abcd");
            message.SetString("decimal", "2.3");

            FastEncoder encoder = Encoder(template);

            byte[] encoding = encoder.Encode(message);

            FastDecoder decoder = Decoder(template, encoding);
            Message decodedMessage = decoder.ReadMessage();

            Assert.AreEqual(150, decodedMessage.GetInt("uint"));
            Assert.AreEqual(150, decodedMessage.GetShort("uint"));
            Assert.AreEqual(4, decodedMessage.GetByte("byte"));
            Assert.AreEqual(-5, decodedMessage.GetShort("short"));
            Assert.AreEqual(1000000000000000000L, decodedMessage.GetLong("long"));
        }
开发者ID:shariqkudcs,项目名称:openfastdotnet,代码行数:35,代码来源:TypeConversionTest.cs

示例4: 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());
        }
开发者ID:shariqkudcs,项目名称:openfastdotnet,代码行数:30,代码来源:FastDecoderTest.cs

示例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);
        }
开发者ID:shariqkudcs,项目名称:openfastdotnet,代码行数:22,代码来源:DynamicTemplateReferenceTest.cs

示例6: TestMantissaIsntPresentWhenExponentIsNull

        public void TestMantissaIsntPresentWhenExponentIsNull()
        {
            const string templateXml = "<template name='SampleTemplate'>" +
                                       "  <decimal name='bid' presence='optional'>" +
                                       "    <mantissa><copy/></mantissa>" +
                                       "    <exponent><copy value='-2'/></exponent>" +
                                       "  </decimal>" +
                                       "</template>";
            MessageTemplate template = Template(templateXml);
            FastEncoder encoder = Encoder(template);

            var message = new Message(template);
            message.SetDecimal(1, 0.63);
            AssertEquals("11010000 10000001 10111111", encoder.Encode(message));

            message = new Message(template);
            AssertEquals("10100000 10000000", encoder.Encode(message));
        }
开发者ID:shariqkudcs,项目名称:openfastdotnet,代码行数:18,代码来源:ErrorCasesTest.cs

示例7: Quote

        public static Message Quote(double bid, double ask)
        {
            var quote = new Message(QuoteTemplate);
            quote.SetDecimal(1, bid);
            quote.SetDecimal(2, ask);

            return quote;
        }
开发者ID:shariqkudcs,项目名称:openfastdotnet,代码行数:8,代码来源:ObjectMother.cs


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