using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Sdaleo.Systems.Advantage
{
///
/// Handles SQL CE Credentials, to be
/// used by all our SQL CE Functions
///
public class AdvantageCredential : IComparable, ICloneable, IConnectDb
{
#region IConnectDb
///
/// Let Callers know this is a SQLCE Connection Object
///
public DBSystem DBType { get { return DBSystem.ADVANTAGE; } }
///
/// Check to see if the Credential Object consists of valid input
///
public bool IsValid
{
get
{
if (!ValidationConsts.IsValidFileNameNPath(DataSource))
return false;
// For ADS i believe we always want a user and Password
//if (!String.IsNullOrEmpty(_UDL.Password) && !ValidationConsts.Generic.IsValidPassword(_UDL.Password))
// return false;
return true;
}
}
///
///
///
public string ConnectionString { get { return _UDL.ConnectionString; } }
///
/// SQL CE uses the File Name and Path as the Datasource
///
public string DataSource { get { return _UDL.DataSource; } }
///
/// SQL CE doesn't use User
///
public string User { get { return _UDL.Username; } }
///
/// SQL CE doesn't support DBMS like behaviors
///
public bool SupportsDBMS { get { return false; } }
///
/// SQL CE doesn't support DBMS like behaviors
///
public IamDBMS DBMS { get { return null; } }
///
/// SQL CE doesn't support Timeouts
///
public bool SupportsTimeouts { get { return false; } }
///
/// SQL CE doesn't support Timeouts
///
public IsupportTimeouts Timeouts { get { return null; } }
#endregion
private UDL _UDL = null;
#region AdvantageCredential Credential Constructors
///
/// Create a SQL CE Connection from an UDL Object
///
///
internal AdvantageCredential(UDL udl)
{
if (udl != null)
_UDL = udl;
}
///
/// Create an Untrusted SQLCE Credential * No Encryption Used *
///
public AdvantageCredential(string FileNameNPath)
{
_UDL = new UDL(FileNameNPath, String.Empty);
}
///
/// Create a Trusted SQLCE Credential * Encryption Used *
///
public AdvantageCredential(string FileNameNPath, string strPassword)
{
_UDL = new UDL(FileNameNPath, strPassword);
}
#endregion
#region ICloneable Members
public object Clone()
{
AdvantageCredential credential = new AdvantageCredential((UDL)this._UDL.Clone());
return credential;
}
#endregion
#region IComparable Members
public int CompareTo(object obj)
{
AdvantageCredential otherCredential = obj as AdvantageCredential;
if (otherCredential != null)
{
int nCompare = _UDL.CompareTo(otherCredential._UDL);
return nCompare;
}
else
{
throw new ArgumentException("Object is not a AdvantageCredential");
}
}
#endregion
}
}