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)
        {
            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);
        }