关闭

这段程序谁能看的懂啊?

670人阅读 评论(0) 收藏 举报

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;}
  }

 }

}

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:28051次
    • 积分:578
    • 等级:
    • 排名:千里之外
    • 原创:31篇
    • 转载:5篇
    • 译文:0篇
    • 评论:4条
    文章分类
    最新评论