public IResourceManager GetResourceManager(Type objectType, bool includeHierarchy) { ArgumentUtility.CheckNotNull("objectType", objectType); ArgumentUtility.CheckNotNull("includeHierarchy", includeHierarchy); var targetType = MixinTypeUtility.GetUnderlyingTargetType(objectType); var result = s_resolver.Value.Resolve(targetType); var mixinResourceManager = s_mixinGlobalizationService.Value.GetResourceManager(TypeAdapter.Create(targetType)); if (includeHierarchy) { if (result.IsNull && mixinResourceManager.IsNull) { throw new ResourceException(string.Format("Type {0} and its base classes do not define a resource attribute.", objectType.FullName)); } return(ResourceManagerSet.Create(result.DefinedResourceManager, mixinResourceManager, result.InheritedResourceManager)); } if (result.IsNull && mixinResourceManager.IsNull) { throw new ResourceException(string.Format("Type {0} and its base classes do not define a resource attribute.", objectType.FullName)); } if (result.DefinedResourceManager.IsNull && !mixinResourceManager.IsNull) { return(mixinResourceManager); } if (result.DefinedResourceManager.IsNull) // we already know there is a resource defined on a base-type so no additional checks are required. { return(MultiLingualResources.GetResourceManager(targetType.BaseType, false)); } return(ResourceManagerSet.Create(result.DefinedResourceManager, mixinResourceManager)); }
/// <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)))); }
/// <summary> Find the <see cref="IResourceManager"/> for this control. </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> /// <returns>An <see cref="IResourceManager"/> from which all resources for this control can be obtained.</returns> protected IResourceManager GetResourceManager(Type localResourcesType) { ArgumentUtility.CheckNotNull("localResourcesType", localResourcesType); return(_resourceManagerCache.GetOrCreateValue( Tuple.Create(localResourcesType, NamingContainer), key => { var localResourceManager = GlobalizationService.GetResourceManager(localResourcesType); var namingContainerResourceManager = ResourceManagerUtility.GetResourceManager(NamingContainer, true); return ResourceManagerSet.Create(namingContainerResourceManager, localResourceManager); })); }
private static IResourceManager CombineResourceManagers(IResourceManager definedResourceManager, IResourceManager inheritedResourceManager) { if (definedResourceManager.IsNull && inheritedResourceManager.IsNull) { return(NullResourceManager.Instance); } if (definedResourceManager.IsNull) { return(inheritedResourceManager); } if (inheritedResourceManager.IsNull) { return(definedResourceManager); } return(ResourceManagerSet.Create(definedResourceManager, inheritedResourceManager)); }
/// <summary> /// Find the <see cref="IResourceManager"/> for this <see cref="ValidationStateViewer"/>. /// </summary> /// <returns></returns> protected IResourceManager GetResourceManager() { // Provider has already been identified. if (_cachedResourceManager != null) { return(_cachedResourceManager); } // Get the resource managers IResourceManager localResourceManager = GlobalizationService.GetResourceManager(typeof(ResourceIdentifier)); IResourceManager namingContainerResourceManager = ResourceManagerUtility.GetResourceManager(NamingContainer, true); _cachedResourceManager = ResourceManagerSet.Create(namingContainerResourceManager, localResourceManager); return(_cachedResourceManager); }
/// <summary> Find the <see cref="IResourceManager"/> for this control info. </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> protected IResourceManager GetResourceManager(Type localResourcesType) { ArgumentUtility.CheckNotNull("localResourcesType", localResourcesType); // Provider has already been identified. if (_cachedResourceManager != null) { return(_cachedResourceManager); } // Get the resource managers var localResourceManager = GlobalizationService.GetResourceManager(localResourcesType); var pageResourceManager = ResourceManagerUtility.GetResourceManager(_page.WrappedInstance, true); _cachedResourceManager = ResourceManagerSet.Create(pageResourceManager, localResourceManager); return(_cachedResourceManager); }
/// <summary> Find the <see cref="IResourceManager"/> for this control. </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> protected IResourceManager GetResourceManager(Type localResourcesType) { //Remotion.Utilities.ArgumentUtility.CheckNotNull ("localResourcesType", localResourcesType); // Provider has already been identified. if (_cachedResourceManager != null) { return(_cachedResourceManager); } // Get the resource managers var localResourceManager = GlobalizationService.GetResourceManager(localResourcesType); var namingContainerResourceManager = ResourceManagerUtility.GetResourceManager(NamingContainer, true); _cachedResourceManager = ResourceManagerSet.Create(namingContainerResourceManager, localResourceManager); return(_cachedResourceManager); }
protected IResourceManager GetResourceManager(Type resourceEnumType) { ArgumentUtility.CheckNotNullAndTypeIsAssignableFrom("resourceEnumType", resourceEnumType, typeof(Enum)); return(ResourceManagerSet.Create(GlobalizationService.GetResourceManager(TypeAdapter.Create(resourceEnumType)), GetResourceManager())); }
protected virtual IResourceManager GetResourceManager(BocListRenderingContext renderingContext) { return(ResourceManagerSet.Create( renderingContext.Control.GetResourceManager(), _globalizationService.GetResourceManager(typeof(ResourceIdentifier)))); }