Hi all,
I have this code structure:
public abstract class ContentEntryBase
{
public string UniqueIdentifier;
public string Title;
public abstract ContentType contentType { get;}
}
public class TextArticle : ContentEntryBase
{
// Holds plain / HTML text as content
public override ContentType contentType {
get { return ContentType.TextArticle; } }
}
public class Series : ContentEntryBase
{
// Holds a series of TextArticles, Separators
// and Prefaces as content
ContentEntryBase[] Articles = null;
public override ContentType contentType {
get { return ContentType.Series; } }
}
ContentEntryBase isn't an interface as so to allow me to perform basic actions valid to all descendant types from the base class.
I have a WinForms application utilizing these classes, and I want it to be able to call a method on ContentEntryBase (meaning, without realizing the exact type of the object at hand) for both displaying the content, and editing it.
So for example, TextArticle would show a TextBox / WYSIWYG editor when accessed for editing, and return a string when accessed for display. When Series is accessed for editing, it would show a list of all elements it contains (derived from ContentEntryBase) where those items could be edited or sorted. When accessed for display, it would show a list of all children. I also have several more derived types, but these are the basic ones.
I tried thinking of the best contract to define for this, but came with no good solution. Can this be made in a way where it could be used in both WinForms and WebForms or MVC? Can display and edit functionalities use the same contract / function (GetContent() or something)?
I know using .NET 2.0 only limiting this even further, but this is what I have to use...
Thanks in advance!
Itamar.