コード例 #1
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="property"></param>
        public PropertyMetaData(IElementPropertyMetaData property)
        {
            if (property == null)
            {
                throw new ArgumentNullException(nameof(property));
            }

            Name               = property.Name;
            Type               = GetTypeName(property.Type);
            Category           = property.Category;
            DelayExecution     = property.DelayExecution;
            EvidenceProperties = property.EvidenceProperties;

            ItemProperties = null;
            if (property.ItemProperties != null &&
                property.ItemProperties.Count > 0)
            {
                var newList = new List <PropertyMetaData>();
                foreach (var itemProperty in property.ItemProperties)
                {
                    newList.Add(new PropertyMetaData(itemProperty));
                }
                ItemProperties = newList;
            }
        }
コード例 #2
0
        /// <summary>
        /// Get the meta data for the specified property name.
        /// If there are no properties with that name or multiple
        /// properties on different elements then an exception will
        /// be thrown.
        /// </summary>
        /// <param name="propertyName">
        /// The property name to find the meta data for
        /// </param>
        /// <returns>
        /// The meta data associated with the specified property name
        /// </returns>
        /// <exception cref="PipelineDataException">
        /// Thrown if the property name is associated with zero or
        /// multiple elements.
        /// </exception>
        public IElementPropertyMetaData GetMetaDataForProperty(string propertyName)
        {
            IElementPropertyMetaData result = null;

            if (_metaDataByPropertyName.TryGetValue(propertyName, out result) == false)
            {
                // Get any properties that match the supplied name.
                var properties = FlowElements
                                 .SelectMany(e => e.Properties)
                                 .Where(p => p.Name.ToUpperInvariant() == propertyName.ToUpperInvariant());


                // If there is more than one matching property then log an error.
                if (properties.Count() > 1)
                {
                    string message = $"Multiple matches for property '{propertyName}'. " +
                                     $"Flow elements that populate this property are: " +
                                     $"'{string.Join(",", properties.Select(p => p.Element.GetType().Name))}'";
                    _logger.LogError(message);
                    throw new PipelineDataException(message);
                }
                // If there are no matching properties then log an error.
                if (properties.Any() == false)
                {
                    string message = $"Could not find property '{propertyName}'.";
                    _logger.LogError(message);
                    throw new PipelineDataException(message);
                }

                result = properties.Single();
                _metaDataByPropertyName.Add(propertyName, result);
            }

            return(result);
        }
コード例 #3
0
        /// <summary>
        /// Get the meta data for the specified property name.
        /// If there are no properties with that name or multiple
        /// properties on different elements then an exception will
        /// be thrown.
        /// </summary>
        /// <param name="propertyName">
        /// The property name to find the meta data for
        /// </param>
        /// <returns>
        /// The meta data associated with the specified property name
        /// </returns>
        /// <exception cref="PipelineDataException">
        /// Thrown if the property name is associated with zero or
        /// multiple elements.
        /// </exception>
        public IElementPropertyMetaData GetMetaDataForProperty(string propertyName)
        {
            IElementPropertyMetaData result = null;

            if (_metaDataByPropertyName.TryGetValue(propertyName, out result) == false)
            {
                // Get any properties that match the supplied name.
                var properties = FlowElements
                                 .SelectMany(e => e.Properties)
                                 .Where(p => p.Name.ToUpperInvariant() == propertyName.ToUpperInvariant());

                // If there is more than one matching property then
                // throw an exception.
                if (properties.Count() > 1)
                {
                    string message = string.Format(
                        CultureInfo.InvariantCulture,
                        Messages.ExceptionMultipleProperties,
                        propertyName,
                        string.Join(",", properties.Select(p => p.Element.GetType().Name)));
                    throw new PipelineDataException(message);
                }
                // If there are no matching properties then
                // throw an exception.
                if (properties.Any() == false)
                {
                    string message = string.Format(
                        CultureInfo.InvariantCulture,
                        Messages.ExceptionCannotFindProperty,
                        propertyName);
                    throw new PipelineDataException(message);
                }

                result = properties.Single();
                result = _metaDataByPropertyName.GetOrAdd(propertyName, result);
            }

            return(result);
        }