/// <summary> /// Sets the <see cref="PropertyAccessMode" /> to use for this property. /// </summary> /// <param name="property"> The property for which to set the access mode. </param> /// <param name="propertyAccessMode"> The <see cref="PropertyAccessMode" />, or null to clear the mode set.</param> /// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param> public static void SetPropertyAccessMode( [NotNull] this IConventionPropertyBase property, PropertyAccessMode?propertyAccessMode, bool fromDataAnnotation = false) { Check.NotNull(property, nameof(property)); property.SetOrRemoveAnnotation(CoreAnnotationNames.PropertyAccessMode, propertyAccessMode, fromDataAnnotation); }
private static FieldInfo TryMatch( KeyValuePair <string, FieldInfo>[] array, string prefix, string middle, string suffix, IConventionPropertyBase propertyBase, FieldInfo existingMatch, Type entityClrType, string propertyName) { var index = PrefixBinarySearch(array, prefix, 0, array.Length - 1); if (index == -1) { return(existingMatch); } var typeInfo = propertyBase?.ClrType; var length = prefix.Length + middle.Length + suffix.Length; var currentValue = array[index]; while (true) { if (currentValue.Key.Length == length && currentValue.Key.EndsWith(suffix, StringComparison.Ordinal) && currentValue.Key.IndexOf(middle, prefix.Length, StringComparison.Ordinal) == prefix.Length) { var newMatch = typeInfo == null ? currentValue.Value : (typeInfo.IsCompatibleWith(currentValue.Value.FieldType) ? currentValue.Value : null); if (newMatch != null) { if (existingMatch != null && newMatch != existingMatch) { propertyBase.SetOrRemoveAnnotation( CoreAnnotationNames.AmbiguousField, CoreStrings.ConflictingBackingFields( propertyName, entityClrType.ShortDisplayName(), existingMatch.Name, newMatch.Name)); return(null); } return(newMatch); } return(existingMatch); } if (++index == array.Length) { return(existingMatch); } currentValue = array[index]; if (!currentValue.Key.StartsWith(prefix, StringComparison.Ordinal)) { return(existingMatch); } } }