/// <summary> /// Gets the localized display name of a property. /// </summary> /// <param name="propertyInformation">The <see cref="IPropertyInformation"/> for which to lookup the resource.</param> /// <param name="typeInformationForResourceResolution">The <see cref="ITypeInformation"/> providing the resources.</param> /// <returns>The localized display name.</returns> public string GetPropertyDisplayName(IPropertyInformation propertyInformation, ITypeInformation typeInformationForResourceResolution) { ArgumentUtility.CheckNotNull("propertyInformation", propertyInformation); ArgumentUtility.CheckNotNull("typeInformationForResourceResolution", typeInformationForResourceResolution); var mixinIntroducedPropertyInformation = propertyInformation as MixinIntroducedPropertyInformation; if (mixinIntroducedPropertyInformation != null) { // Note: this is only needed until there is support for interfaces in object binding, // or at least, until PropertyInfoAdapter can perform the FindIntefaceDeclaration lookup fast. // Then, the MultiLingualResourcesBasedMemberInformationGlobalizationService will be able to implement the look of the localization // from the class-qualified name, then the interfaces-qualified names, and finally, the unqualified name. var interfaceImplementationPropertyInfo = mixinIntroducedPropertyInformation.InterfaceImplementationPropertyInfo; string displayNameFromInterface; if (_memberInformationGlobalizationService.TryGetPropertyDisplayName( interfaceImplementationPropertyInfo.DeclarationPropertyInfo, typeInformationForResourceResolution, out displayNameFromInterface)) { return(displayNameFromInterface); } string displayNameFromImplementation; if (_memberInformationGlobalizationService.TryGetPropertyDisplayName( interfaceImplementationPropertyInfo.ImplementationPropertyInfo, typeInformationForResourceResolution, out displayNameFromImplementation)) { return(displayNameFromImplementation); } } return(_memberInformationGlobalizationService.GetPropertyDisplayName( propertyInformation.GetOriginalDeclaration(), typeInformationForResourceResolution)); }
/// <summary> /// Checks whether a human-readable property name of the spefified reflection object exists. /// </summary> /// <param name="memberInformationGlobalizationService"> /// The <see cref="IMemberInformationGlobalizationService"/> to use during the lookup. Must not be <see langword="null" />. /// </param> /// <param name="propertyInformation"> /// The <see cref="IPropertyInformation"/> that defines the property name for the resource lookup. Must not be <see langword="null" />. /// </param> /// <param name="typeInformationForResourceResolution"> /// The <see cref="ITypeInformation"/> that should be used for the resource resolution. Must not be <see langword="null" />. /// </param> /// <returns><see langword="true" /> if a resource could be found.</returns> public static bool ContainsPropertyDisplayName( [NotNull] this IMemberInformationGlobalizationService memberInformationGlobalizationService, [NotNull] IPropertyInformation propertyInformation, [NotNull] ITypeInformation typeInformationForResourceResolution) { ArgumentUtility.CheckNotNull("memberInformationGlobalizationService", memberInformationGlobalizationService); ArgumentUtility.CheckNotNull("propertyInformation", propertyInformation); ArgumentUtility.CheckNotNull("typeInformationForResourceResolution", typeInformationForResourceResolution); string resourceValue; return(memberInformationGlobalizationService.TryGetPropertyDisplayName( propertyInformation, typeInformationForResourceResolution, out resourceValue)); }
public static string GetPropertyDisplayNameOrDefault( this IMemberInformationGlobalizationService memberInformationGlobalizationService, IPropertyInformation propertyInformation, ITypeInformation typeInformationForResourceResolution) { ArgumentUtility.CheckNotNull("memberInformationGlobalizationService", memberInformationGlobalizationService); ArgumentUtility.CheckNotNull("propertyInformation", propertyInformation); ArgumentUtility.CheckNotNull("typeInformationForResourceResolution", typeInformationForResourceResolution); string resourceValue; if (memberInformationGlobalizationService.TryGetPropertyDisplayName( propertyInformation, typeInformationForResourceResolution, out resourceValue)) { return(resourceValue); } return(null); }