示例#1
0
        public bool Check(IOutput console, IPropertyProvider propertyProvider, IPropertyStore propertyStore, ProcessorItem item)
        {
            propertyProvider.Begin();

            bool result = conditions.All(x => x.Evaluate(console, propertyProvider, propertyStore, item));

            propertyProvider.End();

            return(result);
        }
示例#2
0
        /// <summary>
        /// Creates a string formatted using this template, with the values provided by the property providers.
        /// </summary>
        public string Make(IPropertyProvider propertyProvider, IPropertyStore propertyStore, ProcessorItem item)
        {
            StringBuilder sb = new StringBuilder();

            propertyProvider.Begin();
            {
                foreach (FormatToken token in tokens)
                {
                    if (token.IsText)
                    {
                        sb.Append(token.Value);
                    }
                    else
                    {
                        PropertyItem property = token.GetProperty(propertyProvider, propertyStore, item);
                        string       text     = "NA";

                        if (property == null)
                        {
                            sb.Append(text);
                        }
                        else if (property.IsNumeric)
                        {
                            double value = unitConverter.ConvertPropertyValue(property, token.Unit);

                            text = value.ToString(token.DecimalFormat, CultureInfo.InvariantCulture);
                        }
                        else
                        {
                            text = property.Value.ToString();
                        }

                        sb.Append(text);
                    }
                }
            }
            propertyProvider.End();

            return(sb.ToString());
        }