/// <summary> /// Checks equality of two enum schema /// </summary> /// <param name="obj"></param> /// <returns></returns> public override bool Equals(object obj) { if (obj == this) { return(true); } var that = obj as EnumSchema; if (that == null) { return(false); } if (SchemaName.Equals(that.SchemaName) && Count == that.Count) { for (int i = 0; i < Count; i++) { if (!Symbols[i].Equals(that.Symbols[i])) { return(false); } } return(ObjectUtils.AreEqual(that.Props, Props)); } return(false); }
/// <summary> /// Compares equality of two record schemas /// </summary> /// <param name="obj">record schema to compare against this schema</param> /// <returns>true if the two schemas are equal, false otherwise</returns> public override bool Equals(object obj) { if (obj == this) { return(true); } if (obj is RecordSchema) { RecordSchema that = obj as RecordSchema; return(Protect(() => true, () => { if (SchemaName.Equals(that.SchemaName) && Count == that.Count) { for (int i = 0; i < Fields.Count; i++) { if (!Fields[i].Equals(that.Fields[i])) { return false; } } return ObjectUtils.AreEqual(that.Props, Props); } return false; }, that)); } return(false); }
/// <summary> /// Compares two union schema objects /// </summary> /// <param name="obj">union schema object to compare against this schema</param> /// <returns>true if objects are equal, false otherwise</returns> public override bool Equals(object obj) { if (obj == this) { return(true); } if (!(obj is UnionSchema)) { return(false); } var that = obj as UnionSchema; if (that.Count == Count) { for (int i = 0; i < Count; i++) { if (!that[i].Equals(this[i])) { return(false); } } return(ObjectUtils.AreEqual(that.Props, Props)); } return(false); }
public void ObjectUtils_testAreEqual2() { InnerObject obj1 = new InnerObject("Foo"); InnerObject obj2 = new InnerObject("Foo"); bool result = ObjectUtils.AreEqual(obj1, obj2); Assert.IsNotNull(result); Assert.AreEqual(true, result); Assert.AreEqual("True", result.ToString()); }
public void ObjectUtils_testAreEqual1() { object obj1 = new object(); object obj2 = new object(); bool result = ObjectUtils.AreEqual(obj1, obj2); Assert.IsNotNull(result); Assert.AreEqual(false, result); Assert.AreEqual("False", result.ToString()); }
public override bool Equals(object obj) { if (this == obj) { return(true); } var other = obj as GenericRecord; if (other == null) { return(false); } return(Schema.Equals(other.Schema) && ObjectUtils.AreEqual(_contents, other._contents)); }
/// <summary> /// Function to compare equality of two primitive schemas /// </summary> /// <param name="obj">other primitive schema</param> /// <returns>true two schemas are equal, false otherwise</returns> public override bool Equals(object obj) { if (this == obj) { return(true); } var that = obj as PrimitiveSchema; if (that == null) { return(false); } return(Type == that.Type && ObjectUtils.AreEqual(that.Props, Props)); }
/// <summary> /// Compares equality of two map schemas /// </summary> /// <param name="obj">map schema to compare against this schema</param> /// <returns>true if two schemas are equal, false otherwise</returns> public override bool Equals(object obj) { if (this == obj) { return(true); } var that = obj as MapSchema; if (that == null) { return(false); } return(ValueSchema.Equals(that.ValueSchema) && ObjectUtils.AreEqual(that.Props, Props)); }
/// <summary> /// Function to compare equality of two array schemas /// </summary> /// <param name="obj">other array schema</param> /// <returns>true two schemas are equal, false otherwise</returns> public override bool Equals(object obj) { if (this == obj) { return(true); } if (obj is ArraySchema) { var that = obj as ArraySchema; if (ItemSchema.Equals(that.ItemSchema)) { return(ObjectUtils.AreEqual(that.Props, Props)); } } return(false); }
/// <summary> /// Add or update the property in the underlying config depending on if it exists /// </summary> /// <param name="name"></param> /// <param name="newValue"></param> /// <param name="config"></param> public void AddOrChangeProperty(string name, object newValue, IConfiguration config) { // We do not want to abort the operation due to failed validation on one property try { if (!config.ContainsKey(name)) { m_Log.DebugFormat("Adding property key [{0}], value [{1}]", name, newValue); config.AddProperty(name, newValue); return; } var oldValue = config.GetProperty(name); if (newValue != null) { object newValueArray; if (oldValue is IList && config.ListDelimiter != '\0') { newValueArray = new ArrayList(); var values = ((string)newValue).Split(config.ListDelimiter).Select(v => v.Trim()).Where(v => v.Length != 0); foreach (var value in values) { ((IList)newValueArray).Add(value); } } else { newValueArray = newValue; } if (!ObjectUtils.AreEqual(newValueArray, oldValue)) { m_Log.DebugFormat("Updating property key [{0}], value [{1}]", name, newValue); config.SetProperty(name, newValue); } } else if (oldValue != null) { m_Log.DebugFormat("nulling out property key [{0}]", name); config.SetProperty(name, null); } } catch (ValidationException e) { m_Log.Warn("Validation failed for property " + name, e); } }
public override bool Equals(Object obj) { if (obj == this) { return(true); } if (obj == null) { return(false); } if (!(obj is MethodParameter)) { return(false); } MethodParameter other = (MethodParameter)obj; return(ObjectUtils.AreEqual(this.GetName(), other.GetName())); }
/// <summary> /// Compares two field objects /// </summary> /// <param name="obj">field to compare with this field</param> /// <returns>true if two fields are equal, false otherwise</returns> public override bool Equals(object obj) { if (obj == this) { return(true); } var that = obj as Field; if (that == null) { return(false); } return(ObjectUtils.AreEqual(that.Name, Name) && that.Pos == Pos && ObjectUtils.AreEqual(that.Documentation, Documentation) && ObjectUtils.AreEqual(that.Ordering, Ordering) && JTokenComparer.Equals(that.DefaultValue, DefaultValue) && that.Schema.Equals(Schema) && ObjectUtils.AreEqual(that.Props, Props)); }
override public bool Equals(Object obj) { if (obj == this) { return(true); } if (obj == null) { return(false); } if (!(obj is CategoryParameter)) { return(false); } CategoryParameter other = (CategoryParameter)obj; return(ObjectUtils.AreEqual(this.getType(), other.getType()) && ObjectUtils.AreEqual(this.GetName(), other.GetName())); }
/// <summary> /// Determines whether the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>. /// </summary> /// <returns> /// true if the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>; otherwise, false. /// </returns> /// <param name="obj">The object to compare with the current object. </param> public override bool Equals(object obj) { if (obj == this) { return(true); } var that = obj as Schema; if (that == null) { return(false); } if (Type != that.Type) { return(false); } return(ObjectUtils.AreEqual(Props, that.Props)); }
public override bool Equals(Object obj) { if (obj == this) { return(true); } if (obj == null) { return(false); } if (!(obj is ExtendedParameter)) { return(false); } ExtendedParameter other = (ExtendedParameter)obj; return(ObjectUtils.AreEqual(this.getType(), other.getType()) && ObjectUtils.AreEqual(this.GetName(), other.GetName()) && ObjectUtils.AreEqual(this.getAttributes(), other.getAttributes())); }