Пример #1
0
        public MethodCall(ResponseMessage response)
        {
            if (!response.IsCallback)
            {
                throw new InvalidOperationException("Response must be a callback.");
            }

            Handle = response.Header.Handle;

            // get method name
            var xmlCall = response.MessageXml.Elements(XmlRpcElementNames.MethodCall).First();

            Method = xmlCall.Elements(XmlRpcElementNames.MethodName).First().Value;

            // parse method parameters
            var xmlPars = xmlCall.Elements(XmlRpcElementNames.Params)
                          .First()
                          .Elements(XmlRpcElementNames.Param);

            Arguments = new XmlRpcBaseType[xmlPars.Count()];

            for (int i = 0; i < Arguments.Length; i++)
            {
                var xmlValue = xmlPars.ElementAt(i)
                               .Elements(XmlRpcElementNames.Value)
                               .First()
                               .Elements()
                               .First();

                Arguments[i] = XmlRpcTypes.ElementToInstance(xmlValue);
            }

            Call = new(Method, Arguments);
        }
Пример #2
0
 public MethodCall(string method, uint handle, XmlRpcBaseType[] args)
 {
     Method    = method;
     Arguments = args;
     Call      = new(method, args);
     Handle    = handle;
 }