/* * DotGNU XmlRpc implementation * * Copyright (C) 2002 netFluid Technology Ltd * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * * $Revision: 1.1.2.1 $ $Date: 2003/08/30 17:47:17 $ * * -------------------------------------------------------------------------- */ namespace DotGNU.DGEE.Protocols { using System; using System.Collections; using System.Reflection; using System.Text; using System.Web.Services; using System.IO; public class RequestProc { // Invoke requested method if we have a Request Stream // public MethodInfo ResolveMethod( String type, String method ) { Type svcType = Type.GetType( type ); Console.WriteLine( "Request Proc ThisType: {0}", svcType.ToString() ); MethodInfo minfo = FindMethod( svcType, method ); if( minfo == null ) throw new Exception ( "ERROR: Cannot resolve Method" ); return minfo; } internal WebMethodAttribute GetAttribute(MethodInfo method) { Attribute[] attrs = Attribute.GetCustomAttributes(method, typeof(WebMethodAttribute), false); if( attrs == null || attrs.Length != 1 ) return null; return (WebMethodAttribute)attrs[0]; } internal MethodInfo FindMethod( Type type, String methodname ) { MethodInfo []methods = type.GetMethods(); //type.GetMethods(BindingFlags.Public | BindingFlags.Static); // Scan methods in class, looking for the requested // foreach(MethodInfo method in methods) { Console.WriteLine( "Method: {0}", method.Name ); if( method.Name != methodname ) continue; // See if method is a Webservice (indicated by attribute) // Attribute attr = GetAttribute(method); if(attr != null) { // Found required MethodInfo // return method; } } return null; } } }