Example #1
0
        public override Field Convert(GroupValue fieldDef, TemplateRegistry templateRegistry, ConversionContext context)
        {
            var  type         = (Type)TEMPLATE_TYPE_MAP[fieldDef.GetGroup()];
            bool optional     = fieldDef.GetBool("Optional");
            var  initialValue = ScalarValue.UNDEFINED;

            if (fieldDef.IsDefined("InitialValue"))
            {
                initialValue = (ScalarValue)fieldDef.GetValue("InitialValue");
            }

            if (fieldDef.IsDefined("Operator"))
            {
                GroupValue operatorGroup    = fieldDef.GetGroup("Operator").GetGroup(0);
                Operator   operator_Renamed = GetOperator(operatorGroup.GetGroup());
                var        scalar           = new Scalar(fieldDef.GetString("Name"), type, operator_Renamed, initialValue, optional);
                if (operatorGroup.IsDefined("Dictionary"))
                {
                    scalar.Dictionary = operatorGroup.GetString("Dictionary");
                }
                if (operatorGroup.IsDefined("Key"))
                {
                    string name = operatorGroup.GetGroup("Key").GetString("Name");
                    string ns   = operatorGroup.GetGroup("Key").GetString("Ns");
                    scalar.Key = new QName(name, ns);
                }
                return(scalar);
            }
            return(new Scalar(fieldDef.GetString("Name"), type, Operator.NONE, initialValue, optional));
        }
Example #2
0
        public static ComposedScalar ComposedDecimal(QName name, Operator exponentOp, ScalarValue exponentVal, Operator mantissaOp, ScalarValue mantissaVal, bool optional)
        {
            var exponentScalar = new Scalar(Global.CreateImplicitName(name), Type.I32, exponentOp, exponentVal, optional);
            var mantissaScalar = new Scalar(Global.CreateImplicitName(name), Type.I64, mantissaOp, mantissaVal, false);

            return(new ComposedScalar(name, Type.DECIMAL, new[] { exponentScalar, mantissaScalar }, optional, new DecimalConverter()));
        }
        private static GroupValue CreateComponent(Scalar component, string componentName)
        {
            var componentGroup         = SessionControlProtocol_1_1.COMP_DECIMAL_INSTR.GetGroup(componentName);
            var componentDef           = new GroupValue(componentGroup);
            var componentOperatorDef   = CreateOperator(component);
            var componentOperatorGroup = new GroupValue(componentGroup.GetGroup("Operator"));

            componentDef.SetFieldValue("Operator", componentOperatorGroup);
            componentOperatorGroup.SetFieldValue(0, componentOperatorDef);
            if (!component.DefaultValue.Undefined)
            {
                componentDef.SetInteger("InitialValue", component.DefaultValue.ToInt());
            }
            return(componentDef);
        }
Example #4
0
        public override Field Convert(GroupValue fieldDef, TemplateRegistry templateRegistry, ConversionContext context)
        {
            string name     = fieldDef.GetString("Name");
            string ns       = fieldDef.GetString("Ns");
            var    qname    = new QName(name, ns);
            var    fields   = GroupConverter.ParseFieldInstructions(fieldDef, templateRegistry, context);
            bool   optional = fieldDef.GetBool("Optional");
            Scalar length   = null;

            if (fieldDef.IsDefined("Length"))
            {
                var    lengthDef = fieldDef.GetGroup("Length");
                QName  lengthName;
                string id = null;
                if (lengthDef.IsDefined("Name"))
                {
                    var nameDef = lengthDef.GetGroup("Name");
                    lengthName = new QName(nameDef.GetString("Name"), nameDef.GetString("Ns"));
                    if (nameDef.IsDefined("AuxId"))
                    {
                        id = nameDef.GetString("AuxId");
                    }
                }
                else
                {
                    lengthName = Global.CreateImplicitName(qname);
                }
                var operator_Renamed = Operator.NONE;
                if (lengthDef.IsDefined("Operator"))
                {
                    operator_Renamed = GetOperator(lengthDef.GetGroup("Operator").GetGroup(0).GetGroup());
                }
                var initialValue = ScalarValue.UNDEFINED;
                if (lengthDef.IsDefined("InitialValue"))
                {
                    initialValue = (ScalarValue)lengthDef.GetValue("InitialValue");
                }
                length = new Scalar(lengthName, Type.U32, operator_Renamed, initialValue, optional)
                {
                    Id = id
                };
            }

            return(new Sequence(qname, length, fields, optional));
        }
 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;
 }
        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);
        }
 private static GroupValue CreateComponent(Scalar component, string componentName)
 {
     var componentGroup = SessionControlProtocol_1_1.COMP_DECIMAL_INSTR.GetGroup(componentName);
     var componentDef = new GroupValue(componentGroup);
     var componentOperatorDef = CreateOperator(component);
     var componentOperatorGroup = new GroupValue(componentGroup.GetGroup("Operator"));
     componentDef.SetFieldValue("Operator", componentOperatorGroup);
     componentOperatorGroup.SetFieldValue(0, componentOperatorDef);
     if (!component.DefaultValue.Undefined)
         componentDef.SetInteger("InitialValue", component.DefaultValue.ToInt());
     return componentDef;
 }
Example #8
0
 public static ComposedScalar ComposedDecimal(QName name, Operator exponentOp, ScalarValue exponentVal, Operator mantissaOp, ScalarValue mantissaVal, bool optional)
 {
     var exponentScalar = new Scalar(Global.CreateImplicitName(name), Type.I32, exponentOp, exponentVal, optional);
     var mantissaScalar = new Scalar(Global.CreateImplicitName(name), Type.I64, mantissaOp, mantissaVal, false);
     return new ComposedScalar(name, Type.DECIMAL, new[]{exponentScalar, mantissaScalar}, optional, new DecimalConverter());
 }
        public override Field Convert(GroupValue fieldDef, TemplateRegistry templateRegistry, ConversionContext context)
        {
            string name = fieldDef.GetString("Name");
            string ns = fieldDef.GetString("Ns");
            var qname = new QName(name, ns);
            var fields = GroupConverter.ParseFieldInstructions(fieldDef, templateRegistry, context);
            bool optional = fieldDef.GetBool("Optional");
            Scalar length = null;
            if (fieldDef.IsDefined("Length"))
            {
                var lengthDef = fieldDef.GetGroup("Length");
                QName lengthName;
                string id = null;
                if (lengthDef.IsDefined("Name"))
                {
                    var nameDef = lengthDef.GetGroup("Name");
                    lengthName = new QName(nameDef.GetString("Name"), nameDef.GetString("Ns"));
                    if (nameDef.IsDefined("AuxId"))
                        id = nameDef.GetString("AuxId");
                }
                else
                    lengthName = Global.CreateImplicitName(qname);
                var operator_Renamed = Operator.NONE;
                if (lengthDef.IsDefined("Operator"))
                    operator_Renamed = GetOperator(lengthDef.GetGroup("Operator").GetGroup(0).GetGroup());
                var initialValue = ScalarValue.UNDEFINED;
                if (lengthDef.IsDefined("InitialValue"))
                    initialValue = (ScalarValue) lengthDef.GetValue("InitialValue");
                length = new Scalar(lengthName, Type.U32, operator_Renamed, initialValue, optional) {Id = id};
            }

            return new Sequence(qname, length, fields, optional);
        }
        public override Field Convert(GroupValue fieldDef, TemplateRegistry templateRegistry, ConversionContext context)
        {
            var type = (Type) TEMPLATE_TYPE_MAP[fieldDef.GetGroup()];
            bool optional = fieldDef.GetBool("Optional");
            var initialValue = ScalarValue.UNDEFINED;
            if (fieldDef.IsDefined("InitialValue"))
                initialValue = (ScalarValue) fieldDef.GetValue("InitialValue");

            if (fieldDef.IsDefined("Operator"))
            {
                GroupValue operatorGroup = fieldDef.GetGroup("Operator").GetGroup(0);
                Operator operator_Renamed = GetOperator(operatorGroup.GetGroup());
                var scalar = new Scalar(fieldDef.GetString("Name"), type, operator_Renamed, initialValue, optional);
                if (operatorGroup.IsDefined("Dictionary"))
                    scalar.Dictionary = operatorGroup.GetString("Dictionary");
                if (operatorGroup.IsDefined("Key"))
                {
                    string name = operatorGroup.GetGroup("Key").GetString("Name");
                    string ns = operatorGroup.GetGroup("Key").GetString("Ns");
                    scalar.Key = new QName(name, ns);
                }
                return scalar;
            }
            return new Scalar(fieldDef.GetString("Name"), type, Operator.NONE, initialValue, optional);
        }