public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { if (reader.TokenType == JsonToken.Null) { return(null); } IncludeExclude termsInclude; switch (reader.TokenType) { case JsonToken.StartArray: termsInclude = new IncludeExclude(serializer.Deserialize <IEnumerable <string> >(reader)); break; case JsonToken.String: termsInclude = new IncludeExclude((string)reader.Value); break; default: throw new JsonSerializationException( $"Unexpected token {reader.TokenType} when deserializing {nameof(IncludeExclude)}"); } return(termsInclude); }
/// <summary> /// Returns true if SapInventoryVariant instances are equal /// </summary> /// <param name="other">Instance of SapInventoryVariant to be compared</param> /// <returns>Boolean</returns> public bool Equals(SapInventoryVariant other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( InventoryVariantName == other.InventoryVariantName || InventoryVariantName != null && InventoryVariantName.Equals(other.InventoryVariantName) ) && ( ColumnName == other.ColumnName || ColumnName != null && ColumnName.Equals(other.ColumnName) ) && ( Value == other.Value || Value != null && Value.Equals(other.Value) ) && ( ValueRange == other.ValueRange || ValueRange != null && ValueRange.Equals(other.ValueRange) ) && ( Operator == other.Operator || Operator != null && Operator.Equals(other.Operator) ) && ( IncludeExclude == other.IncludeExclude || IncludeExclude != null && IncludeExclude.Equals(other.IncludeExclude) ) && ( SourceSystem == other.SourceSystem || SourceSystem != null && SourceSystem.Equals(other.SourceSystem) )); }
public void Can_include_nested_only() { var dto = new IncludeExclude { Id = 1234, Name = "TEST", Obj = new Exclude { Id = 1, Key = "Value" } }; using (var config = JsConfig.BeginScope()) { config.ExcludePropertyReferences = new[] { "Exclude.Id", "IncludeExclude.Id", "IncludeExclude.Name" }; Assert.That(dto.ToJson(), Is.EqualTo("{\"Obj\":{\"Key\":\"Value\"}}")); Assert.That(dto.ToJsv(), Is.EqualTo("{Obj:{Key:Value}}")); } Assert.That(JsConfig.ExcludePropertyReferences, Is.EqualTo(null)); }
public void Exclude_all_nested() { var dto = new IncludeExclude { Id = 1234, Name = "TEST", Obj = new Exclude { Id = 1, Key = "Value" } }; using (var config = JsConfig.BeginScope()) { config.ExcludePropertyReferences = new[] { "Exclude.Id", "Exclude.Key" }; Assert.AreEqual(2, config.ExcludePropertyReferences.Length); var actual = dto.ToJson(); Assert.That(actual, Is.EqualTo("{\"Id\":1234,\"Name\":\"TEST\",\"Obj\":{}}")); Assert.That(dto.ToJsv(), Is.EqualTo("{Id:1234,Name:TEST,Obj:{}}")); } }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (InventoryVariantName != null) { hashCode = hashCode * 59 + InventoryVariantName.GetHashCode(); } if (ColumnName != null) { hashCode = hashCode * 59 + ColumnName.GetHashCode(); } if (Value != null) { hashCode = hashCode * 59 + Value.GetHashCode(); } if (ValueRange != null) { hashCode = hashCode * 59 + ValueRange.GetHashCode(); } if (Operator != null) { hashCode = hashCode * 59 + Operator.GetHashCode(); } if (IncludeExclude != null) { hashCode = hashCode * 59 + IncludeExclude.GetHashCode(); } if (SourceSystem != null) { hashCode = hashCode * 59 + SourceSystem.GetHashCode(); } return(hashCode); } }
public IncludeExcludeRules(IncludeExclude defaultValue) { _default = defaultValue; }
/// <summary> /// Constructor for InclusionExclusionRule /// </summary> /// <param name="incEx">Include or Exclude</param> /// <param name="rule">Taxonomy Tree Rule. Tree nodes are separated with dots.</param> public InclusionExclusionRule(IncludeExclude incEx, string rule) { _incEx = incEx; _rule = rule; }