/// <summary> /// Get the meta-data for values from this profile for the /// specified property. /// </summary> /// <param name="propertyName"> /// The name of the property to get values for. /// </param> /// <returns> /// The value meta-data for the specified property on this profile. /// </returns> public IEnumerable <IValueMetaData> GetValues(string propertyName) { using (var values = _engine.MetaData.getValuesForProfile(_source)) { for (uint i = 0; i < values.getSize(); i++) { #pragma warning disable CA2000 // Dispose objects before losing scope // This instance will be returned by this method so // we don't want to dispose of it. var value = new ValueMetaData(_engine, values.getByIndex(i)); #pragma warning restore CA2000 // Dispose objects before losing scope using (var valueProperty = value.GetProperty()) { if (propertyName.Equals(valueProperty.Name, StringComparison.OrdinalIgnoreCase)) { yield return(value); } else { value.Dispose(); } } } } }
/// <summary> /// Get the meta-data for the specified property and value from /// this profile. /// </summary> /// <param name="propertyName"> /// The name of the property to get the meta-data for. /// </param> /// <param name="valueName"> /// The value to get the meta-data for. /// </param> /// <returns> /// The value meta-data for the specified value if it exists /// on this profile. /// </returns> public IValueMetaData GetValue(string propertyName, string valueName) { IValueMetaData result = null; using (var values = _engine.MetaData.getValuesForProfile(_source)) { using (var key = new ValueMetaDataKeySwig( propertyName, valueName)) { #pragma warning disable CA2000 // Dispose objects before losing scope // The ValueMetaDataSwig instance is used and disposed // by the ValueMetaData object. var value = values.getByKey(key); #pragma warning restore CA2000 // Dispose objects before losing scope if (value != null) { result = new ValueMetaData(_engine, value); } } } return(result); }