private static string GetDescription( [NotNull] IField field, [NotNull] ReservedName reservedName, [CanBeNull] FieldSpecification validNameFieldSpecification, out IssueCode issueCode) { var sb = new StringBuilder(); sb.AppendFormat("Field name '{0}' corresponds to a reserved name", field.Name); if (StringUtils.IsNotEmpty(reservedName.Reason)) { sb.AppendFormat(". Reason: {0}", reservedName.Reason); } if (StringUtils.IsNotEmpty(reservedName.CorrectName)) { sb.AppendFormat(". Valid name: {0}", reservedName.CorrectName); } if (validNameFieldSpecification != null) { foreach ( KeyValuePair <string, IssueCode> pair in validNameFieldSpecification.GetIssues(field, null)) { sb.AppendFormat(". {0}", pair.Key); } } issueCode = Codes[Code.FieldNameIsReserved]; return(sb.ToString()); }
public void SaveReservedName(ReservedName ReservedName) { if (ReservedName.Id == 0) { context.ReservedNames.Add(ReservedName); } else { var editMe = context.ReservedNames.Find(ReservedName.Id); if (editMe != null) { // dbEntry.Name = ReservedNames.Name; // dbEntry.Message = ReservedNames.Message; // dbEntry.TimeStamp = ReservedNames.TimeStamp; } } context.SaveChanges(); }
private FieldSpecification GetValidNameFieldSpecification( [NotNull] ReservedName reservedName) { if (reservedName.CorrectName == null) { return(null); } if (_fieldSpecificationsByName == null) { _fieldSpecificationsByName = GetFieldSpecifications().ToDictionary( fieldSpecification => fieldSpecification.FieldName, StringComparer.OrdinalIgnoreCase); } FieldSpecification result; return(_fieldSpecificationsByName.TryGetValue(reservedName.CorrectName, out result) ? result : null); }