You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ibatis.apache.org by gb...@apache.org on 2005/05/24 20:27:29 UTC
svn commit: r178229 -
/incubator/ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Resources.cs
/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapper.cs
Author: gbayon
Date: Tue May 24 11:27:27 2005
New Revision: 178229
URL: http://svn.apache.org/viewcvs?rev=178229&view=rev
Log:
- Improved loading of config file via relative or absolut file path.
Modified:
incubator/ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Resources.cs
incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapper.cs
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Resources.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Resources.cs?rev=178229&r1=178228&r2=178229&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Resources.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Resources.cs Tue May 24 11:27:27 2005
@@ -99,22 +99,30 @@
/// Get config file from from the base directory that the assembler
/// used for probe assemblies
/// </summary>
- /// <param name="fileName"></param>
+ /// <param name="path"></param>
/// <returns></returns>
- public static XmlDocument GetConfigAsXmlDocument(string fileName)
+ public static XmlDocument GetConfigAsXmlDocument(string path)
{
XmlDocument config = new XmlDocument();
XmlTextReader reader = null;
+
try
{
- reader = new XmlTextReader(Path.Combine(_baseDirectory, fileName));
+ if (File.Exists(path))
+ {
+ reader = new XmlTextReader( path );
+ }
+ else
+ {
+ reader = new XmlTextReader(Path.Combine(_baseDirectory, path));
+ }
config.Load(reader);
}
catch(Exception e)
{
throw new ConfigurationException(
string.Format("Unable to load config file \"{0}\". Cause : {1}",
- fileName,
+ path,
e.Message ) ,e);
}
finally
Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapper.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapper.cs?rev=178229&r1=178228&r2=178229&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapper.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapper.cs Tue May 24 11:27:27 2005
@@ -24,28 +24,25 @@
********************************************************************************/
#endregion
-#region Imports
+#region Using
+
using System;
-using System.Data;
-using System.IO;
-using System.Text;
using System.Collections;
using System.Collections.Specialized;
+using System.Data;
+using System.Text;
using System.Threading;
using System.Xml;
-
using IBatisNet.Common;
-using IBatisNet.Common.Exceptions;
using IBatisNet.Common.Utilities;
-using IBatisNet.DataMapper.SessionContainer;
-
using IBatisNet.DataMapper.Configuration;
using IBatisNet.DataMapper.Configuration.Alias;
+using IBatisNet.DataMapper.Configuration.Cache;
using IBatisNet.DataMapper.Configuration.ParameterMapping;
using IBatisNet.DataMapper.Configuration.ResultMapping;
-using IBatisNet.DataMapper.Configuration.Cache;
using IBatisNet.DataMapper.Exceptions;
using IBatisNet.DataMapper.MappedStatements;
+using IBatisNet.DataMapper.SessionContainer;
using IBatisNet.DataMapper.TypeHandlers;
#endregion
@@ -147,7 +144,7 @@
internal SqlMapper(TypeHandlerFactory typeHandlerFactory)
{
_typeHandlerFactory = typeHandlerFactory;
- _sessionContainer = SessionContainerFactory.GetSessionContainer(IBatisNet.Common.Utilities.HashCodeProvider.GetIdentityHashCode(this).ToString());
+ _sessionContainer = SessionContainerFactory.GetSessionContainer(HashCodeProvider.GetIdentityHashCode(this).ToString());
}
#endregion
@@ -196,8 +193,9 @@
/// <summary>
/// Configure an SqlMap from via a file.
/// </summary>
- /// <param name="fileName">File name.</param>
+ /// <param name="fileName">A path to a file name.</param>
/// <returns>An SqlMap</returns>
+ /// <remarks>If you pass a relative file path, if will be relative to your Application root.</remarks>
public static SqlMapper Configure(string fileName)
{
XmlDocument document = Resources.GetConfigAsXmlDocument(fileName);