当前位置: 首页>>代码示例>>C#>>正文


C# XmlRpcSerializer.SerializeRequest方法代码示例

本文整理汇总了C#中CookComputing.XmlRpc.XmlRpcSerializer.SerializeRequest方法的典型用法代码示例。如果您正苦于以下问题:C# XmlRpcSerializer.SerializeRequest方法的具体用法?C# XmlRpcSerializer.SerializeRequest怎么用?C# XmlRpcSerializer.SerializeRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CookComputing.XmlRpc.XmlRpcSerializer的用法示例。


在下文中一共展示了XmlRpcSerializer.SerializeRequest方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SerializeObjectParams

    public void SerializeObjectParams()
    {
      Stream stm = new MemoryStream();
      XmlRpcRequest req = new XmlRpcRequest();
      req.args = new Object[] { new object[] { 1, "one" } };
      req.method = "Foo";
      req.mi = typeof(IFoo).GetMethod("Foo");
      XmlRpcSerializer ser = new XmlRpcSerializer();
      ser.SerializeRequest(stm, req);
      stm.Position = 0;
      TextReader tr = new StreamReader(stm);
      string reqstr = tr.ReadToEnd();
      Assert.AreEqual(
        @"<?xml version=""1.0""?>
<methodCall>
  <methodName>Foo</methodName>
  <params>
    <param>
      <value>
        <i4>1</i4>
      </value>
    </param>
    <param>
      <value>
        <string>one</string>
      </value>
    </param>
  </params>
</methodCall>", reqstr);
    }
开发者ID:sgh1986915,项目名称:vfos-scraper-c-,代码行数:30,代码来源:paramstest.cs

示例2: NoIndentation

    public void NoIndentation()
    {
      Stream stm = new MemoryStream();
      XmlRpcRequest req = new XmlRpcRequest();
      req.args = new Object[] { 1234567 };
      req.method = "Foo";
      XmlRpcSerializer ser = new XmlRpcSerializer();
      ser.UseIndentation = false;
      ser.SerializeRequest(stm, req);
      stm.Position = 0;
      TextReader tr = new StreamReader(stm);
      string reqstr = tr.ReadToEnd();

      Assert.AreEqual(
        "<?xml version=\"1.0\"?><methodCall><methodName>Foo</methodName>"+
        "<params><param><value><i4>1234567</i4></value></param></params>"+
        "</methodCall>", reqstr);
    }
开发者ID:PowerMeMobile,项目名称:xml-rpc,代码行数:18,代码来源:serializetest.cs

示例3: DefaultFormatting

    public void DefaultFormatting()
    {
      Stream stm = new MemoryStream();
      XmlRpcRequest req = new XmlRpcRequest();
      req.args = new Object[] { 1234567 };
      req.method = "Foo";
      XmlRpcSerializer ser = new XmlRpcSerializer();
      ser.SerializeRequest(stm, req);
      stm.Position = 0;
      TextReader tr = new StreamReader(stm);
      string reqstr = tr.ReadToEnd();

      Assert.AreEqual(
@"<?xml version=""1.0""?>
<methodCall>
  <methodName>Foo</methodName>
  <params>
    <param>
      <value>
        <i4>1234567</i4>
      </value>
    </param>
  </params>
</methodCall>", reqstr);
    }
开发者ID:PowerMeMobile,项目名称:xml-rpc,代码行数:25,代码来源:serializetest.cs

示例4: NullParameter

 public void NullParameter()
 {
   Stream stm = new MemoryStream();
   XmlRpcRequest req = new XmlRpcRequest();
   req.args = new Object[] { null };
   req.method = "Foo";
   XmlRpcSerializer ser = new XmlRpcSerializer();
   ser.SerializeRequest(stm, req);
 }
开发者ID:PowerMeMobile,项目名称:xml-rpc,代码行数:9,代码来源:serializetest.cs

示例5: RecursiveArrayMemberTest

    public void RecursiveArrayMemberTest()
    {
      Stream stm = new MemoryStream();
      XmlRpcRequest req = new XmlRpcRequest();
      var example = new RecursiveArrayMember
      {
        Level = "1",
        childExamples = new RecursiveArrayMember[]
        {
          new RecursiveArrayMember
          {
            Level = "1-1",
            childExamples = new RecursiveArrayMember[]
            {
              new RecursiveArrayMember
              {
                Level = "1-1-1",
                childExamples = new RecursiveArrayMember[]
                {
                }
              },
              new RecursiveArrayMember
              {
                Level = "1-1-2",
                childExamples = new RecursiveArrayMember[]
                {
                }
              }
            }
          },
          new RecursiveArrayMember
          {
            Level = "1-2",
            childExamples = new RecursiveArrayMember[]
            {
              new RecursiveArrayMember
              {
                Level = "1-2-1",
                childExamples = new RecursiveArrayMember[]
                {
                }
              },
              new RecursiveArrayMember
              {
                Level = "1-2-2",
                childExamples = new RecursiveArrayMember[]
                {
                }
              }
            }
          }
        }
      };
      req.args = new Object[] { example };
      req.method = "Foo";
      XmlRpcSerializer ser = new XmlRpcSerializer();
      ser.UseStringTag = false;
      ser.SerializeRequest(stm, req);
      stm.Position = 0;
      TextReader tr = new StreamReader(stm);
      string reqstr = tr.ReadToEnd();
      Assert.AreEqual(
@"<?xml version=""1.0""?>
<methodCall>
  <methodName>Foo</methodName>
  <params>
    <param>
      <value>
        <struct>
          <member>
            <name>Level</name>
            <value>1</value>
          </member>
          <member>
            <name>childExamples</name>
            <value>
              <array>
                <data>
                  <value>
                    <struct>
                      <member>
                        <name>Level</name>
                        <value>1-1</value>
                      </member>
                      <member>
                        <name>childExamples</name>
                        <value>
                          <array>
                            <data>
                              <value>
                                <struct>
                                  <member>
                                    <name>Level</name>
                                    <value>1-1-1</value>
                                  </member>
                                  <member>
                                    <name>childExamples</name>
                                    <value>
                                      <array>
                                        <data />
//.........这里部分代码省略.........
开发者ID:PowerMeMobile,项目名称:xml-rpc,代码行数:101,代码来源:serializetest.cs

示例6: NonSerializedClass

    public void NonSerializedClass()
    {
      Stream stm = new MemoryStream();
      XmlRpcRequest req = new XmlRpcRequest();
      req.args = new Object[] { new Class4() };
      req.method = "Foo";
      XmlRpcSerializer ser = new XmlRpcSerializer();
      ser.SerializeRequest(stm, req);
      stm.Position = 0;
      TextReader tr = new StreamReader(stm);
      string reqstr = tr.ReadToEnd();
      Assert.AreEqual(
@"<?xml version=""1.0""?>
<methodCall>
  <methodName>Foo</methodName>
  <params>
    <param>
      <value>
        <struct>
          <member>
            <name>y</name>
            <value>
              <i4>0</i4>
            </value>
          </member>
        </struct>
      </value>
    </param>
  </params>
</methodCall>", reqstr);
    }
开发者ID:PowerMeMobile,项目名称:xml-rpc,代码行数:31,代码来源:serializetest.cs

示例7: SerializeIntNoParams

 public void SerializeIntNoParams()
 {
     Stream stm = new MemoryStream();
       XmlRpcRequest req = new XmlRpcRequest();
       req.args = new object[] { new int[] { 1, 2, 3 } };
       req.method = "BarNotParams";
       req.mi = typeof(IFoo).GetMethod("BarNotParams");
       XmlRpcSerializer ser = new XmlRpcSerializer();
       ser.SerializeRequest(stm, req);
       stm.Position = 0;
       TextReader tr = new StreamReader(stm);
       string reqstr = tr.ReadToEnd();
       Assert.AreEqual(
     @"<?xml version=""1.0""?>
     <methodCall>
       <methodName>BarNotParams</methodName>
       <params>
     <param>
       <value>
     <array>
       <data>
     <value>
       <i4>1</i4>
     </value>
     <value>
       <i4>2</i4>
     </value>
     <value>
       <i4>3</i4>
     </value>
       </data>
     </array>
       </value>
     </param>
       </params>
     </methodCall>", reqstr);
 }
开发者ID:bricel,项目名称:DrutNet,代码行数:37,代码来源:paramstest.cs

示例8: Invoke

    public object Invoke(
      Object clientObj,
      MethodInfo mi,
      params object[] parameters)
    {
#if (!COMPACT_FRAMEWORK && !SILVERLIGHT)
      _responseHeaders = null;
      _responseCookies = null;
#endif
      WebRequest webReq = null;
      object reto = null;
      try
      {
        string useUrl = GetEffectiveUrl(clientObj);
        webReq = GetWebRequest(new Uri(useUrl));
        XmlRpcRequest req = MakeXmlRpcRequest(webReq, mi, parameters,
          clientObj, _xmlRpcMethod, _id);
        SetProperties(webReq);
#if (!SILVERLIGHT)
        SetRequestHeaders(_headers, webReq);
#endif
#if (!COMPACT_FRAMEWORK && !SILVERLIGHT)
        SetClientCertificates(_clientCertificates, webReq);
#endif
        Stream serStream = null;
        Stream reqStream = null;
        bool logging = (RequestEvent != null);
        if (!logging)
          serStream = reqStream = webReq.GetRequestStream();
        else
          serStream = new MemoryStream(2000);
        try
        {
          XmlRpcSerializer serializer = new XmlRpcSerializer();
          if (_xmlEncoding != null)
            serializer.XmlEncoding = _xmlEncoding;
          serializer.UseIndentation = _useIndentation;
          serializer.Indentation = _indentation;
          serializer.NonStandard = _nonStandard;
          serializer.UseStringTag = _useStringTag;
          serializer.UseIntTag = _useIntTag;
          serializer.UseEmptyParamsTag = _useEmptyParamsTag;
          serializer.SerializeRequest(serStream, req);
          if (logging)
          {
            reqStream = webReq.GetRequestStream();
            serStream.Position = 0;
            Util.CopyStream(serStream, reqStream);
            reqStream.Flush();
            serStream.Position = 0;
            OnRequest(new XmlRpcRequestEventArgs(req.proxyId, req.number,
              serStream));
          }
        }
        finally
        {
          if (reqStream != null)
            reqStream.Close();
        }
        HttpWebResponse webResp = GetWebResponse(webReq) as HttpWebResponse;
#if (!COMPACT_FRAMEWORK && !SILVERLIGHT)
        _responseCookies = webResp.Cookies;
#endif
#if (!COMPACT_FRAMEWORK && !SILVERLIGHT)
        _responseHeaders = webResp.Headers;
#endif
        Stream respStm = null;
        Stream deserStream;
        logging = (ResponseEvent != null);
        try
        {
          respStm = webResp.GetResponseStream();
          if (!logging)
          {
            deserStream = respStm;
          }
          else
          {
            deserStream = new MemoryStream(2000);
            Util.CopyStream(respStm, deserStream);
            deserStream.Flush();
            deserStream.Position = 0;
          }
#if (!COMPACT_FRAMEWORK && !SILVERLIGHT)
          deserStream = MaybeDecompressStream((HttpWebResponse)webResp, 
            deserStream);          
#endif
          try
          {
            XmlRpcResponse resp = ReadResponse(req, webResp, deserStream, null);
            reto = resp.retVal;
          }
          finally
          {
            if (logging)
            {
              deserStream.Position = 0;
              OnResponse(new XmlRpcResponseEventArgs(req.proxyId, req.number,
                deserStream));
            }
//.........这里部分代码省略.........
开发者ID:adzerk,项目名称:OpenX.Net,代码行数:101,代码来源:XmlRpcClientProtocol.cs

示例9: StructParamsTooManyParams

 public void StructParamsTooManyParams()
 {
   Stream stm = new MemoryStream();
   XmlRpcRequest req = new XmlRpcRequest();
   req.args = new Object[] { 1234, "test", 10.1, "lopol" };
   req.method = "Foo";
   req.mi = this.GetType().GetMethod("Foo");
   XmlRpcSerializer ser = new XmlRpcSerializer();
   ser.Indentation = 2;
   ser.UseIntTag = true;
   ser.SerializeRequest(stm, req);
 }
开发者ID:PowerMeMobile,项目名称:xml-rpc,代码行数:12,代码来源:serializetest.cs

示例10: StructParams

    public void StructParams()
    {
      Stream stm = new MemoryStream();
      XmlRpcRequest req = new XmlRpcRequest();
      req.args = new Object[] { 1234, "test", 10.1 };
      req.method = "Foo";
      req.mi = this.GetType().GetMethod("Foo");
      XmlRpcSerializer ser = new XmlRpcSerializer();
      ser.Indentation = 2;
      ser.UseIntTag = true;
      ser.SerializeRequest(stm, req);
      stm.Position = 0;
      TextReader tr = new StreamReader(stm);
      string reqstr = tr.ReadToEnd();

      Assert.AreEqual(
        @"<?xml version=""1.0""?>
<methodCall>
  <methodName>Foo</methodName>
  <params>
    <param>
      <value>
        <struct>
          <member>
            <name>x</name>
            <value>
              <int>1234</int>
            </value>
          </member>
          <member>
            <name>y</name>
            <value>
              <string>test</string>
            </value>
          </member>
          <member>
            <name>z</name>
            <value>
              <double>10.1</double>
            </value>
          </member>
        </struct>
      </value>
    </param>
  </params>
</methodCall>", reqstr);
    }
开发者ID:PowerMeMobile,项目名称:xml-rpc,代码行数:47,代码来源:serializetest.cs

示例11: UseInt

    public void UseInt()
    {
      Stream stm = new MemoryStream();
      XmlRpcRequest req = new XmlRpcRequest();
      req.args = new Object[] { 1234 };
      req.method = "Foo";
      XmlRpcSerializer ser = new XmlRpcSerializer();
      ser.Indentation = 4;
      ser.UseIntTag = true;
      ser.SerializeRequest(stm, req);
      stm.Position = 0;
      TextReader tr = new StreamReader(stm);
      string reqstr = tr.ReadToEnd();

      Assert.AreEqual(
        @"<?xml version=""1.0""?>
<methodCall>
    <methodName>Foo</methodName>
    <params>
        <param>
            <value>
                <int>1234</int>
            </value>
        </param>
    </params>
</methodCall>", reqstr);
    }
开发者ID:PowerMeMobile,项目名称:xml-rpc,代码行数:27,代码来源:serializetest.cs

示例12: StringDefaultTag

    public void StringDefaultTag()
    {
      Stream stm = new MemoryStream();
      XmlRpcRequest req = new XmlRpcRequest();
      req.args = new Object[] { "string default tag" };
      req.method = "Foo";
      XmlRpcSerializer ser = new XmlRpcSerializer();
      ser.Indentation = 4;
      ser.SerializeRequest(stm, req);
      stm.Position = 0;
      TextReader tr = new StreamReader(stm);
      string reqstr = tr.ReadToEnd();

      Assert.AreEqual(
        @"<?xml version=""1.0""?>
<methodCall>
    <methodName>Foo</methodName>
    <params>
        <param>
            <value>
                <string>string default tag</string>
            </value>
        </param>
    </params>
</methodCall>", reqstr);
    }
开发者ID:PowerMeMobile,项目名称:xml-rpc,代码行数:26,代码来源:serializetest.cs

示例13: DateTimeLocales

        public void DateTimeLocales()
        {
            CultureInfo oldci = Thread.CurrentThread.CurrentCulture;
              try
              {
            foreach (string locale in Utils.GetLocales())
            {
              try
              {
            CultureInfo ci = new CultureInfo(locale);
            Thread.CurrentThread.CurrentCulture = ci;
            if (ci.LCID == 0x401    // ar-SA  (Arabic - Saudi Arabia)
              || ci.LCID == 0x465   // div-MV (Dhivehi - Maldives)
              || ci.LCID == 0x41e)  // th-TH  (Thai - Thailand)
              break;

            DateTime dt = new DateTime(1900, 01, 02, 03, 04, 05);
            while (dt < DateTime.Now)
            {
              Stream stm = new MemoryStream();
              XmlRpcRequest req = new XmlRpcRequest();
              req.args = new Object[] { dt };
              req.method = "Foo";
              XmlRpcSerializer ser = new XmlRpcSerializer();
              ser.SerializeRequest(stm, req);
              stm.Position = 0;

              XmlRpcSerializer serializer = new XmlRpcSerializer();
              XmlRpcRequest request = serializer.DeserializeRequest(stm, null);

              Assert.IsTrue(request.args[0] is DateTime,
                "argument is DateTime");
              DateTime dt0 = (DateTime)request.args[0];
              Assert.AreEqual(dt0, dt, "DateTime argument 0");
              dt += new TimeSpan(100, 1, 1, 1);
            }
              }
              catch (Exception ex)
              {
              Assert.Fail(String.Format("unexpected exception {0}: {1}",
                locale, ex.Message));
              }
            }
              }
              finally
              {
            Thread.CurrentThread.CurrentCulture = oldci;
              }
        }
开发者ID:molotovbliss,项目名称:csharlibformagexmlrpcapi,代码行数:49,代码来源:deserializerequesttest.cs

示例14: SerializeZeroParametersNoParams

 public void SerializeZeroParametersNoParams()
 {
     Stream stm = new MemoryStream();
       XmlRpcRequest req = new XmlRpcRequest();
       req.args = new Object[0];
       req.method = "FooZeroParameters";
       req.mi = typeof(IFoo).GetMethod("FooZeroParameters");
       XmlRpcSerializer ser = new XmlRpcSerializer();
       ser.UseEmptyParamsTag = false;
       ser.SerializeRequest(stm, req);
       stm.Position = 0;
       TextReader tr = new StreamReader(stm);
       string reqstr = tr.ReadToEnd();
       Assert.AreEqual(
     @"<?xml version=""1.0""?>
     <methodCall>
       <methodName>FooZeroParameters</methodName>
     </methodCall>", reqstr);
 }
开发者ID:bricel,项目名称:DrutNet,代码行数:19,代码来源:paramstest.cs

示例15: SerializeMassimo

 public void SerializeMassimo()
 {
     object[] param1 = new object[] { "test/Gain1", "Gain", 1, 1,
                                new double[] { 0.5 } };
       object[] param2 = new object[] { "test/METER", "P1", 1, 1,
                                new double[] { -1.0 } };
       Stream stm = new MemoryStream();
       XmlRpcRequest req = new XmlRpcRequest();
       req.args = new Object[] { "IFTASK",
     new object[] { param1, param2 } };
       req.method = "Send_Param";
       req.mi = this.GetType().GetMethod("Send_Param");
       XmlRpcSerializer ser = new XmlRpcSerializer();
       ser.SerializeRequest(stm, req);
       stm.Position = 0;
       TextReader tr = new StreamReader(stm);
       string reqstr = tr.ReadToEnd();
       Assert.AreEqual(massimoRequest, reqstr);
 }
开发者ID:bricel,项目名称:DrutNet,代码行数:19,代码来源:paramstest.cs


注:本文中的CookComputing.XmlRpc.XmlRpcSerializer.SerializeRequest方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。