publicabstractclassANP_BBValue { publicabstract Type NP_BBValueType { get; } }
1 2 3 4 5
publicinterfaceINP_BBValue<T> { T GetValue(); voidSetValue(INP_BBValue<T> bbValue); }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
publicabstractclassNP_BBValueBase<T>: ANP_BBValue, INP_BBValue<T> { public T Value; public T GetValue() { return Value; } publicvoidSetValue(INP_BBValue<T> bbValue) { Value = bbValue.GetValue(); } publicvoidSetValue(T bbValue) { Value = bbValue; } }
publicclassNP_BBValue_Bool: NP_BBValueBase<bool>, IEquatable<NP_BBValue_Bool> { publicoverride Type NP_BBValueType { get { returntypeof (bool); } } #region 对比函数 publicboolEquals(NP_BBValue_Bool other) { // If parameter is null, return false. if (Object.ReferenceEquals(other, null)) { returnfalse; } // Optimization for a common success case. if (Object.ReferenceEquals(this, other)) { returntrue; } // If run-time types are not exactly the same, return false. if (this.GetType() != other.GetType()) { returnfalse; } // Return true if the fields match. // Note that the base class is not invoked because it is // System.Object, which defines Equals as reference equality. returnthis.Value == other.GetValue(); } publicoverrideboolEquals(object obj) { if (ReferenceEquals(null, obj)) { returnfalse; } if (ReferenceEquals(this, obj)) { returntrue; } if (obj.GetType() != this.GetType()) { returnfalse; } return Equals((NP_BBValue_Bool) obj); } publicoverrideintGetHashCode() { returnthis.Value.GetHashCode(); } publicstaticbooloperator ==(NP_BBValue_Bool lhs, NP_BBValue_Bool rhs) { // Check for null on left side. if (Object.ReferenceEquals(lhs, null)) { if (Object.ReferenceEquals(rhs, null)) { // null == null = true. returntrue; } // Only the left side is null. returnfalse; } // Equals handles case of null on right side. return lhs.Equals(rhs); } publicstaticbooloperator !=(NP_BBValue_Bool lhs, NP_BBValue_Bool rhs) { return !(lhs == rhs); } publicstaticbooloperator >(NP_BBValue_Bool lhs, NP_BBValue_Bool rhs) { returnfalse; } publicstaticbooloperator <(NP_BBValue_Bool lhs, NP_BBValue_Bool rhs) { returnfalse; } publicstaticbooloperator >=(NP_BBValue_Bool lhs, NP_BBValue_Bool rhs) { returnfalse; } publicstaticbooloperator <=(NP_BBValue_Bool lhs, NP_BBValue_Bool rhs) { returnfalse; } #endregion }
在黑板中的存储方式就是
1
privateDictionary<string, ANP_BBValue> m_Data = new Dictionary<string, ANP_BBValue>();