コード例 #1
0
        private ICustomFactory CreateCustomFactory(Type type)
        {
            CustomFactoryAttribute attribute
                = GetCustomAttribute <CustomFactoryAttribute>(type);

            if (attribute != null)
            {
                return((ICustomFactory)Activator.CreateInstance(attribute.FactoryType));
            }
            else
            {
                return(null);
            }
        }
コード例 #2
0
		public void CustomFactoryWithNullTypeThrows()
		{
			CustomFactoryAttribute attribute = new CustomFactoryAttribute(null);
		}
コード例 #3
0
		public void CustomFactoryWithIncompatibleTypeThrows()
		{
			CustomFactoryAttribute attribute = new CustomFactoryAttribute(typeof(object));
		}
コード例 #4
0
		public void CustomFactoryWithCompatibleTypeWorks()
		{
			CustomFactoryAttribute attribute = new CustomFactoryAttribute(typeof(MockImplementor));
		}