public EnglishPeople([Named("English")] IHelloWorld helloWorld)
        {
            if (helloWorld == null)
                throw new ArgumentNullException("helloWorld");

            this.peopleHelloWorld = helloWorld;
        }
Example #2
0
        public JsonResult GetHelloWorld()
        {
            string strReturnData = string.Empty;

            try
            {
                IHelloWorld oHelloWold = null;

                //this code can be called to return Simple hardcoded implementation of HelloWold
                oHelloWold = new SimpleHelloWorld();

                //this code can be called to return Database implementation of HelloWold - commented as of now
                //oHelloWold = new DBHelloWorld();

                oHelloWold.TxtData = "This is success data.";
                strReturnData      = oHelloWold.GetText();
            }
            catch (Exception ex)
            {
                strReturnData = "This is error data.";
                //TO DO - call a centrallized logger(log4net, loggly etc) to log the error
            }

            // return the JSON Data
            return(new JsonResult {
                Data = strReturnData
            });
        }
        static void Main(string[] args)
        {
            IHelloWorld x = GetImplementation <IHelloWorld>(Assembly.GetExecutingAssembly());

            x.SayHello();
            Console.ReadKey();
        }
Example #4
0
        public void CreateConsoleType()
        {
            HelloWorldFactory fac   = new HelloWorldFactory();
            IHelloWorld       hwAPI = fac.CreateInstance(HelloWorldTypes.Console, "test");

            Assert.AreEqual(hwAPI.getGreeting(), "Hello World Console");
        }
Example #5
0
        static void Main()
        {
            //Create new appDomain
            AppDomain domain = AppDomain.CreateDomain("NewAppDomain");

            // Create remote object in new appDomain via shared interface
            // to avoid loading the implementation library into this appDomain
            IHelloWorld proxy =
                (IHelloWorld)domain.CreateInstanceAndUnwrap(
                    "ImplementationLibrary",
                    "Microsoft.Samples.ImplementationLibrary.HelloWorld");

            // Output results of the call
            Console.WriteLine("\nReturn:\n\t{0}", proxy.Echo("Hello"));
            Console.WriteLine();

            Console.WriteLine("Non-GAC assemblies loaded in {0} appDomain:", AppDomain.CurrentDomain.FriendlyName);
            foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
            {
                if (!assembly.GlobalAssemblyCache)
                {
                    Console.WriteLine("\t" + assembly.GetName().Name);
                }
            }
            Console.WriteLine("\nImplementationLibrary should not be loaded.");

            Console.ReadLine();
        }
Example #6
0
        public HkPeople(IHelloWorld helloWorld)
        {
            if (helloWorld == null)
                throw new ArgumentNullException("helloWorld");

            this.peopleHelloWorld = helloWorld;
        }
Example #7
0
        public JpPeople([EnglishKnowAble] IHelloWorld helloWorld)
        {
            if (helloWorld == null)
                throw new ArgumentNullException("helloWorld");

            this.peopleHelloWorld = helloWorld;
        }
        public ChinesePeople([Named("Chinese")] IHelloWorld helloWorld)
        {
            if (helloWorld == null)
                throw new ArgumentNullException("helloWorld");

            this.peopleHelloWorld = helloWorld;
        }
Example #9
0
        private static void InvokeUsingHttp()
        {
            #region 하드코딩 설정 방법

            /*
             *
             * // http uri 생성
             * Uri uri = new Uri("http://localhost/wcf/helloworldservice");
             *
             * // http 종점 생성
             * ServiceEndpoint endpoint = new ServiceEndpoint(ContractDescription.GetContract(typeof(IHelloWorld)), new BasicHttpBinding(), new EndpointAddress(uri));
             *
             * // 채널 생성
             * ChannelFactory<IHelloWorld> factory = new ChannelFactory<IHelloWorld>(endpoint);
             * IHelloWorld proxy = factory.CreateChannel();
             */

            #endregion

            #region App.config 설정 방법

            ChannelFactory <IHelloWorld> channelFactory = new ChannelFactory <IHelloWorld>("TcpHelloWorld");
            IHelloWorld proxy = channelFactory.CreateChannel();

            #endregion

            // 서비스의 메소드 호출
            string result = proxy.SayHello();
            (proxy as IDisposable).Dispose();

            // 결과 출력
            System.Console.WriteLine(result);
        }
Example #10
0
        public void WriteMessage_NotImplemented()
        {
            HelloWorldFactory fac   = new HelloWorldFactory();
            IHelloWorld       hwAPI = fac.CreateInstance(HelloWorldTypes.Console, "test");

            Assert.ThrowsException <NotImplementedException>(() => hwAPI.writeMessage("test"));
        }
        static void Main(string[] args)
        {
            IHelloWorld   actor  = ActorProxy.Create <IHelloWorld>(ActorId.CreateRandom(), new Uri("fabric:/MyApplication/HelloWorldActorService"));
            Task <string> retval = actor.GetHelloWorldAsync();

            Console.Write(retval.Result);
            Console.ReadLine();
        }
Example #12
0
        public MainPage()
        {
            InitializeComponent();

            IHelloWorld helloWorld = DependencyService.Get <IHelloWorld>();

            helloLabel.Text = helloWorld.HelloWorld();
        }
Example #13
0
        public ChinesePeople([Named("Chinese")] IHelloWorld helloWorld)
        {
            if (helloWorld == null)
            {
                throw new ArgumentNullException("helloWorld");
            }

            this.peopleHelloWorld = helloWorld;
        }
Example #14
0
        public People(IHelloWorld helloWorld)
        {
            if (helloWorld == null)
            {
                throw new ArgumentNullException("helloWorld");
            }

            this.peopleHelloWorld = helloWorld;
        }
        public EnglishPeople([Named("English")] IHelloWorld helloWorld)
        {
            if (helloWorld == null)
            {
                throw new ArgumentNullException("helloWorld");
            }

            this.peopleHelloWorld = helloWorld;
        }
Example #16
0
        public HelloWorldPresenter(IHelloWorld _view)
        {
            //set the view
            view = _view;

            //listen to calls
            view.LoadText   += View_LoadText;
            view.ChangeText += View_ChangeText;
        }
Example #17
0
        static void Main(string[] args)
        {
            HelloWorldFactory factory = new HelloWorldFactory();
            // create hellowWorld obj
            IHelloWorld helloWorldObj = factory.CreateHelloWorldObj();

            // call any of the implemented function to output "Hello World" to either console or database or other places
            helloWorldObj.PrintHelloWorldToConsole("Hello World");
        }
Example #18
0
        public JpPeople([EnglishKnowAble] IHelloWorld helloWorld)
        {
            if (helloWorld == null)
            {
                throw new ArgumentNullException("helloWorld");
            }

            this.peopleHelloWorld = helloWorld;
        }
Example #19
0
        public void AppEventHandler(object sender, AppEventArgs e)
        {
            controller = sender as GenericController;

            lblHelloWorld = controller.GetViewControl("lblHelloWorld") as Label;

            helloWorldService = ServiceFactory.getService <IHelloWorld>();

            Page_Load(sender, e);
        }
 public static SurrogateForIHelloWorld Convert(IHelloWorld value)
 {
     if (value == null)
     {
         return(null);
     }
     return(new SurrogateForIHelloWorld {
         Target = ((HelloWorldRef)value).Target
     });
 }
        static void Main(string[] args)
        {
            //Unity 入門 (1)
            //重點new Unity 的 DI容器
            Console.WriteLine("================Unity 入門 (1)==============================");
            var         container  = new UnityContainer();
            IHelloWorld helloWorld = container.Resolve <HelloWorld>();

            helloWorld.Say();

            //Unity 入門 (2)(3)
            //Unity 註冊型別
            //Unity 在解析物件時,會知道應該用 HelloInCHT 來建立物件,而不是 HelloWorld。
            Console.WriteLine("================Unity 入門 (2)(3)==============================");
            container.RegisterType <IHelloWorld, HelloWorldCHT>();
            helloWorld = container.Resolve <IHelloWorld>();
            helloWorld.Say();

            container.RegisterType <IHelloPG, HelloPG>();
            helloWorld = container.Resolve <IHelloWorld>();
            helloWorld.Go();

            IHelloPG helloPG = container.Resolve <IHelloPG>();

            helloPG.Work();

            //Unity 入門 (4)
            //RegisterType 會後蓋前
            //明確指定預設對應
            Console.WriteLine("================Unity 入門 (4)==============================");
            container.RegisterType <IHelloWorld, HelloWorld>();
            container.RegisterType <IHelloWorld, HelloWorldCHT>("CHT");

            IHelloWorld hello1 = container.Resolve <IHelloWorld>();
            IHelloWorld hello2 = container.Resolve <IHelloWorld>("CHT");

            hello1.Go();
            hello2.Go();


            //Unity 入門 (5)
            Console.WriteLine("================Unity 入門 (5)==============================");
            var containerConfig = new UnityContainer();

            containerConfig.LoadConfiguration();
            IHelloWorld hello3 = container.Resolve <IHelloWorld>();
            IHelloWorld hello4 = container.Resolve <IHelloWorld>("CHT");

            hello3.Say();
            hello4.Say();



            Console.ReadKey();
        }
Example #22
0
        static void Main(string[] args)
        {
            var logDir = ConfigurationManager.AppSettings["LogTo"].ToString();

            HelloWorldFactory hwFac = new HelloWorldFactory();
            IHelloWorld       hwAPI = hwFac.CreateInstance(HelloWorldTypes.Console, logDir);

            Console.Write(hwAPI.getMessage());

            Console.ReadKey();
        }
Example #23
0
        static void Main(string[] args)
        {
            var writeLocation = ConfigurationManager.AppSettings["WriteToLocation"];

            HelloWorldFactory fac   = new HelloWorldFactory();
            IHelloWorld       hwAPI = fac.CreateInstance(HelloWorldTypes.Console, writeLocation);

            Console.Write(hwAPI.getGreeting());

            Console.ReadKey();
        }
Example #24
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, IHelloWorld helloWorld)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.Run(async(context) =>
            {
                var hello = helloWorld.GetMessageHelloWorld();
                await context.Response.WriteAsync(hello);
            });
        }
Example #25
0
        public void WriteMessage_NotImplemented()
        {
            HelloWorldFactory fac   = new HelloWorldFactory();
            IHelloWorld       hwAPI = fac.CreateInstance(HelloWorldTypes.Console, "test");

            try {
                hwAPI.writeMessage("test");
            }
            catch (NotImplementedException e)
            {
                Assert.IsTrue(e.Message == "The method or operation is not implemented.");
            }
        }
Example #26
0
 static void Main(string[] args)
 {
     try
     {
         IHelloWorld   actor  = ActorProxy.Create <IHelloWorld>(ActorId.CreateRandom(), new Uri("fabric:/MyActorApplication2/HelloWorldActorService"));
         Task <string> retval = actor.GetHelloWorldAsync();
         Console.Write(retval.Result.ToString());
         Console.ReadLine();
     }
     catch (Exception Ex)
     {
         Console.WriteLine(Ex);
     }
 }
        public HelloWorld(IHelloWorld service)
        {
            // Set the service implementation properties
            m_service = service;

            // Set base service properties
            ServiceNamespace = new WsXmlNamespace("hel", "hello://Microsoft.WCF.Samples.Adapters");
            ServiceID = "urn:uuid:ade3b12c-b46a-4f8f-8da7-4567e405a2bf";
            ServiceTypeName = "HelloWorld";

            // Add service types here
            ServiceOperations.Add(new WsServiceOperation("hello://Microsoft.WCF.Samples.Adapters/HelloWorld", "HelloWorld_SayHelloWorld_InputMessageRequest"));

            // Add event sources here
        }
Example #28
0
        public HelloWorld(IHelloWorld service)
        {
            // Set the service implementation properties
            m_service = service;

            // Set base service properties
            ServiceNamespace = new WsXmlNamespace("hel", "hello://Microsoft.WCF.Samples.Adapters");
            ServiceID        = "urn:uuid:ade3b12c-b46a-4f8f-8da7-4567e405a2bf";
            ServiceTypeName  = "HelloWorld";

            // Add service types here
            ServiceOperations.Add(new WsServiceOperation("hello://Microsoft.WCF.Samples.Adapters/HelloWorld", "HelloWorld_SayHelloWorld_InputMessageRequest"));

            // Add event sources here
        }
        private void AssertCanMockGenericMethodWithSpecifiedTypeParameter(Mock <IGenericHelloWorld> genericHelloWorld)
        {
            const int    iValue = 3;
            const string sValue = "test";

            genericHelloWorld.Stub.Out.Method(_ => _.Method <int>()).Will(Return.Value(iValue));
            genericHelloWorld.Stub.Out.Method(_ => _.Method <string>()).Will(Return.Value(sValue));
            genericHelloWorld.Stub.Out.Method(_ => _.Method <IHelloWorld, bool>()).Will(Return.Value(Mocks.CreateMock <IHelloWorld>().MockObject));

            string      s          = genericHelloWorld.MockObject.Method <string>();
            int         i          = genericHelloWorld.MockObject.Method <int>();
            IHelloWorld helloWorld = genericHelloWorld.MockObject.Method <IHelloWorld, bool>();

            Assert.AreEqual(iValue, i);
            Assert.AreEqual(sValue, s);
            Assert.IsNotNull(helloWorld);
        }
Example #30
0
        static void Main(string[] args)
        {
            Console.WriteLine("通过 命名方式, 获取指定的实例!");

            using (IKernel kernel = new StandardKernel(new MyModulesByName()))
            {
                Console.WriteLine("获取 ChinesePeople ( Chinese 定义在 ChinesePeople 类中 ) !");
                ChinesePeople cp = kernel.Get <ChinesePeople>();
                cp.SayHello();

                Console.WriteLine("获取  EnglishPeople ( English 定义在 EnglishPeople 类中 )!");
                EnglishPeople ep = kernel.Get <EnglishPeople>();
                ep.SayHello();

                Console.WriteLine("直接获取名称为 Chinese 的 IHelloWorld");
                IHelloWorld ic = kernel.Get <IHelloWorld>("Chinese");
                Console.WriteLine(ic.HelloWorld());

                Console.WriteLine("直接获取名称为 English 的 IHelloWorld");
                IHelloWorld ie = kernel.Get <IHelloWorld>("English");
                Console.WriteLine(ie.HelloWorld());
            }



            Console.WriteLine("通过 标签的条件绑定方式, 获取指定的实例!");
            using (IKernel kernel = new StandardKernel(new MyModulesByConstraints()))
            {
                Console.WriteLine("获取标签中包含 EnglishKnowAble 的 HkPeople!");
                HkPeople cp = kernel.Get <HkPeople>();
                cp.SayHello();


                Console.WriteLine("获取标签中包含 EnglishKnowAble 的 JpPeople!");
                JpPeople jp = kernel.Get <JpPeople>();
                jp.SayHello();


                Console.WriteLine("获取标签中包含 ChineseKnowAble 的 TwPeople!");
                TwPeople ep = kernel.Get <TwPeople>();
                ep.SayHello();
            }

            Console.ReadLine();
        }
Example #31
0
        private static void Main(string[] args)
        {
            if (args.Length > 0)
            {
                for (;;)
                {
                    IHelloWorld friend = ActorProxy.Create <IHelloWorld>(ActorId.NewId(), ApplicationName);
                    Console.WriteLine("\n\nFrom Actor {1}: {0}\n\n", friend.SayHello("Good morning!").Result, friend.GetActorId());
                    Thread.Sleep(50);
                }
            }
            else
            {
                IHelloWorld friend = ActorProxy.Create <IHelloWorld>(ActorId.NewId(), ApplicationName);
                Console.WriteLine("\n\nFrom Actor {1}: {0}\n\n", friend.SayHello("Good morning!").Result, friend.GetActorId());
            }

            Console.WriteLine("Press enter to exit ...");
            Console.ReadLine();
        }
Example #32
0
        void Run()
        {
            Uri uri = new Uri(serviceUrl);

            Console.WriteLine("Client is talking to a RequestReply WCF service.");

            ChannelFactory <IHelloWorld> channelFactory = new ChannelFactory <IHelloWorld>(new BasicHttpBinding());
            IHelloWorld clientService = channelFactory.CreateChannel(new EndpointAddress(uri));

            Console.Write("Type what you want to say to the server: ");
            string greeting = Console.ReadLine();

            for (int i = 0; i < count; i++)
            {
                string reply = clientService.Hello(greeting);
                Console.WriteLine("Server replied: {0}", reply);
            }

            ((IChannel)clientService).Close();
            channelFactory.Close();
        }
 public HelloWorldController(IGrainFactory client)
 {
     _client = client;
     _grain  = _client.GetGrain <IHelloWorld>(0);
 }
Example #34
0
 public HotfixEntry(IHelloWorld helloWorld)
 {
     HelloWorld = helloWorld;
 }
 public static SurrogateForIHelloWorld Convert(IHelloWorld value)
 {
     if (value == null) return null;
     return new SurrogateForIHelloWorld { Target = ((HelloWorldRef)value).Target };
 }
Example #36
0
 public HelloWorldController(IClusterClient client)
 {
     this._client = client;
     this._grain  = this._client.GetGrain <IHelloWorld>(0);
 }