473,386 Members | 1,734 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,386 software developers and data experts.

adding methods/properties runtime for web services

Hi,

I have been searching on this topic for quite sometime and didnt get
any answer.
Is there a way I can extend/add methods/properties to a C# class during
runtime.

eg.,
I have class:
public class MyClass {
private string identity;
}

So when running the program using this class I want to add a attribute
called "name" of type "string". Or say I want to make this class extend
some other class in runtime. Or add method called getIdentity() in
runtime.

Is any of the above possible? Or is it too much to ask?

To give you some background as to why I need this. We are using wsdl
tool to generate client proxy classes using .wsdl file. We need to add
some extra re-wiring to the classes generated in addition to the
relationships already in the schema which was part of wsdl file.

Or is it possible to override wsdl generation and catch the events
generated to add additional code during generation.

Any suggestion/documentation pointing to these aspects will be very
helpful.

Thanks in advance for all the help!!

Jul 21 '05 #1
2 2276
You can create new types with new methods at runtime using
Reflection.Emit, but I really don't think that is what you want.

The WSDL proxy files do not have to be created at runtime (I'm not even
sure how to do that). They can be created at design time by adding a
reference to a web service using VS.NET, or using the WSDL.EXE tool.
Both solutions create a .cs class file, which you are free to edit
during design time to add whatever methods you need.
ma*************@gmail.com wrote:
Hi,

I have been searching on this topic for quite sometime and didnt get
any answer.
Is there a way I can extend/add methods/properties to a C# class during
runtime.

eg.,
I have class:
public class MyClass {
private string identity;
}

So when running the program using this class I want to add a attribute
called "name" of type "string". Or say I want to make this class extend
some other class in runtime. Or add method called getIdentity() in
runtime.

Is any of the above possible? Or is it too much to ask?

To give you some background as to why I need this. We are using wsdl
tool to generate client proxy classes using .wsdl file. We need to add
some extra re-wiring to the classes generated in addition to the
relationships already in the schema which was part of wsdl file.

Or is it possible to override wsdl generation and catch the events
generated to add additional code during generation.

Any suggestion/documentation pointing to these aspects will be very
helpful.

Thanks in advance for all the help!!

Jul 21 '05 #2
First of all thanks very much for the quick responses.

Joshua,
I am using the wsdl.exe to generate the .cs file. My problem is it only
generates properties for the elements in the schema. Its very difficult
to navigate to a different object if the element points to a identity
for a different class type in schema.

eg.,
if there is an employee having an element for job which is part of a
different projection. The schema will have employee-type having
job-type's identity as reference. But to access the job object once
this schema is generated into a client proxy .cs file, to access the
job object for this employee, you need to go through all the jobs and
compare the identities of those with the identity in the employee
object.

I just want to have method called getJob() on employee which will do
this plumbing. My plan is to some how catalog all the objects coming in
and out through soap requests, something like having hashmap with
identity, object mapping. Implement methods which go to this hashmap
and get objects.

I dont know how much of this made sense, but this definitely requires
adding additional methods to classes generated using wsdl.exe. Even if
I can override this tool to trigger some events which I can catch and
add my own methods is also fine.

Ash, thanks for the link, will try to go through it and see whether its
useful for me.

Jul 21 '05 #3

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

Similar topics

10
by: Nikita A. Visnevski | last post by:
Hi everyone, I am rather new to Java beans. Just picked up a book last night and started reading about them. I am building an application that allows a user to define objects with dynamic...
9
by: Ben Dewey | last post by:
Project: ---------------------------- I am creating a HTTPS File Transfer App using ASP.NET and C#. I am utilizing ActiveDirectory and windows security to manage the permissions. Why reinvent...
2
by: Mark | last post by:
I have it in my head that I saw a marketing document from Microsoft with the total number of classes and methods in the .NET Framework. Something like 70,000 methods? I don't need precise numbers,...
3
by: Kiran | last post by:
Hi, If I create a Virtual directory with application name programmatically it will not show up in the available web services while adding web reference(Dynamic discovery fails). Where as if I...
1
by: Jeff Smith | last post by:
Can I load custom web user controls dynamically and access the properties and methods without having to explicitly define custom control types (example 2 below). I have custom web control named...
2
by: manohar.shankar | last post by:
Hi, I have been searching on this topic for quite sometime and didnt get any answer. Is there a way I can extend/add methods/properties to a C# class during runtime. eg., I have class:...
3
by: rickeringill | last post by:
Hi comp.lang.javascript, I'm throwing this in for discussion. First up I don't claim to be any sort of authority on the ecmascript language spec - in fact I'm a relative newb to these more...
9
by: J055 | last post by:
Hi I have a standard asp page which uses a MasterPage. The MasterPage contains a User control. How can I access a public method in the User control from my WebForm page? I can't move the method...
3
by: Udi | last post by:
Hi All, I have an object that is reflected at runtime by Windows script host engine, so its public methods and properties can then be used from within a script. Based on a certain condition, I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.