public void Attribute_Proxy_Inject_Proxy_Invoker()
        {
            using (var injector = Injector.Create())
            {
                injector.RegisterType <ISay, CustomProxyAttributeSayHello>();

                ISay o = injector.CreateInstance <ISay>();

                Assert.IsInstanceOfType(o, typeof(InjectProxyInvokerSayWorld));
                Assert.AreEqual("Hello World", o.Say());
            }
        }
Exemple #2
0
        public void Register_Type_Inject_Constructor()
        {
            var injector = Injector.Create();

            injector.RegisterType <ISay, CustomSay>(new InjectConstructor("Hello"));

            ISay o = injector.CreateInstance <ISay>();

            Assert.IsNotNull(o);
            Assert.IsInstanceOfType(o, typeof(CustomSay));
            Assert.AreEqual("Hello", o.Say());
        }
        public void Register_Proxy_Inject_Target()
        {
            using (var injector = Injector.Create())
            {
                injector.RegisterType <ISay, SayHello>();
                injector.RegisterProxy <ISay, InjectTargetSayWorld>();

                ISay o = injector.CreateInstance <ISay>();

                Assert.IsInstanceOfType(o, typeof(InjectTargetSayWorld));
                Assert.AreEqual("Hello World", o.Say());
            }
        }
        public static void Print(ISay say)
        {
            System.Reflection.MemberInfo info = say.GetType();
            BlockAttribute att = (BlockAttribute)Attribute.GetCustomAttribute(info, typeof(BlockAttribute));

            if (att.Level == Level.Yes)
            {
                Console.WriteLine(say.GetType() + ": " + say.Say());
            }
            else
            {
                Console.WriteLine(say.GetType() + ": " + "I Love the contry!");
            }
        }
 public string Say()
 {
     return(target.Say() + " World");
 }
Exemple #6
0
 public void Say()
 {
     _animal.Say();
 }