Exemple #1
0
        private string BuildArgumentXml(Argument argument, string?value, string commandParameter = "")
        {
            var state = StateVariables.FirstOrDefault(a => string.Equals(a.Name, argument.RelatedStateVariable, StringComparison.OrdinalIgnoreCase));

            if (state != null)
            {
                var sendValue = state.AllowedValues.FirstOrDefault(a => string.Equals(a, commandParameter, StringComparison.OrdinalIgnoreCase)) ??
                                (state.AllowedValues.Count > 0 ? state.AllowedValues[0] : value);

                return(string.Format(CultureInfo.InvariantCulture, "<{0} xmlns:dt=\"urn:schemas-microsoft-com:datatypes\" dt:dt=\"{1}\">{2}</{0}>", argument.Name, state.DataType, sendValue));
            }

            return(string.Format(CultureInfo.InvariantCulture, "<{0}>{1}</{0}>", argument.Name, value));
        }
        private string BuildArgumentXml(Argument argument, string value, string commandParameter = "")
        {
            var state = StateVariables.FirstOrDefault(a => a.Name == argument.RelatedStateVariable);

            if (state != null)
            {
                var sendValue = (state.AllowedValues.FirstOrDefault(a => a == commandParameter) ??
                                 state.AllowedValues.FirstOrDefault()) ??
                                value;

                return(string.Format("<{0} xmlns:dt=\"urn:schemas-microsoft-com:datatypes\" dt:dt=\"{1}\">{2}</{0}>", argument.Name, state.DataType ?? "string", sendValue));
            }

            return(string.Format("<{0}>{1}</{0}>", argument.Name, value));
        }