Sage Modeling and Simulation Library

SmartPropertyBag Members

The SmartPropertyBag type exposes the following members.

Constructors


  Name Description
Public method SmartPropertyBag
Creates a SmartPropertyBag.

Methods


  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:
C#
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:
C#
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.

C#
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 ) {
               Trace.Write(hde.Value.ToString());
               if ( hde.Value is double ) {
                    _Debug.WriteLine(" <NOTE: this is a double.>");
               } else {
                   _Debug.WriteLine("");
               }
           } else {
               _Debug.WriteLine("");
               DumpEnumerable((IEnumerable)hde.Value,depth+1);
           }
       }
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.)

Operators


  Name Description
Public operator Static member Explicit Narrowing Explicit Explicit Explicit (SmartPropertyBag to WriteLock)
Allows the SPB to be treated as a writelock, to determine if it is write-protected.

Properties


  Name Description
Public property HasChanged
True if this SPB has changed in any way since the last time it was snapshotted.
Public property IsLeaf
Indicates if this SPB is a leaf (whether it contains entries). Fulfills obligation incurred by implementing TreeNode.
Public property IsWritable
Indicates if write operations on this equipment are permitted.
Public property Item
Retrieves an entry from this SPB. Compound keys may be specified if appropriate. For example, 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:
C#
string theSKU = (string)myPallet["Crates.123-45.SKU"];
Public property Memento
Retrieves the memento of this SPB. Includes all state from this bag, other bags' aliased entries, and child bags, as well as the mementos from any entry that implements ISupportsMementos. Optimizations are applied such that a minimum of computation is required to perform the extraction.
Public property ReportsOwnChanges
True if this SPB is capable of reporting its own changes.

Events


  Name Description
Public event MementoChangeEvent
Fired whenever the memento maintained by this SPB has changed.