UnityContainer.Resolve () will create instances that were not explicitly registered with reflection, allowing this thing:
using System;
using Microsoft.Practices.Unity;
namespace ConsoleApplication2
{
public class Foo
{
public void SayHello()
{
Console.WriteLine("Hello");
}
}
class Program
{
static void Main(string[] args)
{
var container = new UnityContainer();
var foo = container.Resolve<Foo>();
foo.SayHello();
}
}
}
My question is whether this behavior can be disabled if I want the class to not be automatically resolved (either with an exception raised, or with a null return)
source
share