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: }