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

Does the C# FCL implement a Listener interface or methods?

Hey guys,

Subject line says it all. I have many presentation layer objects that
need to be notified when a specific business-tier class has been
modified.

Thanks,
Roger

Nov 16 '05 #1
3 1783
There is no specific implementation for Listener interfaces in the FCL.
Notification from business objects to presentation is done through events in
the business objects.

--
-Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph
"Roger Helliwell" <rh********@telus.net> wrote in message
news:m6********************************@4ax.com...
Hey guys,

Subject line says it all. I have many presentation layer objects that
need to be notified when a specific business-tier class has been
modified.

Thanks,
Roger

Nov 16 '05 #2
Hey Roger,

You should use events in your business-tier classes which would be raised
when the business class has been modified. The presentation layer objects
would then subscribe to that events to receive notifications they are
interested in.

For example:

//////////////////////
// Business tier
//////////////////////
public class Customer
{
...
private string _firstName;

public event EventHandler FirstNameChanged;

public string FirstName
{
get
{
return _firstName;
}
set
{
_firstName = value;
if (null != FirstNameChanged)
{
FirstNameChanged(this, EventArgs.Empty);
}
}
}
}

////////////////////////////
// Presentation tier
////////////////////////////

public class MyForm: Form
{
private Customer _customer;

public MyForm()
{
InitializeComponent();

_customer = new Customer();
_customer.FirstNameChanged += new
EventHandler(CustomerFirstNameChangedHandler);
}

private CustomerFirstNameChangedHandler(object sender, EventArgs e)
{
// React on first name change.
}
}

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

"Roger Helliwell" <rh********@telus.net> wrote in message
news:m6********************************@4ax.com...
Hey guys,

Subject line says it all. I have many presentation layer objects that
need to be notified when a specific business-tier class has been
modified.

Thanks,
Roger


Nov 16 '05 #3
On Tue, 20 Jul 2004 10:55:10 +0300 in
microsoft.public.dotnet.languages.csharp, "Dmitriy Lapshin [C# / .NET
MVP]" <x-****@no-spam-please.hotpop.com> wrote:
Hey Roger,

You should use events in your business-tier classes which would be raised
when the business class has been modified. The presentation layer objects
would then subscribe to that events to receive notifications they are
interested in.

For example:

//////////////////////
// Business tier
//////////////////////
public class Customer
{
...
private string _firstName;

public event EventHandler FirstNameChanged;


Thanks Dmitriy, that was exactly what i was looking for. I didn't even
know C# had an 'event' keyword! My Deitel & Deitel book barely
mentions it. Thanks again.

Roger

Nov 16 '05 #4

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

Similar topics

3
by: Tony Johansson | last post by:
Hello! When a class implaments an Interface must the class implement all methods? Whan happen if the class don't implament all methods in the interface. Will it cause compile error then. ...
4
by: wesley | last post by:
Hi, Why must abstract classes implements all the methods/property in the interface it implements? Since it's an abstract class it shouldn't be able to be instantiated and the child classes are...
4
by: Sanjay Vyas | last post by:
Sorry, forgot to cross post this one.. This is rather unusual as we would expect any Collection class to implement ICollection interface and furthermore a Dictionary class should implement...
2
by: Kjetil Bjerknes | last post by:
I'm currently creating some user controls in C#, and I've come across the interface IServiceProvider. This interface must be one of the worst examples of bad design I've ever seen. It contains one...
9
by: pamelafluente | last post by:
Hi, I was "studying" the famous (public code) BusyBox. I see the instruction: var busyBox = new BusyBox as in var busyBox = new BusyBox("BusyBox1", "busyBox", 4, "gears_ani_", ".gif",...
52
by: Ben Voigt [C++ MVP] | last post by:
I get C:\Programming\LTM\devtools\UselessJunkForDissassembly\Class1.cs(360,27): error CS0535: 'UselessJunkForDissassembly.InvocableInternals' does not implement interface member...
6
by: Smithers | last post by:
Just looking to compile a list of "all the ways to implement events". I'm NOT looking to get into the merits or mechanics of each in this thread... just want to identify them all - good, bad, and...
9
by: Jonathan Wood | last post by:
I found the following class on the Web: public class LoginRewriter : IHttpModule { void IHttpModule.Dispose() { } void IHttpModule.Init(HttpApplication app) { app.AuthorizeRequest += new...
162
by: Sh4wn | last post by:
Hi, first, python is one of my fav languages, and i'll definitely keep developing with it. But, there's 1 one thing what I -really- miss: data hiding. I know member vars are private when you...
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: 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...
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...
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...

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.