473,387 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to add a method member to a class or object in run-time?

In run-time,is there any approach to add or revise the
members,such as method or attribute ,of a class or object?
As for the object of class soapclient30 in MS soap
toolkit, after it executes the mssoapinit method,it will
have some additional methods which have been described in
WSDL file. For an example,if a Web service provides
an "divide" method,the WSDL filename is mycalculator.wsdl:

set soapclient = CreateObject("MSSOAP.SoapClient30")
soapclient.mssoapinit "mycalculator.wsdl", "", "", ""
soapclient.divide 10,5

that is,the soapclient object has the divide method.
how to add the "divide" method for SoapClient30 class
internally?
Nov 15 '05 #1
2 3126
This won't work in C#, because object.method needs to be resolved at
compile-time, and the method doesn't exist. Try creating a method called
"Invoke" that takes a string argument specifying the name of the "method"
you want to run. The implementation is up to you (you could dynamically
generate code using Reflection.Emit, or just have custom code to interpret
any commands).

-mike
MVP

"peter" <an*******@discussions.microsoft.com> wrote in message
news:04****************************@phx.gbl...
In run-time,is there any approach to add or revise the
members,such as method or attribute ,of a class or object?
As for the object of class soapclient30 in MS soap
toolkit, after it executes the mssoapinit method,it will
have some additional methods which have been described in
WSDL file. For an example,if a Web service provides
an "divide" method,the WSDL filename is mycalculator.wsdl:

set soapclient = CreateObject("MSSOAP.SoapClient30")
soapclient.mssoapinit "mycalculator.wsdl", "", "", ""
soapclient.divide 10,5

that is,the soapclient object has the divide method.
how to add the "divide" method for SoapClient30 class
internally?

Nov 15 '05 #2
Thanks a lot,you are so kind.
Your solution is useful for me.But the class,
soapclient30 in MS soap toolkit30,is implemented the
function that I expect well and truly.Would you please
take some time to analysis the soapclient30 class?
I will appreciate an early reply.

toolkit-----Original Message-----
This won't work in C#, because object.method needs to be

resolved atcompile-time, and the method doesn't exist. Try creating a method called"Invoke" that takes a string argument specifying the name of the "method"you want to run. The implementation is up to you (you could dynamicallygenerate code using Reflection.Emit, or just have custom code to interpretany commands).

-mike
MVP

"peter" <an*******@discussions.microsoft.com> wrote in messagenews:04****************************@phx.gbl...
In run-time,is there any approach to add or revise the
members,such as method or attribute ,of a class or object? As for the object of class soapclient30 in MS soap
toolkit, after it executes the mssoapinit method,it will have some additional methods which have been described in WSDL file. For an example,if a Web service provides
an "divide" method,the WSDL filename is mycalculator.wsdl:
set soapclient = CreateObject("MSSOAP.SoapClient30")
soapclient.mssoapinit "mycalculator.wsdl", "", "", ""
soapclient.divide 10,5

that is,the soapclient object has the divide method.
how to add the "divide" method for SoapClient30 class
internally?

.

Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Alex Vinokur | last post by:
========================================= Windows 2000 CYGWIN_NT-5.0 1.3.22(0.78/3/2) GNU gcc version 3.2 20020927 (prerelease) ========================================= Here is some program...
17
by: Asfand Yar Qazi | last post by:
Basically this: //file 'B.hh' class B { protected: void f() {} }; //file 'C.hh'
6
by: xsist10 | last post by:
whats the best method. delphi lets you do something very simple ptrMethodFoo : procedure how do you do this in C++?
12
by: MacFly | last post by:
Hi everyone, HRESULT WINAPI DirectPlayMessageHandler( PVOID pvUserContext, DWORD dwMessageId, PVOID pMsgBuffer) I want that method to be class member method so it could have access to class...
22
by: Ruben Van Havermaet | last post by:
Hi, I have a problem using member functions in derived classes that override virtual member functions of base classes. The following pieces of (simplified) code don't work. Can anybody give...
4
by: keepyourstupidspam | last post by:
Hello, I have a class X with a member function setConfigValues(). I want to access this member function in another class Y. Y is not inherited from X. A member function of class X called run()...
12
by: Rubbrecht Philippe | last post by:
Hi there, According to documentation I read the ArrayList.IndexOf method uses the Object.Equals method to loop through the items in its list and locate the first index of an item that returns...
43
by: Tony | last post by:
I'm working with GUI messaging and note that MFC encapsulates the message loop inside of a C++ class member function. Is this somehow inherently less robust than calling the message loop functions...
8
by: Belebele | last post by:
Suppose that I want to write a (concrete) interface class (without virtual functions) to classes that contain a method template // -------------------------------------- class Interface {...
7
by: Immortal Nephi | last post by:
My project grows large when I put too many member functions into one class. The header file and source code file will have approximately 50,000 lines when one class contains thousand member...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.