示例#1
0
 private void BtnService2_Click(object sender, EventArgs e)
 {
     using (ILifetimeScope lifetimeScope = container.BeginLifetimeScope())
     {
         IService2 service = null;
         for (int i = 0; i < 3; i++)
         {
             service = lifetimeScope.Resolve <IService2>();
             service.SetUserName(service.GetUserName() + ".");
         }
         MessageBox.Show(service.GetUserName());
     }
 }