//// /// Copyright (c) 2016 Saúl Piña . /// /// This file is part of xmlrpcwsc. /// /// xmlrpcwsc is free software: you can redistribute it and/or modify /// it under the terms of the GNU Lesser General Public License as published by /// the Free Software Foundation, either version 3 of the License, or /// (at your option) any later version. /// /// xmlrpcwsc is distributed in the hope that it will be useful, /// but WITHOUT ANY WARRANTY; without even the implied warranty of /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /// GNU Lesser General Public License for more details. /// /// You should have received a copy of the GNU Lesser General Public License /// along with xmlrpcwsc. If not, see . //// using System; using System.Collections.Generic; namespace XmlRpc { /// /// XML-RPC request /// public class XmlRpcRequest { /// /// Gets or sets the name of the method /// /// The name of the method public string MethodName { get; set; } /// /// Gets or sets the parameters /// /// The parameters private List Params { get; set; } /// /// Initializes a new instance of the class /// public XmlRpcRequest() { this.MethodName = ""; this.Params = new List(); } /// /// Initializes a new instance of the class /// /// Method name public XmlRpcRequest(string methodName) { this.MethodName = methodName ?? ""; this.Params = new List(); } /// /// Initializes a new instance of the class /// /// Method name /// Parameters public XmlRpcRequest(string methodName, params object[] parameters) { this.MethodName = methodName ?? ""; this.Params = new List(); if (parameters != null) this.Params.AddRange(parameters); } /// /// Initializes a new instance of the class /// /// Method name /// Parameters. public XmlRpcRequest(string methodName, List parameters) { this.MethodName = methodName ?? ""; this.Params = parameters ?? new List(); } /// /// Adds the parameter, if param is DateTime uses DateTime.UtcNow, for dateTime.iso8601 conversion /// /// Parameter public void AddParam(object param) { Params.Add(param); } /// /// Adds the parameters /// /// Parameters public void AddParams(params object[] list) { Params.AddRange(list); } /// /// Adds the parameter array /// /// List public void AddParamArray(params object[] list) { AddParam(XmlRpcParameter.AsArray(list)); } /// /// Adds the parameter struct /// /// List public void AddParamStruct(params KeyValuePair[] list) { AddParam(XmlRpcParameter.AsStruct(list)); } /// /// Removes the parameter /// /// The parameter /// Parameter public void RemoveParam(object param) { Params.Remove(param); } /// /// Removes the parameter /// /// The parameter /// Position public object RemoveParam(int pos) { object operation = Params[pos]; RemoveParam(operation); return operation; } /// /// Gets the parameter /// /// The parameter /// Position public object GetParam(int pos) { return Params[pos]; } /// /// Gets the parameters /// /// The parameters public List GetParams() { List temp = new List(); temp.AddRange(Params); return temp; } /// /// Gets the parameters count /// /// The parameters count public int GetParamsCount() { return Params.Count; } /// /// Clear this instance /// public void Clear() { Params.Clear(); } } }