public void Resolve_WithTypeDefiningMultipleResources_ReturnsResourceManagersInOrderOfDefinition()
        {
            var result = _resolver.Resolve(typeof(ClassWithMultiLingualResourcesAttributes));

            Assert.That(result.ResourceManager.IsNull, Is.False);
            Assert.That(result.ResourceManager, Is.InstanceOf <ResourceManagerSet>());
            Assert.That(result.DefinedResourceManager, Is.SameAs(result.ResourceManager));
            Assert.That(result.InheritedResourceManager.IsNull, Is.True);

            var resourceManagerSet = (ResourceManagerSet)result.ResourceManager;

            Assert.That(
                resourceManagerSet.ResourceManagers.Select(rm => rm.Name),
                Is.EquivalentTo(new[] { NamedResources.One, NamedResources.Two, NamedResources.Three }));
        }
Esempio n. 2
0
        private void CollectResourceManagersRecursively(Type type, List <IResourceManager> collectedResourceMangers)
        {
            var mixinTypes = MixinTypeUtility.GetMixinTypesExact(type);

            foreach (var mixinType in mixinTypes)
            {
                CollectResourceManagersRecursively(mixinType, collectedResourceMangers);
            }

            collectedResourceMangers.AddRange(mixinTypes.Select(mixinType => _resourceManagerResolver.Resolve(mixinType).ResourceManager));
        }
        private IResourceManager GetResourceManagerImplementation(ITypeInformation typeInformation)
        {
            var runtimeType = typeInformation.AsRuntimeType();

            if (runtimeType == null)
            {
                return(NullResourceManager.Instance);
            }

            var result = _resourceManagerResolver.Resolve(runtimeType);

            return(result.ResourceManager);
        }