Example #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();
        }
Example #2
0
        static void Main(string[] args)
        {
            Program p1 = new Program();

            Console.WriteLine("The car speed is " + p1.CarSpeed(77, 28));
            Console.WriteLine("The car Motorcycle speed is " + p1.MotorcycleSpeed(55, 45));
            IDog i1 = p1;

            Console.WriteLine("A dog eats " + i1.Dogfood("biscuits ") + "and lives in a " + i1.Doghabitat("house."));
            IElephant i2 = p1;

            Console.WriteLine("An Elephant eats " + i2.Elephantfood("roots ") + "and lives in the " + i2.Elephanthabitat("jungle."));
            Console.ReadLine();
        }
 internal ElephantViewModel(IElephant elephant) : base(elephant)
 {
     this.TrunkLength = elephant.TrunkLength;
     this.ColorName   = this.GetColorName(elephant.Color);
 }
Example #4
0
 public Circus(IClown clown, IElephant elephant, string location)
 {
     Clown    = clown;
     Elephant = elephant;
     Location = location;
 }