예제 #1
0
        public IList listMethods()
        {
            IList methods = new ArrayList();
            bool  considerExposure;

            foreach (DictionaryEntry handlerEntry in _server)
            {
                considerExposure = XmlRpcExposedAttribute.IsExposed(handlerEntry.Value.GetType());

                foreach (var mi in handlerEntry.Value.GetType().GetMembers())
                {
                    if (mi.MemberType != MemberTypes.Method)
                    {
                        continue;
                    }

                    if (!((MethodInfo)mi).IsPublic)
                    {
                        continue;
                    }

                    if (considerExposure && !XmlRpcExposedAttribute.IsExposed(mi))
                    {
                        continue;
                    }

                    methods.Add(handlerEntry.Key + "." + mi.Name);
                }
            }

            return(methods);
        }
예제 #2
0
        public Object Invoke(Object target)
        {
            Type       type   = target.GetType();
            MethodInfo method = type.GetMethod(MethodNameMethod);

            if (method == null)
            {
                throw new XmlRpcException(-2, "Method " + MethodNameMethod + " not found.");
            }

            if (XmlRpcExposedAttribute.IsExposed(target.GetType()) &&
                !XmlRpcExposedAttribute.IsExposed(method))
            {
                throw new XmlRpcException(-3, "Method " + MethodNameMethod + " is not exposed.");
            }

            Object[] args = new Object[Params.Count];

            for (int i = 0; i < Params.Count; i++)
            {
                args[i] = Params[i];
            }

            return(method.Invoke(target, args));
        }