private string GetStringOrDefault(ITypeInformation typeInformation, string shortMemberName, string longMemberName, string resourcePrefix) { var resourceManager = _globalizationService.GetResourceManager(typeInformation); return(resourceManager.GetStringOrDefault(resourcePrefix + longMemberName) ?? resourceManager.GetStringOrDefault(resourcePrefix + shortMemberName)); }
public static IResourceManager GetResourceManager([NotNull] this IGlobalizationService globalizationService, [NotNull] Type type) { ArgumentUtility.CheckNotNull("globalizationService", globalizationService); ArgumentUtility.CheckNotNull("type", type); return(globalizationService.GetResourceManager(TypeAdapter.Create(type))); }
public bool TryGetEnumerationValueDisplayName(Enum value, out string result) { ArgumentUtility.CheckNotNull("value", value); var resourceManager = _globalizationService.GetResourceManager(value.GetType()); return(resourceManager.TryGetString(_memberInformationNameResolver.GetEnumName(value), out result)); }
public bool TryGetExtensibleEnumValueDisplayName(IExtensibleEnum value, out string result) { ArgumentUtility.CheckNotNull("value", value); var resourceType = value.GetValueInfo().DefiningMethod.DeclaringType; var resourceManager = _globalizationService.GetResourceManager(TypeAdapter.Create(resourceType)); return(resourceManager.TryGetString(value.ID, out result)); }
/// <summary> Find the <see cref="IResourceManager"/> for this renderer. </summary> /// <param name="localResourcesType"> /// A type with the <see cref="MultiLingualResourcesAttribute"/> applied to it. Typically an <b>enum</b> or the derived class itself. /// </param> /// <param name="controlResourceManager"> The <see cref="IResourceManager"/> of the control for which the rendering is done. </param> /// <returns>An <see cref="IResourceManager"/> from which all resources for this renderer can be obtained.</returns> protected IResourceManager GetResourceManager(Type localResourcesType, IResourceManager controlResourceManager) { ArgumentUtility.CheckNotNull("localResourcesType", localResourcesType); ArgumentUtility.CheckNotNull("controlResourceManager", controlResourceManager); return(_resourceManagerCache.GetOrCreateValue( Tuple.Create(localResourcesType, controlResourceManager), key => ResourceManagerSet.Create(key.Item2, _globalizationService.GetResourceManager(key.Item1)))); }
public void GetResourceManager() { var fakeResult = MockRepository.GenerateStub <IResourceManager>(); _globalizationServiceMock .Expect(mock => mock.GetResourceManager(Arg <ITypeInformation> .Matches(ti => ((TypeAdapter)ti).Type == typeof(string)))) .Return(fakeResult); var result = _globalizationServiceMock.GetResourceManager(typeof(string)); _globalizationServiceMock.VerifyAllExpectations(); Assert.That(result, Is.SameAs(fakeResult)); }
public BindableObjectGlobalizationService( IGlobalizationService globalizationServices, IMemberInformationGlobalizationService memberInformationGlobalizationService, IEnumerationGlobalizationService enumerationGlobalizationService, IExtensibleEnumGlobalizationService extensibleEnumGlobalizationService) { ArgumentUtility.CheckNotNull("globalizationServices", globalizationServices); ArgumentUtility.CheckNotNull("memberInformationGlobalizationService", memberInformationGlobalizationService); ArgumentUtility.CheckNotNull("enumerationGlobalizationService", enumerationGlobalizationService); ArgumentUtility.CheckNotNull("extensibleEnumGlobalizationService", extensibleEnumGlobalizationService); _resourceManager = new Lazy <IResourceManager> ( () => globalizationServices.GetResourceManager(typeof(ResourceIdentifier)), LazyThreadSafetyMode.ExecutionAndPublication); _memberInformationGlobalizationService = memberInformationGlobalizationService; _enumerationGlobalizationService = enumerationGlobalizationService; _extensibleEnumGlobalizationService = extensibleEnumGlobalizationService; }
public static string GetString(IGlobalizationService service, GlobalResources value) { var resourceManager = service.GetResourceManager(typeof(GlobalResources)); return(resourceManager.GetString(value)); }
protected virtual IResourceManager GetResourceManager(BocListRenderingContext renderingContext) { return(ResourceManagerSet.Create( renderingContext.Control.GetResourceManager(), _globalizationService.GetResourceManager(typeof(ResourceIdentifier)))); }