コード例 #1
0
        public void TypeExtensionProvideValue()
        {
            tlog.Debug(tag, $"TypeExtensionProvideValue START");

            try
            {
                IServiceProviderimplement serviceProviderimplement = new IServiceProviderimplement();
                t1.TypeName = "myTypeName";
                t1.ProvideValue(serviceProviderimplement);
            }
            catch (Exception e)
            {
                tlog.Debug(tag, e.Message.ToString());
                tlog.Debug(tag, $"TypeExtensionProvideValue END (OK)");
                Assert.Pass("Caught Exception : passed!");
            }
        }
コード例 #2
0
        /// <summary>
        ///     Provides an instance of <see cref="TypeConverter" /> based on this <c>TypeConverterExtension</c>.
        /// </summary>
        /// <param name="serviceProvider">
        ///     An object that can provide services.
        /// </param>
        /// <returns>
        ///     The instance of <see cref="TypeConverter" />.
        /// </returns>
        public override object ProvideValue(IServiceProvider serviceProvider)
        {
            Type sourceType = null;
            Type targetType = null;

            if ((sourceTypeExtension.Type != null) || (sourceTypeExtension.TypeName != null))
            {
                sourceType = sourceTypeExtension.ProvideValue(serviceProvider) as Type;
            }

            if ((targetTypeExtension.Type != null) || (targetTypeExtension.TypeName != null))
            {
                targetType = targetTypeExtension.ProvideValue(serviceProvider) as Type;
            }

            // just let the TypeExtensions do the type resolving via the service provider
            return(new TypeConverter(sourceType, targetType));
        }
コード例 #3
0
        public void ProvideValueWithNameWithProviderResolveSuccess()
        {
            var x = new TypeExtension("System.Int32");

            x.ProvideValue(new Resolver(true, true));
        }
コード例 #4
0
        public void ProvideValueWithNameWithProviderResolveFail()
        {
            var x = new TypeExtension("System.Int32");

            Assert.Throws <InvalidOperationException> (() => x.ProvideValue(new Resolver(true, false)));              // raise an error (do not return null)
        }
コード例 #5
0
        public void ProvideValueWithNameWithProviderNoResolver()
        {
            var x = new TypeExtension("System.Int32");

            Assert.Throws <InvalidOperationException> (() => x.ProvideValue(new Resolver(false, false)));
        }
コード例 #6
0
        public void ProvideValueWithNameWithoutResolver()
        {
            var x = new TypeExtension("System.Int32");

            Assert.Throws <ArgumentNullException> (() => x.ProvideValue(null));             // serviceProvider is required.
        }
コード例 #7
0
		public void ProvideValueWithNameWithoutResolver ()
		{
			var x = new TypeExtension ("System.Int32");
			Assert.Throws<ArgumentNullException> (() => x.ProvideValue (null)); // serviceProvider is required.
		}
コード例 #8
0
		public void ProvideValueWithNameWithProviderNoResolver ()
		{
			var x = new TypeExtension ("System.Int32");
			x.ProvideValue (new Resolver (false, false));
		}
コード例 #9
0
		public void ProvideValueWithType ()
		{
			var x = new TypeExtension (typeof (int));
			Assert.AreEqual (typeof (int), x.ProvideValue (null), "#1"); // serviceProvider is not required.
		}
コード例 #10
0
        public void ProvideValueWithNameWithProviderResolveFail()
        {
            var x = new TypeExtension("System.Int32");

            x.ProvideValue(new Resolver(true, false));               // raise an error (do not return null)
        }
コード例 #11
0
        public void ProvideValueWithNameWithProviderNoResolver()
        {
            var x = new TypeExtension("System.Int32");

            x.ProvideValue(new Resolver(false, false));
        }
コード例 #12
0
        public void ProvideValueWithNameWithoutResolver()
        {
            var x = new TypeExtension("System.Int32");

            x.ProvideValue(null);              // serviceProvider is required.
        }
コード例 #13
0
		public void ProvideValueWithNameWithProviderResolveFail ()
		{
			var x = new TypeExtension ("System.Int32");
			Assert.Throws<InvalidOperationException> (() => x.ProvideValue (new Resolver (true, false))); // raise an error (do not return null)
		}
コード例 #14
0
		public void ProvideValueWithNameWithProviderNoResolver ()
		{
			var x = new TypeExtension ("System.Int32");
			Assert.Throws<InvalidOperationException> (() => x.ProvideValue (new Resolver (false, false)));
		}
コード例 #15
0
 private Type ProvideEnumType(IServiceProvider serviceProvider)
 {
     return((Type)TypeExtension.ProvideValue(serviceProvider));
 }
コード例 #16
0
		public void ProvideValueWithNameWithProviderResolveSuccess ()
		{
			var x = new TypeExtension ("System.Int32");
			x.ProvideValue (new Resolver (true, true));
		}
コード例 #17
0
        public void ProvideValueWithoutTypeOrName()
        {
            var te = new TypeExtension();

            Assert.Throws <InvalidOperationException> (() => te.ProvideValue(null));
        }
コード例 #18
0
		public void ProvideValueWithNameWithoutResolver ()
		{
			var x = new TypeExtension ("System.Int32");
			x.ProvideValue (null); // serviceProvider is required.
		}
コード例 #19
0
        public void ProvideValueWithType()
        {
            var x = new TypeExtension(typeof(int));

            Assert.AreEqual(typeof(int), x.ProvideValue(null), "#1");                // serviceProvider is not required.
        }
コード例 #20
0
		public void ProvideValueWithNameWithProviderResolveFail ()
		{
			var x = new TypeExtension ("System.Int32");
			x.ProvideValue (new Resolver (true, false)); // raise an error (do not return null)
		}
コード例 #21
0
		public void ProvideValueWithoutTypeOrName ()
		{
			var te = new TypeExtension ();
			Assert.Throws<InvalidOperationException> (() => te.ProvideValue (null));
		}