Exemplo n.º 1
0
        private ICustomFactory CreateCustomFactory(Type type)
        {
            CustomFactoryAttribute attribute
                = GetCustomAttribute <CustomFactoryAttribute>(type);

            if (attribute != null)
            {
                return((ICustomFactory)Activator.CreateInstance(attribute.FactoryType));
            }
            else
            {
                return(null);
            }
        }
		public void CustomFactoryWithNullTypeThrows()
		{
			CustomFactoryAttribute attribute = new CustomFactoryAttribute(null);
		}
		public void CustomFactoryWithIncompatibleTypeThrows()
		{
			CustomFactoryAttribute attribute = new CustomFactoryAttribute(typeof(object));
		}
		public void CustomFactoryWithCompatibleTypeWorks()
		{
			CustomFactoryAttribute attribute = new CustomFactoryAttribute(typeof(MockImplementor));
		}