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


C# XmlRpc.XmlRpcSerializer类代码示例

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


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

示例1: AdvogatoProblem

 public void AdvogatoProblem()
 {
     string xml = @"<?xml version='1.0'?>
     <methodResponse>
     <params>
     <param>
     <array>
     <data>
     <value>
     <dateTime.iso8601>20020707T11:25:37</dateTime.iso8601>
     </value>
     <value>
     <dateTime.iso8601>20020707T11:37:12</dateTime.iso8601>
     </value>
     </data>
     </array>
     </param>
     </params>
     </methodResponse>";
       StringReader sr = new StringReader(xml);
       XmlRpcSerializer serializer = new XmlRpcSerializer();
       try
       {
     XmlRpcResponse response
       = serializer.DeserializeResponse(sr, null);
     Object o = response.retVal;
     Assert.Fail("should have thrown XmlRpcInvalidXmlRpcException");
       }
       catch(XmlRpcInvalidXmlRpcException)
       {
       }
 }
开发者ID:molotovbliss,项目名称:csharlibformagexmlrpcapi,代码行数:32,代码来源:Copy+of+deserializeresponsetest.cs

示例2: Serialize

 public static XmlDocument Serialize(
   string testName,
   object obj, 
   Encoding encoding,
   MappingAction action)
 {
   Stream stm = new MemoryStream();
   XmlTextWriter xtw = new XmlTextWriter(stm, Encoding.UTF8);
   xtw.Formatting = Formatting.Indented;
   xtw.Indentation = 2;
   xtw.WriteStartDocument();      
   XmlRpcSerializer ser = new XmlRpcSerializer();
   ser.Serialize(xtw, obj, action); 
   xtw.Flush();
   //Console.WriteLine(testName);
   stm.Position = 0;    
   TextReader trdr = new StreamReader(stm, new UTF8Encoding(), true, 4096);
   String s = trdr.ReadLine();
   while (s != null)
   {
     //Console.WriteLine(s);
     s = trdr.ReadLine();
   }            
   stm.Position = 0;    
   XmlDocument xdoc = new XmlDocument();
   xdoc.PreserveWhitespace = true;
   xdoc.Load(stm);
   return xdoc;
 }
开发者ID:sgh1986915,项目名称:vfos-scraper-c-,代码行数:29,代码来源:utils.cs

示例3: AllowInvalidHTTPContentLeadingWhiteSpace

        public void AllowInvalidHTTPContentLeadingWhiteSpace()
        {
            string xml = @"

            <?xml version=""1.0"" ?>
            <methodResponse>
              <params>
            <param>
              <value><i4>12345</i4></value>
            </param>
              </params>
            </methodResponse>";
              Stream stm = new MemoryStream();
              StreamWriter wrtr = new StreamWriter(stm, Encoding.ASCII);
              wrtr.Write(xml);
              wrtr.Flush();
              stm.Position = 0;
              XmlRpcSerializer serializer = new XmlRpcSerializer();
              serializer.NonStandard = XmlRpcNonStandard.AllowInvalidHTTPContent;
              XmlRpcResponse response = serializer.DeserializeResponse(stm, typeof(int));

              Object o = response.retVal;
              Assert.IsTrue(o != null, "retval not null");
              Assert.IsTrue(o is int, "retval is int");
              Assert.AreEqual((int)o, 12345, "retval is 12345");
        }
开发者ID:molotovbliss,项目名称:csharlibformagexmlrpcapi,代码行数:26,代码来源:Copy+of+deserializeresponsetest.cs

示例4: XmlRpcSerializer

            public XmlRpcSerializer()
            {
                Mapper.Initialize((config) =>
                {
                    config.CreateMap<PostStatus, string>().ConvertUsing(src => src.ToRPC());
                    config.CreateMap<PostOrderBy, string>().ConvertUsing(src => src.ToRPC());
                    config.CreateMap<Order, string>().ConvertUsing(src => src.ToRPC());
                    config.CreateMap<Rpc.PostFilter, PostFilterProxy>()
                        .ForMember(
                            dest => dest.PostStatus,
                            opt => opt.MapFrom(
                                source => new string[] { Mapper.Map<string>(source.PostStatus) }
                            )
                        );
                });

                var doc = new XmlDocument();
                doc.Load("SampleData/getpost.xml");

                var response = new CookComputing.XmlRpc.XmlRpcSerializer().DeserializeResponse(
                        doc,
                        typeof(Rpc.Post)
                    );

                this._subject = response.retVal as Rpc.Post;
                this._expected = this.ExpectedPost();
            }
开发者ID:caseygoodhew,项目名称:wordpress-xmlrpc-client,代码行数:27,代码来源:Post.cs

示例5: 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

示例6: PaoloLiveraniProblem

 public void PaoloLiveraniProblem()
 {
     try
       {
     XmlRpcResponse resp = new XmlRpcResponse(new DataSet());
     Stream responseStream = new MemoryStream();
     XmlRpcSerializer serializer = new XmlRpcSerializer();
     serializer.SerializeResponse(responseStream, resp);
       }
       catch(XmlRpcInvalidReturnType ex)
       {
     string s = ex.Message;
       }
 }
开发者ID:ayende,项目名称:Subtext,代码行数:14,代码来源:serializeresponsetest.cs

示例7: Invoke

    public Stream Invoke(Stream requestStream)
    {
      try
      {
        var serializer = new XmlRpcResponseSerializer();
        var deserializer = new XmlRpcRequestDeserializer();
        Type type = this.GetType();
        XmlRpcServiceAttribute serviceAttr = (XmlRpcServiceAttribute)
          Attribute.GetCustomAttribute(this.GetType(),
          typeof(XmlRpcServiceAttribute));

        if (serviceAttr != null)
        {
            if (serviceAttr.XmlEncoding != null)
            {
                serializer.XmlEncoding = Encoding.GetEncoding(serviceAttr.XmlEncoding) ?? Config.DefaultEncoding;
            }
            serializer.UseEmptyParamsTag = serviceAttr.UseEmptyElementTags;
            serializer.UseIntTag = serviceAttr.UseIntTag;
            serializer.UseStringTag = serviceAttr.UseStringTag;
            serializer.UseIndentation = serviceAttr.UseIndentation;
            serializer.Indentation = serviceAttr.Indentation;
        }

        XmlRpcRequest xmlRpcReq = deserializer.DeserializeRequest(requestStream, this.GetType());
        XmlRpcResponse xmlRpcResp = Invoke(xmlRpcReq);

        Stream responseStream = new MemoryStream();
        serializer.SerializeResponse(responseStream, xmlRpcResp);
        responseStream.Seek(0, SeekOrigin.Begin);
        return responseStream;
      }
      catch (Exception ex)
      {
        XmlRpcFaultException fex;
        if (ex is XmlRpcException)
          fex = new XmlRpcFaultException(0, ((XmlRpcException)ex).Message);
        else if (ex is XmlRpcFaultException)
          fex = (XmlRpcFaultException)ex;
        else 
          fex = new XmlRpcFaultException(0, ex.Message);
        XmlRpcSerializer serializer = new XmlRpcSerializer();
        Stream responseStream = new MemoryStream();
        serializer.SerializeFaultResponse(responseStream, fex);
        responseStream.Seek(0, SeekOrigin.Begin);
        return responseStream;      
      }
    }
开发者ID:AntonWong,项目名称:cms,代码行数:48,代码来源:XmlRpcServerProtocol.cs

示例8: Serialize

 public static XmlReader Serialize(
   string testName,
   object obj, 
   Encoding encoding,
   MappingActions actions)
 {
   Stream stm = new MemoryStream();
   XmlWriter xtw = XmlRpcXmlWriter.Create(stm, new XmlRpcFormatSettings());
   xtw.WriteStartDocument();      
   XmlRpcSerializer ser = new XmlRpcSerializer();
   ser.Serialize(xtw, obj, actions); 
   xtw.Flush();
   stm.Position = 0;    
   XmlReader rdr = XmlRpcXmlReader.Create(stm);
   return rdr;
 }
开发者ID:wbrussell,项目名称:xmlrpcnet,代码行数:16,代码来源:utils.cs

示例9: XmlRpcSerializer

            public XmlRpcSerializer()
            {
                var doc = new XmlDocument();
                doc.Load("SampleData/getAuthors.xml");

                var response = new CookComputing.XmlRpc.XmlRpcSerializer().DeserializeResponse(
                        doc,
                        typeof(Rpc.Author[])
                    );

                this._subject = response.retVal as IEnumerable<Rpc.Author>;

                //= new List<Author>();

                this._expected = this.ExpectedAuthors();
            }
开发者ID:caseygoodhew,项目名称:wordpress-xmlrpc-client,代码行数:16,代码来源:Authors.cs

示例10: SerializeToString

 public static string SerializeToString(
   string testName,
   object obj, 
   MappingAction action)
 {
   StringWriter strwrtr = new StringWriter();
   XmlTextWriter xtw = new XmlTextWriter(strwrtr);
   //      xtw.Formatting = formatting;
   //      xtw.Indentation = indentation;
   xtw.WriteStartDocument();      
   XmlRpcSerializer ser = new XmlRpcSerializer();
   ser.Serialize(xtw, obj, action); 
   xtw.Flush();
   //Console.WriteLine(testName);
   //Console.WriteLine(strwrtr.ToString());
   return strwrtr.ToString();
 }
开发者ID:sgh1986915,项目名称:vfos-scraper-c-,代码行数:17,代码来源:utils.cs

示例11: Invoke

        public Stream Invoke(Stream requestStream)
        {
            try
            {
                var serializer = new XmlRpcResponseSerializer();
                var deserializer = new XmlRpcRequestDeserializer();
                var serviceAttr = Attribute.GetCustomAttribute(GetType(), typeof(XmlRpcServiceAttribute)) as XmlRpcServiceAttribute;
                if (serviceAttr != null)
                {
                    if (serviceAttr.XmlEncoding != null)
                        serializer.XmlEncoding = Encoding.GetEncoding(serviceAttr.XmlEncoding);
                    serializer.UseEmptyParamsTag = serviceAttr.UseEmptyElementTags;
                    serializer.UseIntTag = serviceAttr.UseIntTag;
                    serializer.UseStringTag = serviceAttr.UseStringTag;
                    serializer.UseIndentation = serviceAttr.UseIndentation;
                    serializer.Indentation = serviceAttr.Indentation;
                }

                var xmlRpcReq = deserializer.DeserializeRequest(requestStream, GetType());
                var xmlRpcResp = Invoke(xmlRpcReq);
                var responseStream = new MemoryStream();
                serializer.SerializeResponse(responseStream, xmlRpcResp);
                responseStream.Seek(0, SeekOrigin.Begin);
                return responseStream;
            }
            catch (Exception ex)
            {
                XmlRpcFaultException fex;
                var xmlRpcException = ex as XmlRpcException;
                if (xmlRpcException != null)
                    fex = new XmlRpcFaultException(0, xmlRpcException.Message);
                else
                {
                    fex = (ex as XmlRpcFaultException)
                        ?? new XmlRpcFaultException(0, ex.Message);
                }

                var serializer = new XmlRpcSerializer();
                var responseStream = new MemoryStream();
                serializer.SerializeFaultResponse(responseStream, fex);
                responseStream.Seek(0, SeekOrigin.Begin);
                return responseStream;
            }
        }
开发者ID:magicmonty,项目名称:xmlrpcnet,代码行数:44,代码来源:XmlRpcServerProtocol.cs

示例12: IntegerNullType

    public void IntegerNullType()
    {
      string xml = @"<?xml version=""1.0"" ?> 
<methodResponse>
  <params>
    <param>
      <value><int>12345</int></value>
    </param>
  </params>
</methodResponse>";
      StringReader sr = new StringReader(xml);
      XmlRpcSerializer serializer = new XmlRpcSerializer();
      XmlRpcResponse response = serializer.DeserializeResponse(sr, null);

      Object o = response.retVal;
      Assert.IsTrue(o != null, "retval not null");
      Assert.IsTrue(o is int, "retval is int");
      Assert.AreEqual((int)o, 12345, "retval is 12345");
    }
开发者ID:sgh1986915,项目名称:vfos-scraper-c-,代码行数:19,代码来源:deserializeresponsetest.cs

示例13: WithXmlDocPropertyPresentShouldDeserializeProperly

            public void WithXmlDocPropertyPresentShouldDeserializeProperly()
            {
                // Arrange
                var xmlSerializer = new XmlRpcSerializer();
                const string reply = @"<?xml version='1.0'?>
                        <methodResponse><params><param>
                        <value><struct><member><name>XmlDoc</name><value>this is a string</value></member></struct></value>
                        </param></params></methodResponse>";
                var expected = new P2000ReturnStructure
                                    {
                                        XmlDoc = "this is a string"
                                    };

                // Act
                var actual = xmlSerializer.DeserializeStringResponse<P2000ReturnStructure>(reply);

                // Assert
                DtoAssert.AreEqual(expected, actual);

            }
开发者ID:shayaneumar,项目名称:gabbar,代码行数:20,代码来源:P2000ReturnStructureTest.cs

示例14: Base64Empty

        public void Base64Empty()
        {
            string xml = @"<?xml version=""1.0""?>
            <methodCall>
              <methodName>TestHex</methodName>
              <params>
            <param>
              <value>
            <base64></base64>
              </value>
            </param>
              </params>
            </methodCall>";
              StringReader sr = new StringReader(xml);
              XmlRpcSerializer serializer = new XmlRpcSerializer();
              XmlRpcRequest request = serializer.DeserializeRequest(sr, null);

              Assert.AreEqual(request.args[0].GetType(),  typeof(byte[]),
            "argument is byte[]");
              Assert.AreEqual(request.args[0], new byte[0],
            "argument is zero length byte[]");
        }
开发者ID:molotovbliss,项目名称:csharlibformagexmlrpcapi,代码行数:22,代码来源:deserializerequesttest.cs

示例15: Base64

        public void Base64()
        {
            string xml = @"<?xml version=""1.0""?>
            <methodCall>
              <methodName>TestHex</methodName>
              <params>
            <param>
              <value>
            <base64>AQIDBAUGBwg=</base64>
              </value>
            </param>
              </params>
            </methodCall>";
              StringReader sr = new StringReader(xml);
              XmlRpcSerializer serializer = new XmlRpcSerializer();
              XmlRpcRequest request = serializer.DeserializeRequest(sr, null);

              Assert.AreEqual(request.args[0].GetType(), typeof(byte[]),
            "argument is byte[]");
              byte[] ret = (byte[])request.args[0];
              Assert.AreEqual(8, ret.Length, "argument is byte[8]");
              for (int i = 0; i < ret.Length; i++)
            Assert.AreEqual(i+1, ret[i], "members are 1 to 8");
        }
开发者ID:molotovbliss,项目名称:csharlibformagexmlrpcapi,代码行数:24,代码来源:deserializerequesttest.cs


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