/// <summary> /// Get all element data AspectPropertyValues that match the specified predicate /// </summary> /// <param name="predicate"> /// If a property passed to this function returns true then it will /// be included in the results /// </param> /// <returns> /// All the element data AspectPropertyValues that match the predicate /// </returns> /// <exception cref="PipelineException"> /// Thrown if this FlowData instance has not been processed yet. /// </exception> public IEnumerable <KeyValuePair <string, object> > GetWhere( Func <IElementPropertyMetaData, bool> predicate) { var data = _data.AsStringKeyDictionary(); foreach (var element in PipelineInternal.FlowElements .Where(e => data.ContainsKey(e.ElementDataKey))) { var elementData = data[element.ElementDataKey] as IElementData; if (elementData != null) { var elementDataDictionary = elementData.AsDictionary(); foreach (var property in element.Properties.Where(predicate).Where(i => i.Available && // Check if the property is actually present in // the element data before trying to access it. elementDataDictionary.ContainsKey(i.Name))) { #pragma warning disable CA1308 // Normalize strings to uppercase // Pipeline specification is for keys to be lower-case. yield return(new KeyValuePair <string, object>( element.ElementDataKey + "." + property.Name.ToLowerInvariant(), elementDataDictionary[property.Name.ToLowerInvariant()])); #pragma warning restore CA1308 // Normalize strings to uppercase } } } }
/// <summary> /// Get the <see cref="IElementData"/> instance containing data /// populated by the specified element. /// </summary> /// <param name="elementDataKey"> /// The name of the element to get data from. /// </param> /// <returns> /// An <see cref="IElementData"/> instance containing the data. /// </returns> /// <exception cref="ArgumentNullException"> /// Thrown if the supplied data key is null /// </exception> /// <exception cref="PipelineException"> /// Thrown if this FlowData instance has not been processed yet. /// </exception> public IElementData Get(string elementDataKey) { if (_processed == false) { throw new PipelineException(Messages.ExceptionFlowDataNotYetProcessed); } if (elementDataKey == null) { throw new ArgumentNullException(nameof(elementDataKey)); } return(_data.AsStringKeyDictionary()[elementDataKey] as IElementData); }