473,399 Members | 2,478 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,399 software developers and data experts.

Invokation added at runtime?

I have an abstract class with a bool property:

class Abstract {
protected bool throwException;

protected void ThrowException{
if (this.throwException){
throw new MyException();
}
}
}
I then have two derived classes that have propertys:

class A : Abstract {
property X {
get { ... }
set { ... }
}

property Y {
get { ... }
set { ... }
}
}

class B : Abstract {
property Z {
get { ... }
set { ... }
}
}

How can I implement an scenario where the objects from class A or from
class B invoke the abstract method ThrowException every time a property
is accessed I mean, inserting the call as the first instruction of the
get/set methods, without having to coding it, just inserting the call at
runtime (modifying the accessors at runtime)?

Thanks in advance.

--
Nov 23 '06 #1
2 1204

You may checkout some AOP (Aspect Oriented Programming) containers,
like http://www.springframework.net

Thi
http://thith.blogspot.com

Ympostor wrote:
I have an abstract class with a bool property:

class Abstract {
protected bool throwException;

protected void ThrowException{
if (this.throwException){
throw new MyException();
}
}
}
I then have two derived classes that have propertys:

class A : Abstract {
property X {
get { ... }
set { ... }
}

property Y {
get { ... }
set { ... }
}
}

class B : Abstract {
property Z {
get { ... }
set { ... }
}
}

How can I implement an scenario where the objects from class A or from
class B invoke the abstract method ThrowException every time a property
is accessed I mean, inserting the call as the first instruction of the
get/set methods, without having to coding it, just inserting the call at
runtime (modifying the accessors at runtime)?

Thanks in advance.

--
Nov 23 '06 #2
Ympostor wrote:
I have an abstract class with a bool property:
<snip>
How can I implement an scenario where the objects from class A or from
class B invoke the abstract method ThrowException every time a property
is accessed I mean, inserting the call as the first instruction of the
get/set methods, without having to coding it, just inserting the call at
runtime (modifying the accessors at runtime)?
It sounds like you're after Aspect-Oriented Programming (AOP). I
haven't done any of that on .NET (and only a bit in Java) but you may
well find some useful articles and libraries online. I would guess that
most are likely to intercept assembly loading and weave the extra calls
in at that point.

Jon

Nov 23 '06 #3

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

Similar topics

0
by: lucasimone | last post by:
Hi, i need some help to a pocket PC application. I need to implement a Form that contains a WebBrowser to display somes HTML forms. But when users invoke a submit, of that form, i need to capture...
15
by: apm | last post by:
Can an enum start empty and be added to on the fly?
5
by: Steven Berkovitz | last post by:
Hi there, I am having a problem where if i add an attribute to a control at runtime the rendered attribute is HTML encoded. For example, on a textbox: textBox.Attributes = "if(x && y)...
4
by: Jordan | last post by:
I need to dynamically add an ImageButton control to a user control and and do some server-side processing when the user clicks it. While I the ImageButton is added to the user control at runtime,...
3
by: Andrew V | last post by:
Greetings, I need to create a web service to be called by a few of our external affiliated web sites. How can I restrict web service invokation to only these affiliated web sites? Some of the...
3
by: =?Utf-8?B?THVib21pcg==?= | last post by:
Hi, I am wondering how I could clear the invokation list of delegates. I tried the following: //make a chain MyDel += SomeDel; // Clear the chain
5
by: =?Utf-8?B?TWFyYyBXb29sZnNvbg==?= | last post by:
Hi, I have a strange issue occurring with LinkButtons that are dynamically added to each (data) row of my DataGrid on that grid's ItemDataBound event. Each LinkButton is assigned its own event...
2
by: Rob | last post by:
I am not sure if this can be implemented.... There exists a TabContol (added at design time) to a form.. Tabs for this TabContol get added at run time. Usage of the following 2 properties...
1
by: woshicike | last post by:
Hi, I created a web service. When I place it under visual studio development server, the asynchronous invokation of web methd works fine. But when I publish the web service under IIS 5.1, the...
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: 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
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:
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,...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...
0
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...

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.