Example #1
0
        /// <summary>
        /// Serializes MethodCall object into string
        /// </summary>
        /// <param name="methodCall">MethodCall object need to be serialized</param>
        /// <returns>serialized string</returns>
        public static string XmlRpcSerialize(MethodCall methodCall)
        {
            string data;

            using (MemoryStream ms = new MemoryStream())
            {
                XmlRpcSerialization serializer = new XmlRpcSerialization();
                serializer.WriteObject(ms, methodCall);

                ArraySegment <byte> buff;
                if (ms.TryGetBuffer(out buff))
                {
                    data = Encoding.UTF8.GetString(buff.ToArray());
                }
                else
                {
                    throw new InvalidOperationException();
                }
            }
            return(data);
        }