spring spring.core IOC xml 注册

发布时间 2023-08-14 18:48:55作者: valeb
    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>