예제 #1
0
        static void Main(string[] args)
        {
            IApplicationContext ctx = ContextRegistry.GetContext();
            IUserInfoDal        u   = ctx.GetObject("UserInfoDal") as IUserInfoDal;

            // UserInfoService u = ctx.GetObject("UserInfoService") as UserInfoService;
            u.Show();
            Console.ReadKey();
        }
예제 #2
0
        static void Main(string[] args)
        {
            IApplicationContext ctx = ContextRegistry.GetContext();

            IUserInfoDal UserInfoDal = ctx.GetObject("UserInfoDal") as IUserInfoDal;

            UserInfoDal.Show();
            Console.ReadKey();
        }
예제 #3
0
파일: Program.cs 프로젝트: pstoh/Pstoh.OA
        static void Main(string[] args)
        {
            IApplicationContext ac = ContextRegistry.GetContext();
            //IUserInfoDal dall = ac.GetObject("UserInfoDal") as IUserInfoDal;
            IUserInfoDal dall2 = ac.GetObject("UserInfoDal1") as IUserInfoDal;

            dall2.Show();

            UserInfoServce dal3 = ac.GetObject("UserInfoServce") as UserInfoServce;

            dal3.Show();
            Console.ReadLine();
        }
예제 #4
0
파일: Program.cs 프로젝트: wxm001/Wei.OA
        static void Main(string[] args)
        {
            //传统的
            //IUserInfoDal userInfoDal=new UserInfoDal();
            //userInfoDal.Show();

            //做容器创建实例
            //初始化容器
            IApplicationContext context = ContextRegistry.GetContext();
            IUserInfoDal        dal     = context.GetObject("UserInfoDal") as IUserInfoDal;

            dal.Show();

            Console.ReadKey();
        }
예제 #5
0
        public ActionResult Index()
        {
            //IOC
            IApplicationContext ctx   = ContextRegistry.GetContext();
            IUserInfoDal        efDal = ctx.GetObject("UserInfoDal") as IUserInfoDal;
            var a = efDal.Show();

            IUserInfoDal adoDal = ctx.GetObject("UserInfoDal2") as IUserInfoDal;

            adoDal.Show();

            //DI
            var a1 = UserInfoDal;
            var a2 = UserName;


            return(View());
        }
예제 #6
0
        static void Main(string[] args)
        {
            //IUserInfoDal userInfoDal=new UserInfoDal();
            //userInfoDal.Show();

            //容器创建
            IApplicationContext ctx = ContextRegistry.GetContext();
            IUserInfoDal        dal = ctx.GetObject("UserInfoDal") as IUserInfoDal;

            dal.Show();

            IUserInfoDal dal1 = ctx.GetObject("UserInfoDal1") as IUserInfoDal;

            dal1.Show();

            //UserInfoService userInfoService=((IObjectFactory) ctx).GetObject("UserInfoService") as UserInfoService;
            //userInfoService.Show();


            Console.ReadKey();
        }
예제 #7
0
        static void Main(string[] args)
        {
            //控制权没有反转
            //IUserInfoDal infoDal = new EFUserInfoDal();

            //Spring.Net 创建实例的方式转为容器帮我们创建
            //第一步,引用Spring.Net程序集 Spring.Core.dll 和 Common.Logging.dll
            //第二步,添加Spring.Net配置节点
            //第三步,配置object节点
            //第四步,创建spring容器上下文

            IApplicationContext ctx = ContextRegistry.GetContext();
            //第五步,通过容器创建对象
            IUserInfoDal efDal = ctx.GetObject("UserInfoDal") as IUserInfoDal;

            efDal.Show();

            IUserInfoDal adoDal = ctx.GetObject("UserInfoDal2") as IUserInfoDal;

            adoDal.Show();

            Console.ReadKey();
        }
예제 #8
0
        static void Main(string[] args)
        {
            IUserInfoDal userInfoDal = new UserInfoDal("x");

            userInfoDal.Show();

            Console.WriteLine("---------1---------");

            //下面用容器来创建UserInfoDal的实例

            // 第一步: 初始化容器
            IApplicationContext ctx = ContextRegistry.GetContext();

            // 创建对象
            IUserInfoDal efdal = ctx.GetObject("EFUserInfoDal") as IUserInfoDal;

            efdal.Show();

            Console.WriteLine("--------2----------");

            // xml配置文件中配置的文件
            IUserInfoDal dal = ctx.GetObject("UserInfoDal") as IUserInfoDal;

            dal.Show();

            Console.WriteLine("---------3---------");

            //
            UserInfoService userInfoServive = ctx.GetObject("UserInfoService") as UserInfoService;

            userInfoServive.Show();

            Console.WriteLine("---------4---------");

            Console.ReadKey();
        }
예제 #9
0
        static void Main(string[] args)
        {
            //IUserInfoDal userInfoDal =new UserInfoDal();
            //userInfoDal.Show();

            //下面走一个容器来 创建UserInfoDal实例

            //第一步  初始化容器
            IApplicationContext ctx = ContextRegistry.GetContext();

            //IUserInfoDal dal = ctx.GetObject("UserInfoDal") as IUserInfoDal;
            //dal.Show();

            IUserInfoDal dal1 = ctx.GetObject("UserInfoDal1") as IUserInfoDal;

            dal1.Show();

            //UserInfoServce userInfoServce = ctx.GetObject("UserInfoServce") as UserInfoServce;

            //userInfoServce.Show();


            Console.ReadKey();
        }