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));
        }
        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, 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;
 }
Example #4
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);
        }
Example #5
0
        public override Field Convert(GroupValue fieldDef, TemplateRegistry templateRegistry, ConversionContext context)
        {
            string name = fieldDef.GetString("Name");

            Field[] fields   = ParseFieldInstructions(fieldDef, templateRegistry, context);
            bool    optional = fieldDef.GetBool("Optional");

            return(new Group(name, fields, optional));
        }
        public override Field Convert(GroupValue fieldDef, ITemplateRegistry templateRegistry, ConversionContext context)
        {
            string name = fieldDef.GetString("Name");
            string ns = fieldDef.GetString("Ns");
            var qname = new QName(name, ns);
            Field[] fields = GroupConverter.ParseFieldInstructions(fieldDef, templateRegistry, context);
            bool optional = fieldDef.GetBool("Optional");
            Scalar length = null;
            IFieldValue retLength;
            if (fieldDef.TryGetValue("Length", out retLength) && retLength!=null)
            {
                GroupValue lengthDef = (GroupValue)retLength;
                QName lengthName;
                string id = null;
                IFieldValue retName;
                if (lengthDef.TryGetValue("Name", out retName) && retName != null)
                {
                    GroupValue nameDef = (GroupValue)retName;
                    lengthName = new QName(nameDef.GetString("Name"), nameDef.GetString("Ns"));
                    IFieldValue retAuxId;
                    if (nameDef.TryGetValue("AuxId", out retAuxId) && retAuxId != null)
                        id = retAuxId.ToString();
                }
                else
                    lengthName = Global.CreateImplicitName(qname);
                Operator op = Operator.None;
                IFieldValue retOperator;
                if (lengthDef.TryGetValue("Operator", out retOperator) && retOperator != null)
                    op = GetOperator(((GroupValue)retOperator).GetGroup(0).Group);
                ScalarValue initialValue = ScalarValue.Undefined;
                IFieldValue retInitialValue;
                if (lengthDef.TryGetValue("InitialValue", out retInitialValue) && retInitialValue != null)
                    initialValue = (ScalarValue) retInitialValue;
                length = new Scalar(lengthName, FastType.U32, op, initialValue, optional) {Id = id};
            }

            var sequence = new Sequence(qname, length, fields, optional);
            IFieldValue retTypeRef;
            if (fieldDef.TryGetValue("TypeRef", out retTypeRef) && retTypeRef != null)
            {
                GroupValue typeRef = (GroupValue)retTypeRef;
                string typeRefName = typeRef.GetString("Name");
                string typeRefNs = ""; // context.getNamespace();
                IFieldValue rettypeRefNs;
                if (typeRef.TryGetValue("Ns", out rettypeRefNs) && rettypeRefNs!=null)
                    typeRefNs = rettypeRefNs.ToString();
                sequence.TypeReference = new QName(typeRefName, typeRefNs);
            }
            return sequence;
        }
Example #7
0
        public override Field Convert(GroupValue fieldDef, ITemplateRegistry templateRegistry, ConversionContext context)
        {
            FastType    type     = _templateTypeMap[fieldDef.Group];
            bool        optional = fieldDef.GetBool("Optional");
            IFieldValue retInitialValue;
            ScalarValue initialValue = fieldDef.TryGetValue("InitialValue", out retInitialValue) && retInitialValue != null
                                           ? (ScalarValue)retInitialValue
                                           : ScalarValue.Undefined;

            string      name = fieldDef.GetString("Name");
            IFieldValue rettempNs;
            string      tempNs = fieldDef.TryGetValue("Ns", out rettempNs) && rettempNs != null?rettempNs.ToString() : "";

            var qname = new QName(name, tempNs);

            Scalar      scalar;
            IFieldValue retOperator;

            if (fieldDef.TryGetValue("Operator", out retOperator) && retOperator != null)
            {
                GroupValue operatorGroup = ((GroupValue)retOperator).GetGroup(0);
                Operator   operatortemp  = GetOperator(operatorGroup.Group);
                scalar = new Scalar(qname, type, operatortemp, initialValue, optional);
                IFieldValue retDictionary;
                if (operatorGroup.TryGetValue("Dictionary", out retDictionary) && retDictionary != null)
                {
                    scalar.Dictionary = retDictionary.ToString();
                }
                IFieldValue retKey;
                if (operatorGroup.TryGetValue("Key", out retKey) && retKey != null)
                {
                    GroupValue retOperatorGroup = (GroupValue)retKey;
                    string     keyName          = retOperatorGroup.GetString("Name");
                    string     ns = retOperatorGroup.GetString("Ns");
                    scalar.Key = new QName(keyName, ns);
                }
            }
            else
            {
                scalar = new Scalar(qname, type, Operator.None, initialValue, optional);
            }
            IFieldValue retAuxId;

            if (fieldDef.TryGetValue("AuxId", out retAuxId) && retAuxId != null)
            {
                scalar.Id = retAuxId.ToString();
            }
            return(scalar);
        }
Example #8
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 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);
 }
        public override Field Convert(GroupValue fieldDef, ITemplateRegistry templateRegistry, ConversionContext context)
        {
            FastType type = _templateTypeMap[fieldDef.Group];
            bool optional = fieldDef.GetBool("Optional");
            IFieldValue retInitialValue;
            ScalarValue initialValue = fieldDef.TryGetValue("InitialValue",out retInitialValue) && retInitialValue!=null
                                           ? (ScalarValue)retInitialValue
                                           : ScalarValue.Undefined;

            string name = fieldDef.GetString("Name");
            IFieldValue rettempNs;
            string tempNs = fieldDef.TryGetValue("Ns", out rettempNs) && rettempNs != null ? rettempNs.ToString() : "";
            var qname = new QName(name, tempNs);

            Scalar scalar;
            IFieldValue retOperator;
            if (fieldDef.TryGetValue("Operator", out retOperator) && retOperator!=null)
            {
                GroupValue operatorGroup = ((GroupValue)retOperator).GetGroup(0);
                Operator operatortemp = GetOperator(operatorGroup.Group);
                scalar = new Scalar(qname, type, operatortemp, initialValue, optional);
                IFieldValue retDictionary;
                if (operatorGroup.TryGetValue("Dictionary", out retDictionary) && retDictionary != null)
                    scalar.Dictionary = retDictionary.ToString();
                IFieldValue retKey;
                if (operatorGroup.TryGetValue("Key", out retKey) && retKey != null)
                {
                    GroupValue retOperatorGroup = (GroupValue) retKey;
                    string keyName = retOperatorGroup.GetString("Name");
                    string ns = retOperatorGroup.GetString("Ns");
                    scalar.Key = new QName(keyName, ns);
                }
            }
            else
            {
                scalar = new Scalar(qname, type, Operator.None, initialValue, optional);
            }
            IFieldValue retAuxId;
            if (fieldDef.TryGetValue("AuxId", out retAuxId) && retAuxId!=null)
            {
                scalar.Id = retAuxId.ToString();
            }
            return scalar;
        }
Example #11
0
        public override Field Convert(GroupValue fieldDef, ITemplateRegistry templateRegistry, ConversionContext context)
        {
            string      name          = fieldDef.GetString("Name");
            string      namespacetemp = "";
            IFieldValue retns;

            if (fieldDef.TryGetValue("Ns", out retns) && retns != null)
            {
                namespacetemp = retns.ToString();
            }

            Field[] fields   = ParseFieldInstructions(fieldDef, templateRegistry, context);
            bool    optional = fieldDef.GetBool("Optional");
            var     group    = new Group(new QName(name, namespacetemp), fields, optional);

            IFieldValue retTypeRef;

            if (fieldDef.TryGetValue("TypeRef", out retTypeRef) && retTypeRef != null)
            {
                var         typeRef     = (GroupValue)retTypeRef;
                String      typeRefName = typeRef.GetString("Name");
                String      typeRefNs   = ""; // context.getNamespace();
                IFieldValue retNsTypeRef;
                if (typeRef.TryGetValue("Ns", out retNsTypeRef) && retNsTypeRef != null)
                {
                    typeRefNs = retNsTypeRef.ToString();
                }
                group.TypeReference = new QName(typeRefName, typeRefNs);
            }

            IFieldValue retAuxId;

            if (fieldDef.TryGetValue("AuxId", out retAuxId) && retAuxId != null)
            {
                group.Id = retAuxId.ToString();
            }

            return(group);
        }
        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));
        }
Example #13
0
        public override Field Convert(GroupValue fieldDef, ITemplateRegistry templateRegistry, ConversionContext context)
        {
            string name  = fieldDef.GetString("Name");
            string ns    = fieldDef.GetString("Ns");
            var    qname = new QName(name, ns);

            Field[]     fields   = GroupConverter.ParseFieldInstructions(fieldDef, templateRegistry, context);
            bool        optional = fieldDef.GetBool("Optional");
            Scalar      length   = null;
            IFieldValue retLength;

            if (fieldDef.TryGetValue("Length", out retLength) && retLength != null)
            {
                GroupValue  lengthDef = (GroupValue)retLength;
                QName       lengthName;
                string      id = null;
                IFieldValue retName;
                if (lengthDef.TryGetValue("Name", out retName) && retName != null)
                {
                    GroupValue nameDef = (GroupValue)retName;
                    lengthName = new QName(nameDef.GetString("Name"), nameDef.GetString("Ns"));
                    IFieldValue retAuxId;
                    if (nameDef.TryGetValue("AuxId", out retAuxId) && retAuxId != null)
                    {
                        id = retAuxId.ToString();
                    }
                }
                else
                {
                    lengthName = Global.CreateImplicitName(qname);
                }
                Operator    op = Operator.None;
                IFieldValue retOperator;
                if (lengthDef.TryGetValue("Operator", out retOperator) && retOperator != null)
                {
                    op = GetOperator(((GroupValue)retOperator).GetGroup(0).Group);
                }
                ScalarValue initialValue = ScalarValue.Undefined;
                IFieldValue retInitialValue;
                if (lengthDef.TryGetValue("InitialValue", out retInitialValue) && retInitialValue != null)
                {
                    initialValue = (ScalarValue)retInitialValue;
                }
                length = new Scalar(lengthName, FastType.U32, op, initialValue, optional)
                {
                    Id = id
                };
            }

            var         sequence = new Sequence(qname, length, fields, optional);
            IFieldValue retTypeRef;

            if (fieldDef.TryGetValue("TypeRef", out retTypeRef) && retTypeRef != null)
            {
                GroupValue  typeRef     = (GroupValue)retTypeRef;
                string      typeRefName = typeRef.GetString("Name");
                string      typeRefNs   = ""; // context.getNamespace();
                IFieldValue rettypeRefNs;
                if (typeRef.TryGetValue("Ns", out rettypeRefNs) && rettypeRefNs != null)
                {
                    typeRefNs = rettypeRefNs.ToString();
                }
                sequence.TypeReference = new QName(typeRefName, typeRefNs);
            }
            return(sequence);
        }
        public override Field Convert(GroupValue fieldDef, ITemplateRegistry templateRegistry, ConversionContext context)
        {
            string name = fieldDef.GetString("Name");
            string namespacetemp = "";
            IFieldValue retns;

            if (fieldDef.TryGetValue("Ns", out retns) && retns != null)
                namespacetemp = retns.ToString();

            Field[] fields = ParseFieldInstructions(fieldDef, templateRegistry, context);
            bool optional = fieldDef.GetBool("Optional");
            var group = new Group(new QName(name, namespacetemp), fields, optional);

            IFieldValue retTypeRef;
            if (fieldDef.TryGetValue("TypeRef", out retTypeRef) && retTypeRef != null)
            {
                var typeRef = (GroupValue) retTypeRef;
                String typeRefName = typeRef.GetString("Name");
                String typeRefNs = ""; // context.getNamespace();
                IFieldValue retNsTypeRef;
                if (typeRef.TryGetValue("Ns", out retNsTypeRef) && retNsTypeRef != null)
                    typeRefNs = retNsTypeRef.ToString();
                group.TypeReference = new QName(typeRefName, typeRefNs);
            }

            IFieldValue retAuxId;
            if (fieldDef.TryGetValue("AuxId", out retAuxId) && retAuxId != null)
                group.Id = retAuxId.ToString();

            return group;
        }
        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);
        }
 public override Field Convert(GroupValue fieldDef, TemplateRegistry templateRegistry, ConversionContext context)
 {
     string name = fieldDef.GetString("Name");
     Field[] fields = ParseFieldInstructions(fieldDef, templateRegistry, context);
     bool optional = fieldDef.GetBool("Optional");
     return new Group(name, fields, optional);
 }