Exemplo n.º 1
0
        public override Field Convert(GroupValue fieldDef, ITemplateRegistry templateRegistry, ConversionContext context)
        {
            var         name                 = new QName(fieldDef.GetString("Name"), fieldDef.GetString("Ns"));
            bool        optional             = fieldDef.GetBool("Optional");
            GroupValue  exponentDef          = fieldDef.GetGroup("Exponent");
            GroupValue  exponentOperatorDef  = exponentDef.GetGroup("Operator").GetGroup(0);
            Operator    exponentOperator     = GetOperator(exponentOperatorDef.Group);
            ScalarValue exponentDefaultValue = ScalarValue.Undefined;

            if (exponentDef.IsDefined("InitialValue"))
            {
                exponentDefaultValue = new IntegerValue(exponentDef.GetInt("InitialValue"));
            }
            GroupValue  mantissaDef          = fieldDef.GetGroup("Mantissa");
            GroupValue  mantissaOperatorDef  = mantissaDef.GetGroup("Operator").GetGroup(0);
            Operator    mantissaOperator     = GetOperator(mantissaOperatorDef.Group);
            ScalarValue mantissaDefaultValue = ScalarValue.Undefined;

            if (mantissaDef.IsDefined("InitialValue"))
            {
                mantissaDefaultValue = new LongValue(mantissaDef.GetInt("InitialValue"));
            }
            ComposedScalar composedDecimal = Util.ComposedDecimal(name, exponentOperator, exponentDefaultValue,
                                                                  mantissaOperator, mantissaDefaultValue, optional);
            IFieldValue retAuxId;

            if (fieldDef.TryGetValue("AuxId", out retAuxId) && retAuxId != null)
            {
                composedDecimal.Id = retAuxId.ToString();
            }
            return(composedDecimal);
        }
Exemplo n.º 2
0
        public void TestDecodeSequentialEmptyMessages()
        {
            var    messageTemplate = new MessageTemplate("", new Field[0]);
            Stream input           = ByteUtil.CreateByteStream("11000000 11110001 10000000");
            var    context         = new Context();

            context.RegisterTemplate(113, messageTemplate);

            var        decoder  = new FastDecoder(context, input);
            GroupValue message  = decoder.ReadMessage();
            GroupValue message2 = decoder.ReadMessage();

            Assert.AreEqual(113, message.GetInt(0));
            Assert.AreEqual(113, message2.GetInt(0));
        }