예제 #1
0
        public override Field Convert(GroupValue fieldDef, TemplateRegistry templateRegistry, ConversionContext context)
        {
            var  name                 = new QName(fieldDef.GetString("Name"), fieldDef.GetString("Ns"));
            bool optional             = fieldDef.GetBool("Optional");
            var  exponentDef          = fieldDef.GetGroup("Exponent");
            var  exponentOperatorDef  = exponentDef.GetGroup("Operator").GetGroup(0);
            var  exponentOperator     = GetOperator(exponentOperatorDef.GetGroup());
            var  exponentDefaultValue = ScalarValue.UNDEFINED;

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

            if (mantissaDef.IsDefined("InitialValue"))
            {
                mantissaDefaultValue = new LongValue(mantissaDef.GetInt("InitialValue"));
            }
            return(Util.ComposedDecimal(name, exponentOperator, exponentDefaultValue, mantissaOperator, mantissaDefaultValue, optional));
        }
예제 #2
0
        private static Field createComposedDecimal(System.Xml.XmlElement fieldNode, QName name, bool optional, System.Xml.XmlNode mantissaNode, System.Xml.XmlNode exponentNode, ParsingContext context)
        {
            string      mantissaOperator     = "none";
            string      exponentOperator     = "none";
            ScalarValue mantissaDefaultValue = ScalarValue.UNDEFINED;
            ScalarValue exponentDefaultValue = ScalarValue.UNDEFINED;
            QName       mantissaKey          = null;
            QName       exponentKey          = null;
            string      mantissaDictionary   = context.Dictionary;
            string      exponentDictionary   = context.Dictionary;
            string      mantissaNamespace    = context.Namespace;
            string      exponentNamespace    = context.Namespace;

            if ((mantissaNode != null) && mantissaNode.HasChildNodes)
            {
                System.Xml.XmlElement operatorElement = GetElement((System.Xml.XmlElement)mantissaNode, 1);
                mantissaOperator = operatorElement.Name;

                if (operatorElement.HasAttribute("value"))
                {
                    mantissaDefaultValue = FASTType.I64.GetValue(operatorElement.GetAttribute("value"));
                }
                if (operatorElement.HasAttribute("ns"))
                {
                    mantissaNamespace = operatorElement.GetAttribute("ns");
                }
                if (operatorElement.HasAttribute("key"))
                {
                    mantissaKey = new QName(operatorElement.GetAttribute("key"), mantissaNamespace);
                }
                if (operatorElement.HasAttribute("dictionary"))
                {
                    mantissaDictionary = operatorElement.GetAttribute("dictionary");
                }
            }

            if ((exponentNode != null) && exponentNode.HasChildNodes)
            {
                System.Xml.XmlElement operatorElement = GetElement((System.Xml.XmlElement)exponentNode, 1);
                exponentOperator = operatorElement.Name;

                if (operatorElement.HasAttribute("value"))
                {
                    exponentDefaultValue = FASTType.I32.GetValue(operatorElement.GetAttribute("value"));
                }
                if (operatorElement.HasAttribute("ns"))
                {
                    exponentNamespace = operatorElement.GetAttribute("ns");
                }
                if (operatorElement.HasAttribute("key"))
                {
                    exponentKey = new QName(operatorElement.GetAttribute("key"), exponentNamespace);
                }
                if (operatorElement.HasAttribute("dictionary"))
                {
                    exponentDictionary = operatorElement.GetAttribute("dictionary");
                }
            }

            ComposedScalar scalar = Util.ComposedDecimal(name, Operator.Operator.GetOperator(exponentOperator), exponentDefaultValue, Operator.Operator.GetOperator(mantissaOperator), mantissaDefaultValue, optional);

            Scalar exponent = scalar.Fields[0];

            exponent.Dictionary = exponentDictionary;
            if (exponentKey != null)
            {
                exponent.Key = exponentKey;
            }

            Scalar mantissa = scalar.Fields[1];

            mantissa.Dictionary = mantissaDictionary;
            if (mantissaKey != null)
            {
                mantissa.Key = mantissaKey;
            }

            if (fieldNode.HasAttribute("id"))
            {
                scalar.Id = fieldNode.GetAttribute("id");
            }
            return(scalar);
        }