public void IsArray_Array()
        {
            var type = typeof(object[]);

            Assert.That(TypeAdapter.Create(type).IsArray, Is.EqualTo(type.IsArray).And.True);
        }
        public void IsValueType_ReferenceType()
        {
            var type = typeof(ArrayList);

            Assert.That(TypeAdapter.Create(type).IsValueType, Is.EqualTo(type.IsValueType).And.False);
        }
        public void IsValueType_ValueType()
        {
            var type = typeof(int);

            Assert.That(TypeAdapter.Create(type).IsValueType, Is.EqualTo(type.IsValueType).And.True);
        }
        public void IsClass_ValueType()
        {
            var type = typeof(Guid);

            Assert.That(TypeAdapter.Create(type).IsClass, Is.EqualTo(type.IsClass).And.False);
        }
        public void IsInterface_Interface()
        {
            var type = typeof(IList <>);

            Assert.That(TypeAdapter.Create(type).IsInterface, Is.EqualTo(type.IsInterface).And.True);
        }
        public void GetOriginalDeclaringType_NotNestedType()
        {
            var type = typeof(ArrayList);

            Assert.That(TypeAdapter.Create(type).GetOriginalDeclaringType(), Is.Null);
        }
        public void IsClass_ReferenceType()
        {
            var type = typeof(ArrayList);

            Assert.That(TypeAdapter.Create(type).IsClass, Is.EqualTo(type.IsClass).And.True);
        }
        public void GetOriginalDeclaringType_NestedType()
        {
            var type = typeof(Environment.SpecialFolder);

            Assert.That(TypeAdapter.Create(type).GetOriginalDeclaringType(), Is.TypeOf <TypeAdapter> ().And.Property("Type").SameAs(type.DeclaringType));
        }
Exemplo n.º 9
0
        protected IResourceManager GetResourceManager(Type resourceEnumType)
        {
            ArgumentUtility.CheckNotNullAndTypeIsAssignableFrom("resourceEnumType", resourceEnumType, typeof(Enum));

            return(ResourceManagerSet.Create(GlobalizationService.GetResourceManager(TypeAdapter.Create(resourceEnumType)), GetResourceManager()));
        }
Exemplo n.º 10
0
 public void DeclaringType()
 {
     Assert.That(_adapter.DeclaringType, Is.EqualTo(TypeAdapter.Create(_method.DeclaringType)));
 }
Exemplo n.º 11
0
        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));
        }
 public void IsExtensibleEnumType_FromITypeInformation_False_BaseType()
 {
     Assert.That(ExtensibleEnumUtility.IsExtensibleEnumType(TypeAdapter.Create(typeof(ExtensibleEnum <>))), Is.False);
     Assert.That(ExtensibleEnumUtility.IsExtensibleEnumType(TypeAdapter.Create(typeof(ExtensibleEnum <Color>))), Is.False);
     Assert.That(ExtensibleEnumUtility.IsExtensibleEnumType(TypeAdapter.Create(typeof(IExtensibleEnum))), Is.False);
 }