Welcome to Rainbow Portal Community Sign in | Join | Help

Generic Setting Object

Well, i was looking at the content api, and noticed, settings are reptitive in a few objects, and they need to support different types.

i was working on it a bit, and came up with something like this... i hope to get some feedback, because filip and i are moving along, and the base code once in place, wont change for a bit as we proced, as setting is a key base type in the api. ( similar so in rainbow and most aps in general ).

the thing is a setting, jsut like in appsettings, come down to a simple key value pair. it gets more interesting when you say the value has a type, so now you have key, value and type. lastly, it may be interesting to know when a setting is changed.

So here is my proposal for a setting object.

 

   1:  [Serializable]
   2:      public class Setting<T>
   3:      {
  11:          private T _value; 
  12:          private string _key;
  13:   
  14:          public Setting()
  15:          {
  16:              _value = default(T);
  17:          }
  18:          public Setting(T value, string key)
  19:          {
  20:              _value = value;_key = key;
  21:          }
  22:   
  23:          public T Value
  24:          {
  25:              get
  26:              {
  27:                  return _value; 
  28:                                //
  29:              }
  30:              set
  31:              {
  32:                  if (!_value.Equals(value))
  33:                  {
  35:                      _value = value;
  38:                  }
  39:              }
  40:          }
  41:   
  42:          public override int GetHashCode()
  43:          {
  44:              return base.GetHashCode();
  45:          }
  46:   
  47:          public override string ToString()
  48:          {
  49:              return "Key = " + this.Key + " : value = " 
  50:                   + this.Value.ToString();
  51:          }
  52:   
  53:   
  54:          public string Key
  55:          {
  56:              get { return _key; }
  57:              set { _key = value; }
  58:          }
  59:                
  97:      }
Published domenica 11 giugno 2006 21.45 by Jonathan
Filed under: , ,

Comments

# re: Generic Setting Object

mercoledì 14 giugno 2006 15.15 by Yannick Smits
sorry for jumping in so late on this discussion but could you elaborate on the differences of using this settings system or using the Microsoft.ApplicationBlocks.Config classes?

# re: Generic Setting Object

mercoledì 14 giugno 2006 23.42 by Jonathan
setting object has nothing to do with config settings, it is a "setting object" for other obejcts.
so an item object has settings
ItemSettings and types have TypeSettings
Item And Type settings both inherit SettingCollection, and basically are settings.

# New to DNS Blogs

lunedì 26 giugno 2006 5.33 by jonathan's blog
I have some blogging there on things like providing design time support to your custom controls, codedom, builiding a generic setting objects and client side javascript stuff.

# metro pcs phone ringtones

lunedì 4 febbraio 2008 19.40 by ringtones for alltel cell phone

Before free motorola real ringtones free pcs ringtones sprint

# nokia ringtones tracfone

In fact make ringtones free 100 free mobile ringtones virgin

# free cingular wireless ringtones

lunedì 4 febbraio 2008 21.06 by 30 day payday loan

If 30 day payday loan ringtones for prepaid cell phone

Anonymous comments are disabled