Exemple #1
0
        private static void ProcessValue(Value val, XmlWriter xmlw, string type = "")
        {
            xmlw.WriteStartElement(type + "Value");
            ConstantValue               cvc  = val as ConstantValue;
            ExpressionValue             ev   = val as ExpressionValue;
            ParameterFieldDiscreteValue pfdv = val as ParameterFieldDiscreteValue;
            ParameterFieldRangeValue    pfrv = val as ParameterFieldRangeValue;
            ParameterFieldValue         pfv  = val as ParameterFieldValue;

            if (cvc != null)
            {
                xmlw.WriteAttributeString("Value", cvc.Value.ToStringSafe());
            }
            else if (ev != null)
            {
                xmlw.WriteAttributeString("Expression", ev.Expression);
            }
            else if (pfdv != null)
            {
                xmlw.WriteAttributeString("Description", pfdv.Description);
                xmlw.WriteAttributeString("Value", Convert.ToString(pfdv.Value));
            }
            else if (pfrv != null)
            {
                xmlw.WriteAttributeString("BeginValue", Convert.ToString(pfrv.BeginValue));
                xmlw.WriteAttributeString("Description", pfrv.Description);
                xmlw.WriteAttributeString("EndValue", Convert.ToString(pfrv.EndValue));
                xmlw.WriteAttributeString("LowerBoundType", Convert.ToString(pfrv.LowerBoundType));
                xmlw.WriteAttributeString("UpperBoundType", Convert.ToString(pfrv.UpperBoundType));
            }
            else if (pfv != null)
            {
                xmlw.WriteAttributeString("Description", pfv.Description);
            }
            xmlw.WriteEndElement();
        }
Exemple #2
0
        private static void ProcessValue(Value val, Utf8JsonWriter jsonw, string type = "")
        {
            jsonw.WriteStartObject();
            ConstantValue               cvc  = val as ConstantValue;
            ExpressionValue             ev   = val as ExpressionValue;
            ParameterFieldDiscreteValue pfdv = val as ParameterFieldDiscreteValue;
            ParameterFieldRangeValue    pfrv = val as ParameterFieldRangeValue;
            ParameterFieldValue         pfv  = val as ParameterFieldValue;

            if (cvc != null)
            {
                jsonw.WriteString("Value", cvc.Value.ToStringSafe());
            }
            else if (ev != null)
            {
                jsonw.WriteString("Expression", ev.Expression);
            }
            else if (pfdv != null)
            {
                jsonw.WriteString("Description", pfdv.Description);
                jsonw.WriteString("Value", Convert.ToString(pfdv.Value));
            }
            else if (pfrv != null)
            {
                jsonw.WriteString("BeginValue", Convert.ToString(pfrv.BeginValue));
                jsonw.WriteString("Description", pfrv.Description);
                jsonw.WriteString("EndValue", Convert.ToString(pfrv.EndValue));
                jsonw.WriteString("LowerBoundType", Convert.ToString(pfrv.LowerBoundType));
                jsonw.WriteString("UpperBoundType", Convert.ToString(pfrv.UpperBoundType));
            }
            else if (pfv != null)
            {
                jsonw.WriteString("Description", pfv.Description);
            }
            jsonw.WriteEndObject();
        }