all groups > c# > october 2005 >
You're in the

c#

group:

How can i solve this simple problem without using reflection


How can i solve this simple problem without using reflection Ste
10/31/2005 11:25:53 PM
c#:
I am connecting to a web service and wsdl has generated a lot of methods =
for it. I am creating a wrapper DLL that handles all the communication =
with the web service (uses WSE and such) to hide the complexity and do =
full validation etc..

Each method takes the same input param and needs to call a distinct =
validation fn(). [ see example below ]

How can i avoid cutting and pasting 100's of fn()'s eg...

I can use reflection to dynamically create each fn() on demand - but =
then my clients would not see a nice list of fn()'s and parameters in =
the "object browser".

Is there anyway i can get Visual Studio to autogenerate the methods =
based upon some form of template - eg an [attribute] .. dont think so - =
but i thought i would ask?

Can anyone suggest a nice pattern? =20

Any help is appreciated whatsoever =20
=20

*** How can i avoid cutting and pasting 100's of fn()'s eg...


public string method_01(string inputXml)
{
// note args change for each fn()
ValidateXMLAgainstXSD(inputXML, "method_01.xsd");
outputXML =3D soap.method_01(inputXML);
ValidateXMLAgainstXSD(outputXML, "method_01.xsd");
=20
return outputXML;
}

public string method_02(string inputXml)
{
// note args change for each fn()
ValidateXMLAgainstXSD(inputXML, "method_02.xsd");
outputXML =3D soap.method_01(inputXML);
ValidateXMLAgainstXSD(outputXML, "method_02.xsd");

return outputXML;
}

....=20
.... 997 functions cut & paste & edited later
....
=20
public string method_999(string inputXml)
{
// note args change for each fn()
ValidateXMLAgainstXSD(inputXML, "method_999.xsd");
outputXML =3D soap.method_01(inputXML);
ValidateXMLAgainstXSD(outputXML, "method_999.xsd");

return outputXML;
Re: How can i solve this simple problem without using reflection Frank Dzaebel
11/1/2005 7:59:52 AM
Hi Ste,

[quoted text, click to view]

May be 'Assembly enhancing' is possible idea here (autotranslated!) :
http://www.dzaebel.net/ExtendYourAssembliesAfterCompiling.htm


ciao Frank
--
Dipl.Inf. Frank Dzaebel [MCP/MVP C#]
AddThis Social Bookmark Button