public void AssertNotDuplicateOf(IAmField otherConstant) { if (!HasTheSameNameAs(otherConstant)) { if (HasTheSameValueAs(otherConstant)) { var builder = new StringBuilder(); AddNameTo(builder); builder.Append(" is a duplicate of "); otherConstant.AddNameTo(builder); throw new DuplicateConstantException(builder.ToString()); } } }
private bool HasTheSameValueAs(IAmField otherConstant) { return(otherConstant.HasValue(_fieldInfo.GetValue(null))); }
private bool HasTheSameNameAs(IAmField otherConstant) { return(otherConstant.HasName(_fieldInfo.Name)); }