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!"); } }
/// <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)); }
public void ProvideValueWithNameWithProviderResolveSuccess() { var x = new TypeExtension("System.Int32"); x.ProvideValue(new Resolver(true, true)); }
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) }
public void ProvideValueWithNameWithProviderNoResolver() { var x = new TypeExtension("System.Int32"); Assert.Throws <InvalidOperationException> (() => x.ProvideValue(new Resolver(false, false))); }
public void ProvideValueWithNameWithoutResolver() { var x = new TypeExtension("System.Int32"); Assert.Throws <ArgumentNullException> (() => x.ProvideValue(null)); // serviceProvider is required. }
public void ProvideValueWithNameWithoutResolver () { var x = new TypeExtension ("System.Int32"); Assert.Throws<ArgumentNullException> (() => x.ProvideValue (null)); // serviceProvider is required. }
public void ProvideValueWithNameWithProviderNoResolver () { var x = new TypeExtension ("System.Int32"); x.ProvideValue (new Resolver (false, false)); }
public void ProvideValueWithType () { var x = new TypeExtension (typeof (int)); Assert.AreEqual (typeof (int), x.ProvideValue (null), "#1"); // serviceProvider is not required. }
public void ProvideValueWithNameWithProviderResolveFail() { var x = new TypeExtension("System.Int32"); x.ProvideValue(new Resolver(true, false)); // raise an error (do not return null) }
public void ProvideValueWithNameWithProviderNoResolver() { var x = new TypeExtension("System.Int32"); x.ProvideValue(new Resolver(false, false)); }
public void ProvideValueWithNameWithoutResolver() { var x = new TypeExtension("System.Int32"); x.ProvideValue(null); // serviceProvider is required. }
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) }
public void ProvideValueWithNameWithProviderNoResolver () { var x = new TypeExtension ("System.Int32"); Assert.Throws<InvalidOperationException> (() => x.ProvideValue (new Resolver (false, false))); }
private Type ProvideEnumType(IServiceProvider serviceProvider) { return((Type)TypeExtension.ProvideValue(serviceProvider)); }
public void ProvideValueWithNameWithProviderResolveSuccess () { var x = new TypeExtension ("System.Int32"); x.ProvideValue (new Resolver (true, true)); }
public void ProvideValueWithoutTypeOrName() { var te = new TypeExtension(); Assert.Throws <InvalidOperationException> (() => te.ProvideValue(null)); }
public void ProvideValueWithNameWithoutResolver () { var x = new TypeExtension ("System.Int32"); x.ProvideValue (null); // serviceProvider is required. }
public void ProvideValueWithType() { var x = new TypeExtension(typeof(int)); Assert.AreEqual(typeof(int), x.ProvideValue(null), "#1"); // serviceProvider is not required. }
public void ProvideValueWithNameWithProviderResolveFail () { var x = new TypeExtension ("System.Int32"); x.ProvideValue (new Resolver (true, false)); // raise an error (do not return null) }
public void ProvideValueWithoutTypeOrName () { var te = new TypeExtension (); Assert.Throws<InvalidOperationException> (() => te.ProvideValue (null)); }