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); }
public override Field Convert(GroupValue fieldDef, TemplateRegistry templateRegistry, ConversionContext context) { var scalar = (Scalar) base.Convert(fieldDef, templateRegistry, context); if (fieldDef.IsDefined("Length")) { scalar.AddAttribute(Error.FastConstants.LENGTH_FIELD, fieldDef.GetGroup("Length").GetString("Name")); } return scalar; }
public override Field Convert(GroupValue fieldDef, TemplateRegistry templateRegistry, ConversionContext context) { var scalar = (Scalar)base.Convert(fieldDef, templateRegistry, context); if (fieldDef.IsDefined("Length")) { scalar.AddAttribute(Error.FastConstants.LENGTH_FIELD, fieldDef.GetGroup("Length").GetString("Name")); } return(scalar); }
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); }