Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / March 2008

Tip: Looking for answers? Try searching our database.

Alternative to static property in interface?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sin Jeong-hun - 02 Mar 2008 13:25 GMT
I would like to get a static property of classes through an interface.
But static isn't allowed in interface. The class types are
implementing an interface, and loaded from external assemblies (this
is my plug-in architecture). So, if the property is not static I
should create an instance for each class loaded, and instantiations
could be overheads. The static property is a description of the class
so it needn't be instantiated for all instances. I can get the static
property directly from the class, but then I can't make sure that the
class "implemented" that property. That's why I tried to define the
property in the interface in the first place. Then I thought of
putting them as an Attribute of the class, but again, I cannot make
sure that the class has the Attribute.

What would you think is the best way for this situation? Is there any
good way to make sure that the class has the static property ( as
interface does for non-static properties), or do I have to instantiate
them temporarily in order to use the property? Please give me an
advice, thank you.
Jon Skeet [C# MVP] - 02 Mar 2008 13:52 GMT
> I would like to get a static property of classes through an interface.
> But static isn't allowed in interface. The class types are
[quoted text clipped - 14 lines]
> them temporarily in order to use the property? Please give me an
> advice, thank you.

You might want to create two interfaces - one for the plugin, and one
for a plugin *factory*. The factory would allow you to create instances
of the plugin, tell you the description, etc.

Signature

Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet   Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.