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>
标签:xml,core,name,spring,context,IOC,class From: https://www.cnblogs.com/valeb/p/17629465.html