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); }
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); }
/// <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); }