/// <summary> /// Tries to get a specific property value. The bags are search for the property, starting from the topmost bag and iterating to the bag at the bottom. /// </summary> /// <typeparam name="T">Type of the property value to search for.</typeparam> /// <param name="p">The property key.</param> /// <param name="value">On successfull return, this contains the retrieved property value.</param> /// <param name="bag">On successfull return, this contains the property bag from which the property value was retrieved.</param> /// <param name="bagInfo">On successfull return, this contains the information about the property bag from which the property value was retrieved.</param> /// <returns><c>True</c> if the property value could be successfully retrieved; <c>false</c> otherwise.</returns> public bool TryGetValue <T>(PropertyKey <T> p, out T value, out IPropertyBag bag, out PropertyBagInformation bagInfo) { foreach (var tuple in _propertyBags) { if (tuple.Bag.TryGetValue <T>(p, out value)) { bag = tuple.Bag; bagInfo = tuple.BagInformation; return(true); } } value = default(T); bag = null; bagInfo = default(PropertyBagInformation); return(false); }
/// <summary> /// Adds the bag. This bag will be added at the bottom of the hierarchy. /// </summary> /// <param name="description">The information about the bag.</param> /// <param name="bag">The bag to add.</param> public void AddBag(PropertyBagInformation description, PropertyBag bag) { _propertyBags.Add(new PropertyBagWithInformation(description, bag)); }
public PropertyBagWithInformation(PropertyBagInformation bagInformation, IPropertyBag bag) { BagInformation = bagInformation; Bag = bag; }
/// <summary> /// Tries to get a specific property value. The bags are search for the property, starting from the topmost bag and iterating to the bag at the bottom. /// </summary> /// <typeparam name="T">Type of the property value to search for.</typeparam> /// <param name="propName">The property key as string value.</param> /// <param name="value">On successfull return, this contains the retrieved property value.</param> /// <param name="bag">On successfull return, this contains the property bag from which the property value was retrieved.</param> /// <param name="bagInfo">On successfull return, this contains the information about the property bag from which the property value was retrieved.</param> /// <returns><c>True</c> if the property value could be successfully retrieved; <c>false</c> otherwise.</returns> public bool TryGetValue <T>(string propName, out T value, out IPropertyBag bag, out PropertyBagInformation bagInfo) { return(TryGetValue <T>(propName, false, out value, out bag, out bagInfo)); }
public PropertyBagWithInformation(PropertyBagInformation bagInformation, IPropertyBag bag) { BagInformation = bagInformation; Bag = bag; }