473,732 Members | 2,033 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2318
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
3786
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 properties. Something similar to a java hash table. One can add new properties at runtime and remove them as well. I have a really fancy third party property inspector available to me that I would very much like to reuse. This inspector uses...
9
10900
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 the wheel, right? Everything so far is working well with the Active Directory. The problem I am having is with adding File Permissions to a directory. I am currently using some code courtesy of "Willy Denoyette "
2
5435
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, but a rough estimate of the number of classes and methods would be interesting to know.... Thanks in advance. Mark
3
2224
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 create the virtual directory manually it will shown up while adding web reference. I have used the following code to create it
1
2418
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 EditStuff.ascx which reads from an xml file and loads controls to its self based on string value in xml nodes collection of the xml. There are several controls that can be loaded and for each one there exists a public method called 'IntiControl'...
2
357
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: public class MyClass {
3
1779
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 esoteric uses (abuses?) of the language. I've been working from the oft quoted resource http://www.crockford.com/javascript/private.html. During my first serious attempt at using the knowledge acquired from this page, I ran up against the problem...
9
2651
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 to another location because it populates a Textbox in the user control page. Thanks Andrew
3
13819
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 need to allocate a new member inside that object to be able to use it through the script engine as well. (This local member is null and ignored by default)
0
8944
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8772
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9303
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9233
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8184
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6732
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6030
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4546
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2176
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.