I proposed

public

static XmlDocument GetConfigAsXmlDocument(string path)
{
XmlDocument config =
new XmlDocument();
XmlTextReader reader =
null;

try
{
if (File.Exists(path))
{
reader =
new XmlTextReader( path );
}
else
{
reader =
new XmlTextReader(Path.Combine (_baseDirectory, path));
}
config.Load(reader);
}


 
On 5/24/05, Ron Grabowski <[EMAIL PROTECTED]> wrote:
I think the existing signature:

ConfigureAndWatch(string, ConfigureHandler)

should continue to work the way it does with regards to the file path
being relative to the application's base directory. A new overrload
could be added:

ConfigureAndWatch(FileInfo, ConfigureHandler)

That would allow you pass in a file from wherever you wanted. The
Resources class may need the following method added too:

GetConfigAsXmlDocument(FileInfo)

because:

GetConfigAsXmlDocument(string)

is relative to the application's base directory.

You may want to create a sub-task from this issue becuase the two
issues seem to be related:

http://issues.apache.org/jira/browse/IBATISNET-31

--- Bob Hanson <[EMAIL PROTECTED] > wrote:
> I was not subscribed to this list. Thanks for pointing it out Ron.
> I'm
> emailing here first before opening a Jira issue. LMK if  should just
> go to Jira first in the future.
>
> I just downloaded and attempted to use 1.1.0.458.
>
> IBatisNet.DataMapper.SqlMapper still does not support a non project
> relative filename.
>
> I create separate Mapper singletons for each of my databases used in
> my DAL. I then make a call like:
> _mapper = SqlMapper.ConfigureAndWatch(@"c:/Web Services/DB
> Configuration/Transmission/TransmissionMap.config", handler);
>
> ConfigurateAndWatch calls
> IBatisNet.Common.Utilities.Resources.GetConfigAsXmlDocument() which
> assumes a project relative filename.
>
> My previous version hack looks like:
>               public static XmlDocument GetConfigAsXmlDocument(string fileName)
>               {
>                       XmlDocument config = new XmlDocument();
>
>                       try
>                       {
>                               XmlTextReader reader;
>                               if ((fileName[1] == ':' && fileName[2] == '\\') || fileName[0] ==
> '\\' ||
>                                       fileName.ToLower().Substring(0, 7) == "file://")
>                               { // detects paths starting with drive:, \, \\
>                                       reader = new XmlTextReader(fileName);
>                               }
>                               else
>                               {
>                                       reader = new XmlTextReader(_baseDirectory +
> Path.DirectorySeparatorChar + fileName);
>                               }
>                               config.Load(reader);
>                               reader.Close();
>                       }
>                       catch(Exception e)
>                       {
>                               throw new ConfigurationException(
>                                       string.Format("Unable to load config file \"{0}\". Cause : ",
>                                       fileName,
>                                       e.Message  ) ,e);
>                       }
>
>                       return config;
>               }
>

Reply via email to