zoukankan      html  css  js  c++  java
  • spring依赖注入

    参考

    http://www.cnblogs.com/han1982/p/4177850.html

    http://blog.csdn.net/fax5201314/article/details/8777298

    http://www.tuicool.com/articles/zI7Rzy

      <sectionGroup name="spring">
          <section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core" />
          <section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core" />
        </sectionGroup>
      
      </configSections>
    
      <spring>
        <context>
          <!--<resource uri="assembly://namespace/project/Objects.xml"/>-->
          <!--<resource uri="file://objects.xml"/>-->
          <resource uri="config://spring/objects" />
        </context>
    
        <objects>   
          <object id="BLLSession" type="BLL.BLLSession,BLL" singleton="false"></object>
          <object id="DBSessionFactory" type="DALMSSQL.DBSessionFactory,DALMSSQL"></object>
        </objects>
      </spring>
     public class SpringHelper
        {
            private static IApplicationContext SpringContext
            {
                get { return ContextRegistry.GetContext(); }
            }
    
            public static T GetObject<T>(string objName) where T : class
            {
                return SpringContext.GetObject(objName) as T;
            }
        }
     IDAL.IDBSessionFactory sessionFactory = DI.SpringHelper.GetObject<IDAL.IDBSessionFactory>("DBSessionFactory");
    
                        iDBSession = sessionFactory.GetDBSession();
    
    
    
    
    IBLL.IBLLSession ibllSession = DI.SpringHelper.GetObject<IBLL.IBLLSession>("BLLSession");
                IBLL.IProductBLL ibll = ibllSession.IProductBLL;
                var list = ibll.GetListBy(a => a.ID >= 0).ToList();
  • 相关阅读:
    binary and out mode to open a file
    ADV7482&TP2825开发之总结
    C++ 操作符重载
    OpenCV学习(一)基础篇
    Linux设备驱动程序 第三版 读书笔记(一)
    My First Linux Module
    Bitmap每个像素值由指定的掩码决定
    C++ File Binary
    Bitmap RGB24 4字节对齐
    查看binlog的简单方法!
  • 原文地址:https://www.cnblogs.com/tgdjw/p/4680650.html
Copyright © 2011-2022 走看看