Sage Modeling and Simulation Library

SmartPropertyBag Methods

The SmartPropertyBag type exposes the following members.


  Name Description
Public method AddAlias
Adds an alias to this SPB. An alias points to an entry in another SPB. The other SPB need not be a child of this SPB.
Public method AddBoolean
Adds a boolean value to the SPB under a specified key.
Public method AddChildSPB
Adds a child SPB to this SPB. A child SPB is one that is owned by this bag, and whose entries can be treated as sub-entries of this bag. For example, a if a bag, representing a pallet, were to contain another SPB under the key of "Crates", and that SPB contained one SPB for each crate (one of which was keyed as "123-45", and that SPB had a string keyed as "SKU" and another keyed as "Batch", then the following code would retrieve the SKU directly:
string theSKU = (string)myPallet["Crates.123-45.SKU"];
Public method AddDelegate
Adds a delegate to the SPB under a specified key. When this entry is retrieved from the SPB, it will first be located by key, and then be evaluated by calling it, and the value returned from the delegate invocation will be returned to the entity calling into the SPB. Example:
SPBDoubleDelegate spbdd = new SPBDoubleDelegate(this.GetAValue);
mySPB.AddDelegate("someValue",spbdd); // Add the delegate to the SPB.
double theValue = mySPB["someValue"]; // calls into 'this.GetAValue()' and returns the answer.
Public method AddExpression
Adds an expression to this SPB.
Public method AddSnapshottable
Any object can be stored in a SPB if it implements ISupportsMementos. This API performs such storage.
Public method AddString
Adds a string value to the SPB under a specified key.
Public method AddValue
Adds a value (convertible to double) to the SPB under a specified key.
Public method Clear
Removes all objects from the SPB.
Public method Contains
Determines whether this smart property bag contains the specified key.
Public method DeserializeFrom
Reconstitutes this object from the specified XmlSerializationContext.
Public method Equals(ISupportsMementos)
Returns true if the two SPBs are semantically equal. (In other words, if both have the same entries, and each evaluates as being '.Equal()' to its opposite, then the two bags are equal.)
Public method Equals(System.Object)
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected method ExistsKey
Returns true if this dictionary (or any dictionary below it) contains a value stored under this key.
Protected method Finalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Protected method GetContentsOfKey
Retrieves the contents of a key known to exist in THIS SPB. Throws a SmartPropertyBagContentsException if the key does not exist in this bag.
Public method GetEnumerator
Retrieves an enumerator that cycles through all of the entries in this SPB. If the entry is not a leaf node, then it can have its enumerator invoked, allowing that entry's child list to be walked, and so forth.

private void DumpEnumerable( IEnumerable enumerable, int depth ) {
       foreach ( HierarchicalDictionaryEntry hde in enumerable ) {
           for ( int i = 0 ; i < depth ; i++ ) Trace.Write("\t");
           Trace.Write(hde.Key.ToString() + ", ");
           Trace.Write(hde.Value.GetType() + ", ");
           if ( hde.IsLeaf ) {
               if ( hde.Value is double ) {
                    _Debug.WriteLine(" <NOTE: this is a double.>");
               } else {
           } else {
Public method GetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public method GetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected method MemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public method Remove
Removes an object from this SPB.
Public method SerializeTo
Stores this object to the specified XmlSerializationContext.
Public method ToString
Returns a string that represents the current object.
(Inherited from Object.)