ProvideValue() 공개 메소드

public ProvideValue ( IServiceProvider provider ) : object
provider IServiceProvider
리턴 object
예제 #1
0
        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);
        }
예제 #2
0
		public void ProvideValueWithNameWithProviderResolveSuccess ()
		{
			var x = new TypeExtension ("System.Int32");
			x.ProvideValue (new Resolver (true, true));
		}
예제 #3
0
		public void ProvideValueWithNameWithProviderResolveFail ()
		{
			var x = new TypeExtension ("System.Int32");
			x.ProvideValue (new Resolver (true, false)); // raise an error (do not return null)
		}
예제 #4
0
		public void ProvideValueWithNameWithProviderNoResolver ()
		{
			var x = new TypeExtension ("System.Int32");
			x.ProvideValue (new Resolver (false, false));
		}
예제 #5
0
		public void ProvideValueWithNameWithoutResolver ()
		{
			var x = new TypeExtension ("System.Int32");
			x.ProvideValue (null); // serviceProvider is required.
		}
예제 #6
0
		public void ProvideValueWithType ()
		{
			var x = new TypeExtension (typeof (int));
			Assert.AreEqual (typeof (int), x.ProvideValue (null), "#1"); // serviceProvider is not required.
		}