C#技术百科
问问你的心你有没有信心 做事情要专一坚定,执着
  static StoredScript()
      {
          if (DatabaseFactory.DefaultProviderName == DatabaseFactory.OleDbProvider)
              PopulateScriptFromProvider(typeof(OleDbScriptProvider));
          else if (DatabaseFactory.DefaultProviderName == DatabaseFactory.OracleClientProvider)
              PopulateScriptFromProvider(typeof(OracleScriptProvider));
          else if (DatabaseFactory.DefaultProviderName == DatabaseFactory.SqlClientProvider)
              PopulateScriptFromProvider(typeof(SqlScriptProvider));
          else
              throw new NotSupportedException(DatabaseFactory.DefaultProviderName);
      }
      /// <summary>
      /// 初使化SQL字典
      /// </summary>
      /// <param name="type"></param>
      private static  void PopulateScriptFromProvider(Type type)
      {
        PropertyInfo[] propertys= type.GetProperties();
        object instance = Activator.CreateInstance(type);
        foreach (PropertyInfo prop in propertys)
        {
            object propValue = prop.GetValue(instance, null);
            if (propValue != null)
                _keySql.Add(prop.Name, propValue.ToString());
        }
      }
posted on 2011-02-23 18:04  王德田  阅读(386)  评论(0编辑  收藏  举报