aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Common/XmlRpcCS/XmlRpcExposedAttribute.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Common/XmlRpcCS/XmlRpcExposedAttribute.cs')
-rw-r--r--Common/XmlRpcCS/XmlRpcExposedAttribute.cs87
1 files changed, 0 insertions, 87 deletions
diff --git a/Common/XmlRpcCS/XmlRpcExposedAttribute.cs b/Common/XmlRpcCS/XmlRpcExposedAttribute.cs
deleted file mode 100644
index 261ade3..0000000
--- a/Common/XmlRpcCS/XmlRpcExposedAttribute.cs
+++ /dev/null
@@ -1,87 +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.Reflection;
32
33 /// <summary>
34 /// Simple tagging attribute to indicate participation is XML-RPC exposure.
35 /// </summary>
36 /// <remarks>
37 /// If present at the class level it indicates that this class does explicitly
38 /// expose methods. If present at the method level it denotes that the method
39 /// is exposed.
40 /// </remarks>
41 [AttributeUsage(
42 AttributeTargets.Class | AttributeTargets.Method,
43 AllowMultiple = false,
44 Inherited = true
45 )]
46 public class XmlRpcExposedAttribute : Attribute
47 {
48 /// <summary>Check if <paramref>obj</paramref> is an object utilizing the XML-RPC exposed Attribute.</summary>
49 /// <param name="obj"><c>Object</c> of a class or method to check for attribute.</param>
50 /// <returns><c>Boolean</c> true if attribute present.</returns>
51 public static Boolean ExposedObject(Object obj)
52 {
53 return IsExposed(obj.GetType());
54 }
55
56 /// <summary>Check if <paramref>obj</paramref>.<paramref>methodName</paramref> is an XML-RPC exposed method.</summary>
57 /// <remarks>A method is considered to be exposed if it exists and, either, the object does not use the XmlRpcExposed attribute,
58 /// or the object does use the XmlRpcExposed attribute and the method has the XmlRpcExposed attribute as well.</remarks>
59 /// <returns><c>Boolean</c> true if the method is exposed.</returns>
60 public static Boolean ExposedMethod(Object obj, String methodName)
61 {
62 Type type = obj.GetType();
63 MethodInfo method = type.GetMethod(methodName);
64
65 if (method == null)
66 throw new MissingMethodException("Method " + methodName + " not found.");
67
68 if (!IsExposed(type))
69 return true;
70
71 return IsExposed(method);
72 }
73
74 /// <summary>Check if <paramref>mi</paramref> is XML-RPC exposed.</summary>
75 /// <param name="mi"><c>MemberInfo</c> of a class or method to check for attribute.</param>
76 /// <returns><c>Boolean</c> true if attribute present.</returns>
77 public static Boolean IsExposed(MemberInfo mi)
78 {
79 foreach (Attribute attr in mi.GetCustomAttributes(true))
80 {
81 if (attr is XmlRpcExposedAttribute)
82 return true;
83 }
84 return false;
85 }
86 }
87}