火焰

valeb
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

spring spring.core IOC xml 注册

Posted on 2023-08-14 18:40  valeb  阅读(7)  评论(0编辑  收藏  举报
    public class SpringUtils
    {
        static IApplicationContext context;

        public static T GetObject<T>(string name) where T : class
        {
            if(context == null)
            { 
                 context  = new  XmlApplicationContext("file://objects.xml"); 
            }
            return context.GetObject<T>(name); 
        } 
    }

  

<?xml version="1.0" encoding="utf-8" ?> 
<objects xmlns="http://www.springframework.net">
	<object id="BusinessSession" type="Game.Platform.Service.BusinessSession,Game.Platform.Service" singleton="false"/> 
	<object id="DataSessionFactory" type="Game.Platform.Repository.DataSessionFactory,Game.Platform.Repository" singleton="false"/>
</objects>