#region Apache Notice
/*****************************************************************************
* $Revision$
* $LastChangedDate$
* $LastChangedBy$
*
* iBATIS.NET Data Mapper
* Copyright (C) 2006/2005 - The Apache Software Foundation
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
********************************************************************************/
#endregion
#region Using
using System;
using System.Xml.Serialization;
#endregion
namespace IBatisNet.Common
{
///
/// Information about a data source.
///
[Serializable]
[XmlRoot("dataSource", Namespace="http://ibatis.apache.org/dataMapper")]
public class DataSource : IDataSource
{
#region Fields
[NonSerialized]
private string _connectionString = string.Empty;
[NonSerialized]
private IDbProvider _provider;
[NonSerialized]
private string _name = string.Empty;
#endregion
#region Properties
///
/// The connection string.
///
[XmlAttribute("connectionString")]
public virtual string ConnectionString
{
get { return _connectionString; }
set
{
CheckPropertyString("ConnectionString", value);
_connectionString = value;
}
}
///
/// DataSource Name
///
[XmlAttribute("name")]
public string Name
{
get { return _name; }
set
{
CheckPropertyString("Name", value);
_name = value;
}
}
///
/// The provider to use for this data source.
///
[XmlIgnore]
public virtual IDbProvider DbProvider
{
get { return _provider; }
set { _provider = value; }
}
#endregion
#region Constructor (s) / Destructor
///
/// Constructor
///
public DataSource()
{
}
#endregion
#region Methods
private void CheckPropertyString(string propertyName, string value)
{
if (value == null || value.Trim().Length == 0)
{
throw new ArgumentException(
"The "+propertyName+" property cannot be " +
"set to a null or empty string value.", propertyName);
}
}
///
/// ToString implementation.
///
/// A string that describes the data source
public override string ToString()
{
return "Source: ConnectionString : "+ConnectionString;
}
#endregion
}
}