public override bool Equals(object obj) { if (!(obj is CommonField)) { return(false); } CommonField other = (CommonField)obj; if (!(Name == other.Name && CType == other.CType && HasHeading == other.HasHeading)) { return(false); } return(!HasHeading || Fields.SequenceEqual(other.Fields)); }
// create a heading minus one field public CommonHeading Remove(CommonField field) { return(CommonHeading.Create(Fields.Where(f => f.Name != field.Name))); }
// rename a field from old to new public CommonHeading Rename(CommonField field1, CommonField field2) { var fields = Fields.Select(f => (f.Name == field1.Name) ? new CommonField(field2.Name, f.CType) : f); return(CommonHeading.Create(fields)); }
// create a heading plus one field public CommonHeading Append(CommonField field) { return(CommonHeading.Create(Fields.Append(field))); }
public static CommonHeading Create(string heading) { return(Create(CommonField.ToFields(heading))); }