public void SayHello(ELanguage language) { HelloFactory factory = new HelloFactory(); this.speaker = factory.CreateSpeaker(language); this.speaker.SayHello(); }
public MainPageViewModel(INavigationService navigationService, ISayHello sayHello) { _navigationService = navigationService; _SayHello = sayHello; WhoAreYour = _SayHello.Hello(); }
static void SayHello() { using (var scope = _container.BeginLifetimeScope()) { ISayHello hello = _container.Resolve <ISayHello>(); hello.Run(); } }
static void Main(string[] args) { var container = new UnityContainer(); ISayHello hello = container.Resolve <SayHelloInEnglish>(); hello.Run(); Console.ReadKey(); }
public MainPageViewModel(INavigationService navigationService, ISayHello sayHello) { this.navigationService = navigationService; this.sayHello = sayHello; GetSystemCommand = new DelegateCommand(() => { Message = sayHello.Hello(); }); }
public MainPageViewModel(INavigationService navigationService, ISayHello sayHelloService, IPageDialogService dialogService) { _sayHelloService = sayHelloService; _dialogService = dialogService; _navigationService = navigationService; Title = "Welcome"; Initialize(); }
static void Main(string[] args) { SayHello obj = new SayHello(); IHello ih = obj; ih.Hello(); // IHello ISayHello ish = (ISayHello)ih; // or obj ish.Hello(); // ISayHello }
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("테스트"); }
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)); }
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"); }
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"); }
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"); }
static void Main1(string[] args) { // 建立Unity容器 IUnityContainer container = new UnityContainer(); // 向Unity容器注册类型 container.RegisterType <ISayHello, SayHelloInEnglist>(); // 在程序某处要求解析类型, 已取得组件的实例 ISayHello hello = container.Resolve <ISayHello>(); // 调用组件的方法 hello.Run(); Console.ReadKey(); }
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"); }
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(); // 等待按任意鍵結束程式。 }
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>()); }
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> }
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"); }
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); }
/* 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(); }
public SecurityEnabledHello(ISayHello hello) { _hello = hello; }
public static void TestNamePopulated(ISayHello sut) { sut.GetHello().Should().NotBeNullOrWhiteSpace(); }
public HomeController(ApplicationDbContext context, ISayHello sayHello) { _context = context; _sayHello = sayHello; }
public SecondPageViewModel(INavigationService navigationService, ISayHello sayHelloService) { _navigationService = navigationService; _sayHelloService = sayHelloService; Title = "Home"; }
public OutputHello(ISayHello sayHello) { _sayHello = sayHello; }
//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; }
public MainPageViewModel(ISayHello sayHello) { _SayHello = sayHello; }
public MainPageViewModel(ISayHello sayHello) { _SayHello = sayHello; HelloText = _SayHello.Hello(); }
public MainPageViewModel(INavigationService navigationService, ISayHello sayHello) { _navigationService = navigationService; _SayHello = sayHello; }
public HomeController(ISayHello say) { _say = say; }
public MainPageViewModel(ISayHello iSayHello) { _ISayHello = iSayHello; Title = _ISayHello.Hello(); }
public LoggingHello(ISayHello hello) { _hello = hello; }
public HelloController(ISayHello sayHello) { _SayHello = sayHello; }