- /// This method is never invoked if the parser is namespace aware
- /// and was called to process the root node.
- ///
+ ///
+ /// Parse the specified XmlElement and register the resulting
+ /// ObjectDefinitions with the IObjectDefinitionRegistry
+ /// embedded in the supplied
+ ///
+ /// The element to be parsed.
+ /// TThe object encapsulating the current state of the parsing process.
+ /// Provides access to a IObjectDefinitionRegistry
+ /// The primary object definition.
+ ///
+ ///
+ /// This method is never invoked if the parser is namespace aware
+ /// and was called to process the root node.
+ ///
- /// Allows simple manipulation of properties, and provides constructors to
- /// support deep copy and construction from a number of collection types such as
- /// and
- /// .
- ///
- ///
- /// Rod Johnson
- /// Mark Pollack (.NET)
- /// Rick Evans (.NET)
- [Serializable]
- public class MutablePropertyValues : IPropertyValues
- {
- #region Fields
-
- ///
- /// The list of objects.
- ///
- private IList propertyValuesList = new ArrayList();
-
- #endregion
-
- #region Constructor (s) / Destructor
-
- ///
- /// Creates a new instance of the
- /// class.
- ///
- ///
- ///
- /// The returned instance is initially empty...
- /// s can be added with the various
- /// overloaded ,
- /// ,
- /// ,
- /// and
- /// methods.
- ///
- ///
- ///
- ///
- public MutablePropertyValues ()
- {
- }
-
- ///
- /// Creates a new instance of the
- /// class.
- ///
- ///
- ///
- /// Deep copy constructor. Guarantees
- /// references are independent, although it can't deep copy objects currently
- /// referenced by individual objects.
- ///
- ///
- public MutablePropertyValues (IPropertyValues other)
- {
- if (other != null)
- {
- AddAll (other.PropertyValues);
- }
- }
-
- ///
- /// Creates a new instance of the
- /// class.
- ///
- ///
- /// The with property values
- /// keyed by property name, which must be a .
- ///
- public MutablePropertyValues (IDictionary map)
- {
- AddAll (map);
- }
-
- #endregion
-
- #region Properties
-
- ///
- /// Property to retrieve the array of property values.
- ///
- public PropertyValue[] PropertyValues
- {
- get { return (PropertyValue[]) ArrayList.Adapter (propertyValuesList).ToArray (typeof (PropertyValue)); }
- }
-
- #endregion
-
- #region Methods
-
- ///
- /// Overloaded version of Add that takes a property name and a property value.
- ///
- ///
- /// The name of the property.
- ///
- ///
- /// The value of the property.
- ///
- public void Add (string propertyName, object propertyValue)
- {
- Add (new PropertyValue (propertyName, propertyValue));
- }
-
- ///
- /// Add the supplied object,
- /// replacing any existing one for the respective property.
- ///
- ///
- /// The object to add.
- ///
- public void Add (PropertyValue pv)
- {
- for (int i = 0; i < propertyValuesList.Count; ++i)
- {
- PropertyValue currentPv = (PropertyValue) propertyValuesList [i];
- if (currentPv.Name.Equals (pv.Name))
- {
- propertyValuesList[i] = pv;
- return ;
- }
- }
- propertyValuesList.Add (pv);
- }
-
- ///
- /// Add all property values from the given
- /// .
- ///
- ///
- /// The map of property values, the keys of which must be
- /// s.
- ///
- public void AddAll (IDictionary map)
- {
- if (map != null)
- {
- foreach (string key in map.Keys)
- {
- Add (new PropertyValue (key, map [key]));
- }
- }
- }
-
- ///
- /// Add all property values from the given
- /// .
- ///
- ///
- /// The list of s to be added.
- ///
- public void AddAll (IList values)
- {
- if (values != null)
- {
- foreach (PropertyValue value in values)
- {
- Add (value);
- }
- }
- }
-
- ///
- /// Remove the given , if contained.
- ///
- ///
- /// The to remove.
- ///
- public void Remove (PropertyValue pv)
- {
- propertyValuesList.Remove (pv);
- }
-
- ///
- /// Removes the named , if contained.
- ///
- ///
- /// The name of the property.
- ///
- public void Remove (string propertyName)
- {
- Remove (GetPropertyValue (propertyName));
- }
-
- ///
- /// Modify a object held in this object. Indexed from 0.
- ///
- public void SetPropertyValueAt (PropertyValue pv, int i)
- {
- propertyValuesList [i] = pv;
- }
-
- ///
- /// Return the property value given the name.
- ///
- ///
- /// The property name is checked in a case-insensitive fashion.
- ///
- ///
- /// The name of the property.
- ///
- ///
- /// The property value.
- ///
- public PropertyValue GetPropertyValue (string propertyName)
- {
- string propertyNameLowered = propertyName.ToLower (CultureInfo.CurrentCulture);
- foreach (PropertyValue pv in propertyValuesList)
- {
- if (pv.Name.ToLower(CultureInfo.CurrentCulture).Equals (propertyNameLowered))
- {
- return pv;
- }
- }
- return null;
- }
-
- ///
- /// Does the container of properties contain one of this name.
- ///
- /// The name of the property to search for.
- ///
- /// True if the property is contained in this collection, false otherwise.
- ///
- public bool Contains (string propertyName)
- {
- return GetPropertyValue (propertyName) != null;
- }
-
- ///
- /// Return the difference (changes, additions, but not removals) of
- /// property values between the supplied argument and the values
- /// contained in the collection.
- ///
- /// Another property values collection.
- ///
- /// The collection of property values that are different than the supplied one.
- ///
- public IPropertyValues ChangesSince (IPropertyValues old)
- {
- MutablePropertyValues changes = new MutablePropertyValues ();
- if (old == this)
- {
- return changes;
- }
- // for each property value in this (the newer set)
- foreach (PropertyValue newProperty in propertyValuesList)
- {
- PropertyValue oldProperty = old.GetPropertyValue (newProperty.Name);
- if (oldProperty == null)
- {
- // if there wasn't an old one, add it
- changes.Add (newProperty);
- }
- else if (!oldProperty.Equals (newProperty))
- {
- // it's changed
- changes.Add (newProperty);
- }
- }
- return changes;
- }
-
- ///
- /// Returns an that can iterate
- /// through a collection.
- ///
- ///
- ///
- /// The returned is the
- /// exposed by the
- ///
- /// property.
- ///
+ /// Allows simple manipulation of properties, and provides constructors to
+ /// support deep copy and construction from a number of collection types such as
+ /// and
+ /// .
+ ///
+ ///
+ /// Rod Johnson
+ /// Mark Pollack (.NET)
+ /// Rick Evans (.NET)
+ [Serializable]
+ public class MutablePropertyValues : IPropertyValues
+ {
+ #region Fields
+
+ ///
+ /// The list of objects.
+ ///
+ private IList propertyValuesList = new ArrayList();
+
+ #endregion
+
+ #region Constructor (s) / Destructor
+
+ ///
+ /// Creates a new instance of the
+ /// class.
+ ///
+ ///
+ ///
+ /// The returned instance is initially empty...
+ /// s can be added with the various
+ /// overloaded ,
+ /// ,
+ /// ,
+ /// and
+ /// methods.
+ ///
+ ///
+ ///
+ ///
+ public MutablePropertyValues ()
+ {
+ }
+
+ ///
+ /// Creates a new instance of the
+ /// class.
+ ///
+ ///
+ ///
+ /// Deep copy constructor. Guarantees
+ /// references are independent, although it can't deep copy objects currently
+ /// referenced by individual objects.
+ ///
+ ///
+ public MutablePropertyValues (IPropertyValues other)
+ {
+ if (other != null)
+ {
+ AddAll (other.PropertyValues);
+ }
+ }
+
+ ///
+ /// Creates a new instance of the
+ /// class.
+ ///
+ ///
+ /// The with property values
+ /// keyed by property name, which must be a .
+ ///
+ public MutablePropertyValues (IDictionary map)
+ {
+ AddAll (map);
+ }
+
+ #endregion
+
+ #region Properties
+
+ ///
+ /// Property to retrieve the array of property values.
+ ///
+ public PropertyValue[] PropertyValues
+ {
+ get { return (PropertyValue[]) ArrayList.Adapter (propertyValuesList).ToArray (typeof (PropertyValue)); }
+ }
+
+ #endregion
+
+ #region Methods
+
+ ///
+ /// Overloaded version of Add that takes a property name and a property value.
+ ///
+ ///
+ /// The name of the property.
+ ///
+ ///
+ /// The value of the property.
+ ///
+ public void Add (string propertyName, object propertyValue)
+ {
+ Add (new PropertyValue (propertyName, propertyValue));
+ }
+
+ ///
+ /// Add the supplied object,
+ /// replacing any existing one for the respective property.
+ ///
+ ///
+ /// The object to add.
+ ///
+ public void Add (PropertyValue pv)
+ {
+ for (int i = 0; i < propertyValuesList.Count; ++i)
+ {
+ PropertyValue currentPv = (PropertyValue) propertyValuesList [i];
+ if (currentPv.Name.Equals (pv.Name))
+ {
+ pv = MergeIfRequired(pv, currentPv);
+ propertyValuesList[i] = pv;
+ return ;
+ }
+ }
+ propertyValuesList.Add (pv);
+ }
+
+ ///
+ /// Merges the value of the supplied 'new' with that of
+ /// the current if merging is supported and enabled.
+ ///
+ ///
+ /// The new pv.
+ /// The current pv.
+ /// The possibly merged PropertyValue
+ private PropertyValue MergeIfRequired(PropertyValue newPv, PropertyValue currentPv)
+ {
+ object val = newPv.Value;
+ IMergable mergable = val as IMergable;
+ if (mergable != null)
+ {
+ if (mergable.MergeEnabled)
+ {
+ object merged = mergable.Merge(currentPv.Value);
+ return new PropertyValue(newPv.Name, merged);
+ }
+ }
+ return newPv;
+ }
+
+ ///
+ /// Add all property values from the given
+ /// .
+ ///
+ ///
+ /// The map of property values, the keys of which must be
+ /// s.
+ ///
+ public void AddAll (IDictionary map)
+ {
+ if (map != null)
+ {
+ foreach (string key in map.Keys)
+ {
+ Add (new PropertyValue (key, map [key]));
+ }
+ }
+ }
+
+ ///
+ /// Add all property values from the given
+ /// .
+ ///
+ ///
+ /// The list of s to be added.
+ ///
+ public void AddAll (IList values)
+ {
+ if (values != null)
+ {
+ foreach (PropertyValue value in values)
+ {
+ Add (value);
+ }
+ }
+ }
+
+ ///
+ /// Remove the given , if contained.
+ ///
+ ///
+ /// The to remove.
+ ///
+ public void Remove (PropertyValue pv)
+ {
+ propertyValuesList.Remove (pv);
+ }
+
+ ///
+ /// Removes the named , if contained.
+ ///
+ ///
+ /// The name of the property.
+ ///
+ public void Remove (string propertyName)
+ {
+ Remove (GetPropertyValue (propertyName));
+ }
+
+ ///
+ /// Modify a object held in this object. Indexed from 0.
+ ///
+ public void SetPropertyValueAt (PropertyValue pv, int i)
+ {
+ propertyValuesList [i] = pv;
+ }
+
+ ///
+ /// Return the property value given the name.
+ ///
+ ///
+ /// The property name is checked in a case-insensitive fashion.
+ ///
+ ///
+ /// The name of the property.
+ ///
+ ///
+ /// The property value.
+ ///
+ public PropertyValue GetPropertyValue (string propertyName)
+ {
+ string propertyNameLowered = propertyName.ToLower (CultureInfo.CurrentCulture);
+ foreach (PropertyValue pv in propertyValuesList)
+ {
+ if (pv.Name.ToLower(CultureInfo.CurrentCulture).Equals (propertyNameLowered))
+ {
+ return pv;
+ }
+ }
+ return null;
+ }
+
+ ///
+ /// Does the container of properties contain one of this name.
+ ///
+ /// The name of the property to search for.
+ ///
+ /// True if the property is contained in this collection, false otherwise.
+ ///
+ public bool Contains (string propertyName)
+ {
+ return GetPropertyValue (propertyName) != null;
+ }
+
+ ///
+ /// Return the difference (changes, additions, but not removals) of
+ /// property values between the supplied argument and the values
+ /// contained in the collection.
+ ///
+ /// Another property values collection.
+ ///
+ /// The collection of property values that are different than the supplied one.
+ ///
+ public IPropertyValues ChangesSince (IPropertyValues old)
+ {
+ MutablePropertyValues changes = new MutablePropertyValues ();
+ if (old == this)
+ {
+ return changes;
+ }
+ // for each property value in this (the newer set)
+ foreach (PropertyValue newProperty in propertyValuesList)
+ {
+ PropertyValue oldProperty = old.GetPropertyValue (newProperty.Name);
+ if (oldProperty == null)
+ {
+ // if there wasn't an old one, add it
+ changes.Add (newProperty);
+ }
+ else if (!oldProperty.Equals (newProperty))
+ {
+ // it's changed
+ changes.Add (newProperty);
+ }
+ }
+ return changes;
+ }
+
+ ///
+ /// Returns an that can iterate
+ /// through a collection.
+ ///
+ ///
+ ///
+ /// The returned is the
+ /// exposed by the
+ ///
+ /// property.
+ ///