public override ScalarValue GetValueToEncode(ScalarValue value, ScalarValue priorValue, Scalar field) { if (priorValue == null) { return(value); } if (value == null) { if (!field.IsOptional) { throw new ArgumentNullException("value"); } if (priorValue == ScalarValue.Undefined && field.DefaultValue.IsUndefined) { return(null); } return(ScalarValue.Null); } if (priorValue.IsUndefined) { return(value.Equals(field.DefaultValue) ? null : value); } var inc = ((NumericValue)priorValue).Increment(); return(!value.Equals(inc) ? value : null); }
public override ScalarValue GetValueToEncode(ScalarValue value_Renamed, ScalarValue priorValue, Scalar field) { if (priorValue == null) { return(value_Renamed); } if (value_Renamed == null) { if (field.Optional) { if (priorValue == ScalarValue.UNDEFINED && field.DefaultValue.Undefined) { return(null); } return(ScalarValue.NULL); } throw new ArgumentException(); } if (priorValue.Undefined) { if (value_Renamed.Equals(field.DefaultValue)) { return(null); } return(value_Renamed); } if (!value_Renamed.Equals(((NumericValue)priorValue).Increment())) { return(value_Renamed); } return(null); }
protected internal override ScalarValue GetValueToEncode(ScalarValue value_Renamed, ScalarValue priorValue, ScalarValue defaultValue) { if ((priorValue == ScalarValue.UNDEFINED) && value_Renamed.Equals(defaultValue)) { return(null); } return((value_Renamed.Equals(priorValue))?null:value_Renamed); }
protected override ScalarValue GetValueToEncode(ScalarValue value, ScalarValue priorValue, ScalarValue defaultValue) { if (ScalarValue.Undefined.Equals(priorValue) && value.Equals(defaultValue)) { return(null); } return(value.Equals(priorValue) ? null : value); }
private Func <LogEvent, bool> WithProperty(string propertyName, object scalarValue) { if (propertyName == null) { throw new ArgumentNullException($"{propertyName}"); } var scalar = new ScalarValue(scalarValue); return(e => { if (!e.Properties.TryGetValue(propertyName, out var propertyValue)) { return false; } if (propertyValue is StructureValue stValue) { var value = stValue.Properties.FirstOrDefault(cc => cc.Name == "Id"); var result = scalar.Equals(value?.Value); return result; } return propertyValue.Equals(scalar); }); }
public override ScalarValue GetValueToEncode(ScalarValue value_Renamed, ScalarValue priorValue, Scalar field) { if (value_Renamed == null) { return(field.DefaultValue.Undefined ? null : ScalarValue.NULL); } return(value_Renamed.Equals(field.DefaultValue)?null:value_Renamed); }
public override ScalarValue GetValueToEncode(ScalarValue value_Renamed, ScalarValue priorValue, Scalar field) { if (value_Renamed == null) { return field.DefaultValue.Undefined ? null : ScalarValue.NULL; } return value_Renamed.Equals(field.DefaultValue)?null:value_Renamed; }
protected internal override ScalarValue GetValueToEncode(ScalarValue value_Renamed, ScalarValue priorValue, ScalarValue defaultValue) { if ((priorValue == ScalarValue.UNDEFINED) && value_Renamed.Equals(defaultValue)) { return null; } return (value_Renamed.Equals(priorValue))?null:value_Renamed; }
/// <summary> /// Matches events with the specified property value. /// </summary> /// <param name="propertyName">The name of the property to match.</param> /// <param name="scalarValue">The property value to match; must be a scalar type. /// Null is allowed.</param> /// <returns>A predicate for matching events.</returns> public static Func <LogEvent, bool> WithProperty(string propertyName, object scalarValue) { if (propertyName == null) { throw new ArgumentNullException(nameof(propertyName)); } var scalar = new ScalarValue(scalarValue); return(e => { return e.Properties.TryGetValue(propertyName, out var propertyValue) && scalar.Equals(propertyValue); }); }
/// <summary> /// Filter log events to include only those that has EventId with specified id /// </summary> /// <param name="configuration">configuration</param> /// <param name="id">The id of EventId</param> /// <returns>LoggerConfiguration</returns> public static LoggerConfiguration FilterByEventId(this LoggerFilterConfiguration configuration, int id) { var scalarValue = new ScalarValue(id); return(configuration.ByIncludingOnly(logEvent => { if (logEvent.Properties.TryGetValue(nameof(EventId), out var propertyValue) && propertyValue is StructureValue structureValue) { var idValue = structureValue.Properties.Where(cc => cc.Name == nameof(EventId.Id)).FirstOrDefault(); return scalarValue.Equals(idValue.Value); } return false; })); }
public static Func <LogEvent, bool> WithProperty(string propertyName, object scalarValue) { if (propertyName == null) { throw new ArgumentNullException("propertyName"); } var scalar = new ScalarValue(scalarValue); return(e => { if (e.Properties.TryGetValue(propertyName, out var propertyValue)) { if (propertyValue is StructureValue stValue) { var value = stValue.Properties.Where(cc => cc.Name == "Id").FirstOrDefault(); bool result = scalar.Equals(value.Value); return result; } } return false; }); }
private bool Equals(TwinValue other) { return(first.Equals(other.first) && second.Equals(other.second)); }
internal bool Equals(Scalar other) { return(name.Equals(other.name) && type.Equals(other.type) && typeCodec.Equals(other.typeCodec) && operator_Renamed.Equals(other.operator_Renamed) && operatorCodec.Equals(other.operatorCodec) && initialValue.Equals(other.initialValue) && dictionary.Equals(other.dictionary)); }
protected override ScalarValue GetValueToEncode(ScalarValue value, ScalarValue priorValue, ScalarValue defaultValue) { if (ScalarValue.Undefined.Equals(priorValue) && value.Equals(defaultValue)) return null; return value.Equals(priorValue) ? null : value; }
public override ScalarValue GetValueToEncode(ScalarValue value, ScalarValue priorValue, Scalar field) { return(value == null ? (field.DefaultValue.IsUndefined ? null : ScalarValue.Null) : (value.Equals(field.DefaultValue) ? null : value)); }
public override ScalarValue GetValueToEncode(ScalarValue value, ScalarValue priorValue, Scalar field) { return value == null ? (field.DefaultValue.IsUndefined ? null : ScalarValue.Null) : (value.Equals(field.DefaultValue) ? null : value); }
public override ScalarValue GetValueToEncode(ScalarValue value, ScalarValue priorValue, Scalar field) { if (priorValue == null) return value; if (value == null) { if (!field.IsOptional) throw new ArgumentNullException("value"); if (priorValue == ScalarValue.Undefined && field.DefaultValue.IsUndefined) return null; return ScalarValue.Null; } if (priorValue.IsUndefined) return value.Equals(field.DefaultValue) ? null : value; var inc = ((NumericValue) priorValue).Increment(); return !value.Equals(inc) ? value : null; }
public override ScalarValue GetValueToEncode(ScalarValue value_Renamed, ScalarValue priorValue, Scalar field) { if (priorValue == null) { return value_Renamed; } if (value_Renamed == null) { if (field.Optional) { if (priorValue == ScalarValue.UNDEFINED && field.DefaultValue.Undefined) { return null; } return ScalarValue.NULL; } throw new ArgumentException(); } if (priorValue.Undefined) { if (value_Renamed.Equals(field.DefaultValue)) { return null; } return value_Renamed; } if (!value_Renamed.Equals(((NumericValue) priorValue).Increment())) { return value_Renamed; } return null; }