/// <summary> /// Gets the values associated with the property. Can return null. /// </summary> /// <param name="property"> /// The property whose values are required. /// </param> /// <para> /// The <see cref="Values"/> type is used to return values so that /// helper methods like ToBool can be used to convert the response to /// a boolean. /// </para> /// <returns> /// Array of the values associated with the property, or null if the /// property does not exist. /// </returns> public Values this[Property property] { get { Values values = null; // A read / write upgradable guard could be used in the future // should the performance of GetPropertyValueIndexes prove too // slow in the future. The use of a lock on the dictionary // ensures that this implementation is thread safe. lock (PropertyIndexToValues) { if (PropertyIndexToValues.TryGetValue( property.Index, out values) == false) { values = new Entities.Values( property, GetPropertyValueIndexes(property)); PropertyIndexToValues.Add(property.Index, values); } } return(values); } }
/// <summary> /// Gets the values associated with the property. /// </summary> /// <param name="property"> /// The property whose values are required. /// </param> /// <returns> /// Value(s) associated with the property, or null if the property /// does not exist. /// </returns> public Values this[Property property] { get { Values values = null; if (PropertyIndexToValues.TryGetValue(property.Index, out values) == false) { lock (this) { if (PropertyIndexToValues.TryGetValue(property.Index, out values) == false) { values = GetPropertyValues(property); PropertyIndexToValues.Add(property.Index, values); } } } return(values); } }