public static IDao CreateFromSetting() { var dao = new Dao(); dao.ProviderName = "System.Data.SqlClient"; dao.ConnectionString = GetConnectionString(); return dao; }
public static IDao Create(string name = "Default") { if (File.Exists(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Setting.xml"))) { return CreateFromSetting(); } var cnss = ConfigurationManager.ConnectionStrings[name]; if (cnss == null) { throw new ArgumentException(string.Format("ConnectionString Not Found! name:{0}", name), "name"); } var dao = new Dao(); dao.ProviderName = cnss.ProviderName; dao.ConnectionString = cnss.ConnectionString; return dao; }