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

How can I set properties of the concrete class while programming against interfaces?



Hi,

In general my question is how can I set properties on a concrete class
while programming against interfaces
For example I have a MailServerFatory which can create two types of
Mail servers and return IMailServer
public interface IMailServer
{
void Send();
MailServerType Type {get;}
}
the first is SMTP server

public class SMTPMailServer : IMailServer
{
public void Send(){}
public string SMTPHost
public MailServerType Type

}

The second is EXCHMailServer

public class EXCHMailServer:IMailServer
{

public string UserName
public string PassWord
public string Folder
public void Send()
public MailServerType Type
}
When one of the properties of the current mail server changed i would like
that the application will set it.
I know of course that I can add
OnPropertyChanged(PropertyName,PropertyValue) to the IMailServer
but I am looking for other way.

I was thinking about reflection,but can I get the concrete class from an
interface?

Thanks in advance

Nov 16 '05 #1
3 1201
If I understand you correctly, the best way to do it is just to make the
property at the interface as set as well as get:

For example:

MailServerType Type {get; get}

And now the user of the interface can change the property value of the
concrete class.

Hope it helps
Sharon G.
http://sharong.agreatserver.com/

Nov 16 '05 #2
But each mail server have different properties.

Thanks.

"Sharon" <Sh****@discussions.microsoft.com> wrote in message
news:BA**********************************@microsof t.com...
If I understand you correctly, the best way to do it is just to make the
property at the interface as set as well as get:

For example:

MailServerType Type {get; get}

And now the user of the interface can change the property value of the
concrete class.

Hope it helps
Sharon G.
http://sharong.agreatserver.com/

Nov 16 '05 #3
You have two choices:
1. To add each property you realize to the interface class with set and get.
2. Or instead of using a Interface class, use abstract class that include
all the properties you realize and give them some default implementation that
the derived classes can override.

I don’t know what else can be done.
Hope it helps
Sharon G.
http://sharong.agreatserver.com/
Nov 16 '05 #4

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

Similar topics

19
by: David Baelde | last post by:
Hi, I tried python, and do like it. Easy to learn and read (at least for the commonly used part), has a very large community so great doc and contributions, and... the design is clean. I come...
45
by: Brett | last post by:
If I do this without declaring a corresponding field, is it considered bad design? What are the advantages or disadvantages to either method? Notice there is not set. public string URL { get...
10
by: Jeff Grills | last post by:
I am an experienced C++ programmer with over 12 years of development, and I think I know C++ quite well. I'm changing jobs at the moment, and I have about a month between leaving my last job and...
12
by: Perre Van Wilrijk | last post by:
Hi there, When I started using VB6, I used to write classes with properties and functions as following ... Private lngf1 As Long Private strf2 As String Public Property Get f1() As Long...
7
by: WXS | last post by:
Vote for this idea if you like it here: http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx?feedbackid=5fee280d-085e-4fe2-af35-254fbbe96ee9...
7
by: sherifffruitfly | last post by:
Hi, I'm learning the .net Bloomberg api, and it's main class has all of its stuff static. The help then goes on to say that the class is implemented as a singleton. It's cool I guess to make...
17
by: Lee Harr | last post by:
I understand how to create a property like this: class RC(object): def _set_pwm(self, v): self._pwm01 = v % 256 def _get_pwm(self): return self._pwm01 pwm01 = property(_get_pwm, _set_pwm)
0
by: mvanroshum | last post by:
Hi, I have the following problem: The DataSource of a DataGrid can be set to an IList. The DataGrid nicely lists the objects in the IList, showing all the public properties of the objects as...
4
by: Josh Valino | last post by:
Hi group, Is there a way in C# (.Net 3.5 FW) for me to define an abstract class that has some properties, and then in each derived class, select which properties I'd like available and which...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.