public override object ProvideValue(IServiceProvider serviceProvider) { object value = null; var type = (Type)typeExtension.ProvideValue(serviceProvider); if (!Instances.TryGetValue(type, out value)) { Instances[type] = value = Activator.CreateInstance(type); } return(value); }
public void ProvideValueWithNameWithProviderResolveSuccess () { var x = new TypeExtension ("System.Int32"); x.ProvideValue (new Resolver (true, true)); }
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 ProvideValueWithType () { var x = new TypeExtension (typeof (int)); Assert.AreEqual (typeof (int), x.ProvideValue (null), "#1"); // serviceProvider is not required. }