public static void InitializeSqlMapper() { if (_sqlmapper == null) { lock (typeof(IBatisNet.DataMapper.SqlMapper)) { //if (_sqlmapper == null) // double-check //{ IBatisNet.Common.Utilities.ConfigureHandler handler = new IBatisNet.Common.Utilities.ConfigureHandler(Configure); IBatisNet.DataMapper.Configuration.DomSqlMapBuilder builder = new IBatisNet.DataMapper.Configuration.DomSqlMapBuilder(); #if DEBUG try { _sqlmapper = builder.ConfigureAndWatch("Book.SQLServer.SQLMap.config", handler); } catch (Exception ex) { throw ex; } #else _sqlmapper = builder.ConfigureAndWatch("Book.SQLServer.SQLMap.config", handler); #endif // } } } }
public static ISqlMapper GetMapper(string name) { lock (Locker) { if (Mappers.ContainsKey(name)) { return(Mappers[name]); } } var resource = name; var section = ConfigurationManager.GetSection("StoneIBatisMappers") as StoneIBatisMappers; if (section != null && section.Count > 0) { var m = section.FindLast(map => map.Name == name); resource = m.File; } lock (Locker) { if (Mappers.ContainsKey(name)) { return(Mappers[name]); } var mapper = new iBatis.DataMapper.Configuration.DomSqlMapBuilder().Configure(resource); mapper.SessionStore = new HybridWebThreadSessionStore(mapper.Id); Mappers.Add(name, mapper); return(mapper); } }
private IBatisNet.DataMapper.ISqlMapper CreateMapper(string propertiesFile) { string databaseFile = Path.Combine(_binPath, "db.Config"); XmlDocument xmlConfig = new XmlDocument(); xmlConfig.Load(databaseFile); XmlNamespaceManager nsmgr = new XmlNamespaceManager(xmlConfig.NameTable); nsmgr.AddNamespace("ab", "http://ibatis.apache.org/dataMapper"); xmlConfig.SelectSingleNode("/ab:sqlMapConfig/ab:properties/@resource", nsmgr).Value = propertiesFile; IBatisNet.DataMapper.Configuration.DomSqlMapBuilder builder = new IBatisNet.DataMapper.Configuration.DomSqlMapBuilder(); return(builder.Configure(xmlConfig)); }
private static int Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); jingxian.install.DbInsteller installer = new jingxian.install.DbInsteller(); if (!installer.Instell(true)) { return(-1); } System.Threading.Thread.CurrentThread.Name = "jingxian GUI main"; //NON-NLS-1 log4net.ILog log = null; CommandLineArguments arguments = new CommandLineArguments(args); if (!arguments.Succeeded) { // TODO write out error info System.Console.WriteLine(arguments.GetUsage()); return(1); } else { if (RuntimeConfiguration.Instance.EnableLogging && !arguments.IsVerboseDefined) { Logging.ConfigureLog4net(typeof(Bootstrap)); log = log4net.LogManager.GetLogger(typeof(Bootstrap)); log.Debug("Starting..."); } } string binDirectory = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); IBatisNet.DataMapper.Configuration.DomSqlMapBuilder builder = new IBatisNet.DataMapper.Configuration.DomSqlMapBuilder(); domainModel.SessionFactory.Mapper = builder.Configure(System.IO.Path.Combine(binDirectory, "db.Config")); Dictionary <string, object> context = new Dictionary <string, object>(); context["startPerspective"] = jingxian.ui.Constants.PerspectiveId; context["layoutProvider"] = jingxian.ui.LayoutProvider.PageLayoutProviderPointId; int exitCode = RuntimeConfiguration.Instance.ShowSplashScreen ? PlatformLauncher.Launch(new ProductProvider(), context) : PlatformRuntime.Launch(new ProductProvider(), arguments, context); string msg = string.Format("Exited with code {0}.", exitCode); if (log != null) { if (exitCode == 0) { log.Debug(msg); } else { log.Error(msg); } } else { System.Console.WriteLine(msg); } return(exitCode); }