using System;
using System.Xml.Serialization;
using System.Configuration;
namespace Bzfc.Components
{
/// <summary>
/// Globals 的摘要说明。
/// </summary>
///
public class Globals
{
public Globals()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
public static IDTOProvider DbProvider
{
get
{
return DTOProvider.Instance();
}
}
}
//返回DTOProviderConfiguration.Instance()
public class DTOProvider
{
private DTOProvider(){}
static DTOProvider()
{
DTOProviderConfiguration dtoPC = Config.Settings.WebProviders.DTOProvider;
idto = (IDTOProvider)dtoPC.Instance();
}
private static IDTOProvider idto = null;
public static IDTOProvider Instance()
{
return idto;
}
}
public class DbProvider
{
private DbProvider()
{
}
static DbProvider()
{
DbProviderConfiguration dpc = Config.Settings.WebProviders.DbProvider;
dp = (IDbProvider)dpc.Instance();
}
private static IDbProvider dp = null;
public static IDbProvider Instance()
{
return dp;
}
}
public class DataDTOProvider : IDTOProvider
{
public bool AddUser()
{
return DbProvider.Instance().AddUser();
}
}
/// <summary>
/// Config.Setting = WebConfigurationSettings.Instance();
/// </summary>
public class Config
{
public Config()
{
}
public static WebConfigurationSettings Settings
{
get
{
return WebConfigurationSettings.Instance();
}
}
}
/// <summary>
/// WebConfigurationSettings.Instance();
/// </summary>
[Serializable]
public class WebConfigurationSettings
{
public WebConfigurationSettings()
{
}
public static WebConfigurationSettings Instance()
{
return ((WebConfigurationSettings)ConfigurationSettings.GetConfig("WebConfigurationSettings"));
}
private WebProviders _webProviders;
public WebProviders WebProviders
{
get {return this._webProviders;}
set {this._webProviders = value;}
}
}
[XmlRoot("DTOProvider")]
public class DTOProviderConfiguration : BaseProvider
{
public DTOProviderConfiguration()
{
//
// TODO: Add constructor logic here
//
}
}
public abstract class BaseProvider
{
public BaseProvider()
{
//
// TODO: Add constructor logic here
//
}
//public abstract object Instance();
private string _type;
[XmlAttribute("type")]
public string ProviderType
{
get { return _type; }
set { _type = value; }
}
public object Instance()
{
return Activator.CreateInstance(System.Type.GetType(this.ProviderType));
}
}
/// <summary>
/// DTOProvider
/// </summary>
public class WebProviders
{
public WebProviders()
{
}
private DTOProviderConfiguration _dTOProvider;
public DTOProviderConfiguration DTOProvider
{
get {return this._dTOProvider;}
set {this._dTOProvider = value;}
}
private DbProviderConfiguration _dbProvider;
public DbProviderConfiguration DbProvider
{
get {return this._dbProvider;}
set {this._dbProvider = value;}
}
}
[XmlRoot("DbProvider")]
public class DbProviderConfiguration : BaseProvider
{
public DbProviderConfiguration()
{
}
private string _connectionString;
[XmlAttribute("connectionString")]
public string ConnectionString
{
get {return this._connectionString;}
set {this._connectionString = value;}
}
}
}