private void button1_Click(object sender, EventArgs e) { ITest1 test1 = PMY.Remoting.Common.RemotingObjFactory.Test1; ITest2 test2 = PMY.Remoting.Common.RemotingObjFactory.Test2; MessageBox.Show(test1.Test()); MessageBox.Show(test2.Test()); }
static void Main(string[] args) { var dual = new Dual(); ITest test = dual; test.Test(); ITest2 test2 = dual; test2.Test(); Console.ReadLine(); }
static void Main(string[] args) { Console.WriteLine("Hello World!"); ContainerBuilder builder = new ContainerBuilder(); builder.RegisterType <Test>().As <ITest1>().InstancePerLifetimeScope(); builder.RegisterType <Test2>().As <ITest2>().InstancePerLifetimeScope(); var container = builder.Build(); // ITest1 t = container.Resolve<ITest1>(); Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")); ITest2 t2 = container.Resolve <ITest2>(); Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")); t2.Test(); Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")); Console.Read(); }