[ADDED] [V0.8.0] Make abstract classes like ComboBoxBase easier to inherit from

  1. #1

    [ADDED] [V0.8.0] Make abstract classes like ComboBoxBase easier to inherit from

    While working on creating some Extensions for the Coolite Framework, I found a large limitation with some abstract classes. A really good example of this limitation is with the ComboBoxBase class. If I wish to create a new ComboBox style control that inherits ComboBoxBase, the Items property is locked into a collection of ListItems (text and value). Here is an example of the control I am working on and I have it working, but I couldn't reuse any existing code.

    <ext:IconCombo 
       ID="IconComboTest" 
       TriggerAction="All"
       Mode="Local"
       Editable="false"
       ForceSelection="true"
       Select&#111;nfocus="true"
       EmptyText="Select a country"
       runat="server">
       <Items>
          <ext:IconListItem Text="United States" Icon="FlagUs" Value="US" />
          <ext:IconListItem Text="Canada" Icon="FlagCa" Value="CA" />
          <ext:IconListItem Text="Russia" Icon="FlagRu" Value="RU" />
          <ext:IconListItem Text="Germany" Icon="FlagDe" Value="DE" />
          <ext:IconListItem Text="Italy" Icon="FlagIt" Value="IT" />
       </Items>
    </ext:IconCombo>
    I would assume that a developer would start by creating a class similar to this:

    public class IconCombo : ComboBoxBase
    {
    
    ...
    
       private IconListItemCollection items;
    
       public IconListItemCollection Items   // <= will error because the abstract class locks the type
       {
          get { return items; }
          set { items = value; }
       }
    
    }
    I would like to recommend that this collection use generics to identifythe contents collection. The complicated part of this implementationwould be the JsonConverter. To make it developer friendly, there wouldhave to be some way to convert the object, probably using JsonPropertyattributes. Anyhow, the new code would look something like this.

    public class IconCombo : ComboBoxBase<IconListItem>
    {
    
    ...
    
       private ListItemCollection<IconListItem> items;
    
       public ListItemCollection<IconListItem> Items 
       {
          get { return items; }
          set { items = value; }
       }
    }
    
    public class ComboBox : ComboBoxBase<ListItem>
    {
    
    ...
    
       private ListItemCollection<ListItem> items;
    
       public ListItemCollection<ListItem> Items 
       {
          get { return items; }
          set { items = value; }
       }
    }

    Thanks,
    MC
  2. #2

    RE: [ADDED] [V0.8.0] Make abstract classes like ComboBoxBase easier to inherit from

    Hi MC,

    The*ListItemCollection has been modified and committed to svn.*


    Publicly available with v0.8.0.


    Hope this helps.


    Geoffrey McGill
    Founder

Similar Threads

  1. [CLOSED] Runtime error in abstract component .cs
    By feanor91 in forum 2.x Legacy Premium Help
    Replies: 4
    Last Post: Apr 18, 2012, 11:24 AM
  2. Cannot create abstract class.
    By hugo.carvalho in forum Bugs
    Replies: 7
    Last Post: Aug 07, 2009, 12:53 AM
  3. [CLOSED] Abstract objects in a Store control. Is this possible?
    By conman in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Feb 04, 2009, 9:05 AM
  4. [FIXED] [V0.5] ComboBoxBase and 0.5.0
    By Karel Frajták in forum Bugs
    Replies: 1
    Last Post: Jun 11, 2008, 5:08 AM

Posting Permissions