Ejemplo n.º 1
0
        public void SayHello(ELanguage language)
        {
            HelloFactory factory = new HelloFactory();

            this.speaker = factory.CreateSpeaker(language);
            this.speaker.SayHello();
        }
Ejemplo n.º 2
0
        public MainPageViewModel(INavigationService navigationService,
                                 ISayHello sayHello)
        {
            _navigationService = navigationService;
            _SayHello          = sayHello;

            WhoAreYour = _SayHello.Hello();
        }
Ejemplo n.º 3
0
 static void SayHello()
 {
     using (var scope = _container.BeginLifetimeScope())
     {
         ISayHello hello = _container.Resolve <ISayHello>();
         hello.Run();
     }
 }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            var       container = new UnityContainer();
            ISayHello hello     = container.Resolve <SayHelloInEnglish>();

            hello.Run();
            Console.ReadKey();
        }
Ejemplo n.º 5
0
 public MainPageViewModel(INavigationService navigationService, ISayHello sayHello)
 {
     this.navigationService = navigationService;
     this.sayHello          = sayHello;
     GetSystemCommand       = new DelegateCommand(() =>
     {
         Message = sayHello.Hello();
     });
 }
Ejemplo n.º 6
0
        public MainPageViewModel(INavigationService navigationService, ISayHello sayHelloService, IPageDialogService dialogService)
        {
            _sayHelloService   = sayHelloService;
            _dialogService     = dialogService;
            _navigationService = navigationService;

            Title = "Welcome";
            Initialize();
        }
Ejemplo n.º 7
0
        static void Main(string[] args)
        {
            SayHello obj = new SayHello();
            IHello   ih  = obj;

            ih.Hello();                    // IHello
            ISayHello ish = (ISayHello)ih; // or obj

            ish.Hello();                   // ISayHello
        }
Ejemplo n.º 8
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.activity_main);
            Button   button1   = FindViewById <Button>(Resource.Id.button1);
            TextView textView1 = FindViewById <TextView>(Resource.Id.textView1);

            hello          = new SayHelloImpl();
            button1.Click += (sender, args) => textView1.Text = hello.SayHello("테스트");
        }
Ejemplo n.º 9
0
        private string GetAllMessages()
        {
            var englishLang     = new EnglishHello();
            var frenchHello     = new FrenchHello();
            var englishInformat = new EnglishInformalHello();
            var allHellos       = new ISayHello[] { englishLang, frenchHello, englishInformat };
            var allLangs        = allHellos.Where(l => l is ISayHelloLanguage).Cast <ISayHelloLanguage>();
            var factory         = GetSayHelloFactory(allHellos);

            return(GetAllMessagesFromController(factory, allLangs, allHellos, englishLang, frenchHello));
        }
Ejemplo n.º 10
0
        public void MixinInArrayList()
        {
            Engine c = new Engine("MixinInArrayList");

            c.Configuration.Aspects.Add(new SignatureAspect("AddInterface", typeof(ArrayList), new Type[] { typeof(SayHelloMixin) }, new IPointcut[0]));

            ArrayList proxy = (ArrayList)c.CreateProxy(typeof(ArrayList));

            ISayHello sayHello = (ISayHello)proxy;

            string helloString = sayHello.SayHello();

            Assert.IsTrue(helloString == "Hello", "SayHelloMixin did not work");
        }
Ejemplo n.º 11
0
        public void MixinTest()
        {
            Engine c = new Engine("MixinTest");

            c.Configuration.Aspects.Add(new SignatureAspect("MixinTest", typeof(SomeClass), new Type[] { typeof(SayHelloMixin) }, new IPointcut[0]));

            SomeClass proxy = (SomeClass)c.CreateProxy(typeof(SomeClass));

            ISayHello sayHello = (ISayHello)proxy;

            string helloString = sayHello.SayHello();

            Assert.IsTrue(helloString == "Hello", "SayHelloMixin did not work");
        }
Ejemplo n.º 12
0
        public void TypedAspectMixinTest()
        {
            Engine c = new Engine("TypedAspectMixinTest");

            c.Configuration.Aspects.Add(new MyTypedAspect());

            Foo proxy = (Foo)c.CreateProxy(typeof(Foo));

            ISayHello sayHello = (ISayHello)proxy;

            string helloString = sayHello.SayHello();

            Assert.IsTrue(helloString == "Hello", "SayHelloMixin did not work");
        }
Ejemplo n.º 13
0
        static void Main1(string[] args)
        {
            // 建立Unity容器
            IUnityContainer container = new UnityContainer();

            // 向Unity容器注册类型
            container.RegisterType <ISayHello, SayHelloInEnglist>();
            // 在程序某处要求解析类型, 已取得组件的实例
            ISayHello hello = container.Resolve <ISayHello>();

            // 调用组件的方法
            hello.Run();

            Console.ReadKey();
        }
Ejemplo n.º 14
0
        public void MixinInterfaceWOImplementation()
        {
            Engine c = new Engine("MixinInterfaceWOImplementation");

            c.Configuration.Aspects.Add(new SignatureAspect("AddInterface", typeof(ArrayList), new Type[] { typeof(ISomeListMarkerIFace), typeof(SayHelloMixin) }, new IPointcut[0]));

            ArrayList proxy = (ArrayList)c.CreateProxy(typeof(ArrayList));

            ISayHello sayHello = (ISayHello)proxy;

            string helloString = sayHello.SayHello();

            Assert.IsTrue(helloString == "Hello", "SayHelloMixin did not work");

            Assert.IsTrue(proxy is ISomeListMarkerIFace, "Marker interface was not applied to type");
        }
Ejemplo n.º 15
0
        static void Main(string[] args)
        {
            // (1) 建立 Unity 容器。
            IUnityContainer container = new UnityContainer();

            // (2) 向 Unity 容器註冊型別。
            container.RegisterType <ISayHello, SayHelloInEnglish>();

            // (3) 在程式某處,要求解析型別,以取得元件的執行個體。
            ISayHello hello = container.Resolve <ISayHello>();

            // (4) 呼叫元件的方法。
            hello.Run();

            Console.ReadKey(); // 等待按任意鍵結束程式。
        }
Ejemplo n.º 16
0
        public void SayHelloFactory_Should_Ignore_Null_Instances_In_Parameter()
        {
            var instances = new ISayHello[] {
                new English.EnglishHello(), new EnglishInformal.EnglishInformalHello(), new French.FrenchHello()
            };

            IEnumerable<ISayHello> InterleavedEnumerable()
            {
                foreach (var instance in instances)
                {
                    yield return instance;
                    yield return null;
                }
            }

            var sut = new SayHelloFactory(InterleavedEnumerable());

            sut.GetAllHellos().Should().BeEquivalentTo(instances.Cast<object>());
        }
Ejemplo n.º 17
0
        public static void Snippet3()
        {
            // <Snippet3>
            // Open up a channel factory on a client application.
            ChannelFactory <ISayHello> factory = new ChannelFactory <ISayHello>("BasicHttpBinding_ISayHello");

            // Both of these contracts work (provided both hostnames are valid) because
            // the binding configuration is set to hostNameComparisonMode="StrongWildcard".

            ISayHello channel  = factory.CreateChannel(new EndpointAddress("http://localhost:8000/UESamples/HelloService"));
            ISayHello channel2 = factory.CreateChannel(new EndpointAddress("http://machineName/UESamples/HelloService"));

            Console.WriteLine(channel.SayHello());

            Console.WriteLine();
            Console.WriteLine("Press <ENTER> to terminate client.");
            Console.ReadLine();
            // </Snippet3>
        }
Ejemplo n.º 18
0
        public void CreateWrapper()
        {
            Engine c = new Engine("CreateWrapper");

            c.Configuration.Aspects.Add(new SignatureAspect("AddInterface", typeof(ArrayList), new Type[] { typeof(ISomeListMarkerIFace), typeof(SayHelloMixin) }, new IPointcut[0]));


            ArrayList realList    = new ArrayList();
            IList     wrapperList = (IList)c.CreateWrapper(realList);

            wrapperList.Add("apa");
            int cnt = wrapperList.Count;

            Assert.IsTrue(wrapperList is ISomeListMarkerIFace, "Marker interface was not applied to type");

            ISayHello sayHello    = (ISayHello)wrapperList;
            string    helloString = sayHello.SayHello();

            Assert.IsTrue(helloString == "Hello", "SayHelloMixin did not work");
        }
Ejemplo n.º 19
0
        public virtual ISayHello CreateSpeaker(ELanguage language)
        {
            ISayHello speaker = null;

            switch (language)
            {
            case ELanguage.PL:
                speaker = new HelloPl();
                break;

            case ELanguage.ENG:
                speaker = new HelloEng();
                break;

            case ELanguage.GER:
                speaker = new HelloGer();
                break;

            default:
                break;
            }
            return(speaker);
        }
Ejemplo n.º 20
0
 /* public void FancyMethod(Student st)
  * {
  *  st.PrintMe();
  * }
  * public void FancyMethod(Instructor instructor)
  * {
  *  instructor.PrintMe();
  * }*/
 public static void MyFancyMethod(ISayHello myObj) // static for main to access it.
 {
     myObj.PrintMe();
 }
Ejemplo n.º 21
0
 public SecurityEnabledHello(ISayHello hello)
 {
     _hello = hello;
 }
Ejemplo n.º 22
0
 public static void TestNamePopulated(ISayHello sut)
 {
     sut.GetHello().Should().NotBeNullOrWhiteSpace();
 }
Ejemplo n.º 23
0
 public HomeController(ApplicationDbContext context, ISayHello sayHello)
 {
     _context  = context;
     _sayHello = sayHello;
 }
Ejemplo n.º 24
0
 public SecondPageViewModel(INavigationService navigationService, ISayHello sayHelloService)
 {
     _navigationService = navigationService;
     _sayHelloService   = sayHelloService;
     Title = "Home";
 }
 public OutputHello(ISayHello sayHello)
 {
     _sayHello = sayHello;
 }
Ejemplo n.º 26
0
        //public void FancyMethod(Student st)
        //{
        //    st.PrintMe();
        //}

        //public void FancyMethod(Instructor st)
        //{
        //    st.PrintMe();
        //}

        public static void MyFancyMethod(ISayHello myObj)
        {
            myObj.PrintMe();
        }
 public OrdersController(ISayHello say, ISendOnlyBus bus)
 {
     _say = say;
     _bus = bus;
 }
Ejemplo n.º 28
0
 public MainPageViewModel(ISayHello sayHello)
 {
     _SayHello = sayHello;
 }
Ejemplo n.º 29
0
 public MainPageViewModel(ISayHello sayHello)
 {
     _SayHello = sayHello;
     HelloText = _SayHello.Hello();
 }
Ejemplo n.º 30
0
 public MainPageViewModel(INavigationService navigationService,
                          ISayHello sayHello)
 {
     _navigationService = navigationService;
     _SayHello          = sayHello;
 }
 public HomeController(ISayHello say)
 {
     _say = say;
 }
Ejemplo n.º 32
0
 public MainPageViewModel(ISayHello iSayHello)
 {
     _ISayHello = iSayHello;
     Title      = _ISayHello.Hello();
 }
Ejemplo n.º 33
0
 public LoggingHello(ISayHello hello)
 {
     _hello = hello;
 }
Ejemplo n.º 34
0
 public HelloController(ISayHello sayHello)
 {
     _SayHello = sayHello;
 }