aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Common/XmlRpcCS/XmlRpcClientProxy.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--Common/XmlRpcCS/XmlRpcClientProxy.cs88
1 files changed, 0 insertions, 88 deletions
diff --git a/Common/XmlRpcCS/XmlRpcClientProxy.cs b/Common/XmlRpcCS/XmlRpcClientProxy.cs
deleted file mode 100644
index e9af1ac..0000000
--- a/Common/XmlRpcCS/XmlRpcClientProxy.cs
+++ /dev/null
@@ -1,88 +0,0 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28namespace Nwc.XmlRpc
29{
30 using System;
31 using System.Runtime.Remoting.Proxies;
32 using System.Runtime.Remoting.Messaging;
33
34 /// <summary>This class provides support for creating local proxies of XML-RPC remote objects</summary>
35 /// <remarks>
36 /// To create a local proxy you need to create a local C# interface and then, via <i>createProxy</i>
37 /// associate that interface with a remote object at a given URL.
38 /// </remarks>
39public class XmlRpcClientProxy : RealProxy
40{
41 private String _remoteObjectName;
42 private String _url;
43 private XmlRpcRequest _client = new XmlRpcRequest();
44
45 /// <summary>Factory method to create proxies.</summary>
46 /// <remarks>
47 /// To create a local proxy you need to create a local C# interface with methods that mirror those of the server object.
48 /// Next, pass that interface into <c>createProxy</c> along with the object name and URL of the remote object and
49 /// cast the resulting object to the specifice interface.
50 /// </remarks>
51 /// <param name="remoteObjectName"><c>String</c> The name of the remote object.</param>
52 /// <param name="url"><c>String</c> The URL of the remote object.</param>
53 /// <param name="anInterface"><c>Type</c> The typeof() of a C# interface.</param>
54 /// <returns><c>Object</c> A proxy for your specified interface. Cast to appropriate type.</returns>
55 public static Object createProxy(String remoteObjectName, String url, Type anInterface)
56 {
57 return new XmlRpcClientProxy(remoteObjectName, url, anInterface).GetTransparentProxy();
58 }
59
60 private XmlRpcClientProxy(String remoteObjectName, String url, Type t) : base(t)
61 {
62 _remoteObjectName = remoteObjectName;
63 _url = url;
64 }
65
66 /// <summary>The local method dispatcher - do not invoke.</summary>
67 override public IMessage Invoke(IMessage msg)
68 {
69 IMethodCallMessage methodMessage = (IMethodCallMessage)msg;
70
71 _client.MethodName = _remoteObjectName + "." + methodMessage.MethodName;
72 _client.Params.Clear();
73 foreach (Object o in methodMessage.Args)
74 _client.Params.Add(o);
75
76 try
77 {
78 Object ret = _client.Invoke(_url);
79 return new ReturnMessage(ret,null,0,
80 methodMessage.LogicalCallContext, methodMessage);
81 }
82 catch (Exception e)
83 {
84 return new ReturnMessage(e, methodMessage);
85 }
86 }
87}
88}