Exemplo n.º 1
0
        public void RunRegisteredInstancesWithContainerTest()
        {
            Console.WriteLine("Creating new unity container...");
            IUnityContainer container = new UnityContainer();

            Console.WriteLine("Registering fun stuff...");
            FunContainers.RegisterFunStuffForRegisterTest(container);

            Console.WriteLine("Resolving fun stuff...");
            IClown clown = container.Resolve <IClown>();

            clown.ClownName = "Bubbles";

            Console.WriteLine($"Clowns name is: {clown.ClownName}");

            IElephant elephant = container.Resolve <IElephant>();

            elephant.ElephantName = "Barbar";

            Console.WriteLine($"The elephants name is: {elephant.ElephantName}");

            IToilet toilet = container.Resolve <Toilet>();

            Console.WriteLine($"The toilet is hiding here: {toilet.ToiletLocation}");

            ICircus circus = container.Resolve <ICircus>(new ParameterOverride("clown", clown),
                                                         new ParameterOverride("elephant", elephant),
                                                         new ParameterOverride("location", "Some Place Imaginary"));

            Console.WriteLine("Executing circus methods...");
            Console.WriteLine(circus.GetLocation());
            circus.MakeElephantDoSomethingWithClown();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            IClown fingersTheClown = new ScaryScary("big red nose", 14);

            fingersTheClown.Honk();
            if (fingersTheClown is IScaryClown scaryClown)
            {
                scaryClown.ScareLittleChildren();
            }
            IClown.CarCapacity = 18;
            Console.WriteLine(IClown.ClownCarDescription());
        }
        static void Main(string[] args)
        {
            IClown.CarCapacity = 18;
            Console.WriteLine(IClown.ClownCarDescription());

            IClown fingersTheClown = new ScaryScary("big red nose", 14);

            fingersTheClown.Honk();
            if (fingersTheClown is IScaryClown iScaryClownReference)
            {
                iScaryClownReference.ScareAdults();
            }
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            IClown[] clowns  = new IClown[2];
            TallGuy  tallGuy = new TallGuy("A guitar")
            {
                Name = "Jimmy", Height = 74
            };

            clowns[0] = tallGuy;
            tallGuy.TalkAboutYourself();
            Console.WriteLine(tallGuy.FunnyThingIHave);
            tallGuy.Honk();
            Console.WriteLine(tallGuy.AnotherFunnyThingIHave);
            IClown tallClown = new TallGuy("A red nose");

            clowns[1] = tallClown;
            tallClown.Honk();
            Console.WriteLine("==============================");
            Chief chief = new Chief(clowns);

            chief.GiveMeYourStuff();
            Console.ReadKey();
        }
Exemplo n.º 5
0
 string WhichFunnyThingIWant(IClown clownType)
 {
     clownType.Honk();
 }
Exemplo n.º 6
0
 public Circus(IClown clown, IElephant elephant, string location)
 {
     Clown    = clown;
     Elephant = elephant;
     Location = location;
 }
Exemplo n.º 7
0
 private static void DoJob(IClown man)
 {
     Console.WriteLine(man.FunnyThingIHave);
     man.Honk();
 }