public void GetPropertyDisplayName_NoResourceFound_ReturnsShortPropertyName() { _serviceStub .Stub( _ => _.TryGetPropertyDisplayName( Arg.Is(_propertyInformationStub), Arg.Is(_typeInformationForResourceResolutionStub), out Arg <string> .Out(null).Dummy)) .Return(false); var result = _serviceStub.GetPropertyDisplayName(_propertyInformationStub, _typeInformationForResourceResolutionStub); Assert.That(result, Is.EqualTo("PropertyName")); }
public string GetString() { var propertyInformation = PropertyInfoAdapter.Create(_propertyRule.GetPropertyInfo()); var typeInformation = TypeAdapter.Create(_typeToValidate); var localizedPropertyName = _globalizationService.GetPropertyDisplayName(propertyInformation, typeInformation); return(localizedPropertyName); }
/// <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)); }