public bool TryResolve(object value, IMessagePropertyValueFactory nest, out MessagePropertyValue result)
        {
            if (value is Interval interval)
            {
                if (interval.HasStart)
                {
                    // ReSharper disable once ConvertIfStatementToConditionalTernaryExpression
                    if (interval.HasEnd)
                    {
                        // start and end
                        result = nest.CreatePropertyValue(new { interval.Start, interval.End }, PropertyResolvingMode.Destructure);
                    }
                    else
                    {
                        // start only
                        result = nest.CreatePropertyValue(new { interval.Start }, PropertyResolvingMode.Destructure);
                    }
                }
                else if (interval.HasEnd)
                {
                    // end only
                    result = nest.CreatePropertyValue(new { interval.End }, PropertyResolvingMode.Destructure);
                }
                else
                {
                    // neither
                    result = new StructureValue(new MessageProperty[0]);
                }

                return(true);
            }

            result = null;
            return(false);
        }
        public bool TryResolve(object value, IMessagePropertyValueFactory nest, out MessagePropertyValue result)
        {
            if (value is DateTimeZone dtz)
            {
                result = nest.CreatePropertyValue(dtz.Id, PropertyResolvingMode.Destructure);
                return(true);
            }

            result = null;
            return(false);
        }
Example #3
0
        public bool TryResolve(object value, IMessagePropertyValueFactory nest, out MessagePropertyValue result)
        {
            if (value is T t)
            {
                Validator?.Invoke(t);

                result = nest.CreatePropertyValue(Pattern.Format(t), PropertyResolvingMode.Default);
                return(true);
            }

            result = null;
            return(false);
        }
Example #4
0
        /// <inheritdoc />
        public bool TryResolve(object value, IMessagePropertyValueFactory nest, out MessagePropertyValue result)
        {
            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }
            if (_conditionFunc(value.GetType()))
            {
                result = nest.CreatePropertyValue(_convertFunc(value), PropertyResolvingMode.Destructure);
                return(true);
            }

            result = null;
            return(false);
        }
Example #5
0
 /// <inheritdoc />
 public bool TryResolve(object value, IMessagePropertyValueFactory nest, out MessagePropertyValue result)
 {
     result = IsBasicReflectionType(value) ? new ScalarValue(value) : null;
     return(result != null);
 }
Example #6
0
 public bool TryResolve(object value, IMessagePropertyValueFactory factory, out MessagePropertyValue result)
 {
     result = value is Delegate @delegate ? new ScalarValue(@delegate) : null;
     return(result != null);
 }