コード例 #1
0
 private List <ConnectionSetting> Load()
 {
     if (list == null)
     {
         list = new List <ConnectionSetting>();
         try
         {
             string filename = "connectionsettings.config";
             string fullpath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, filename);
             if (File.Exists(fullpath))
             {
                 string   text = File.ReadAllText(fullpath);
                 XElement root = XElement.Parse(text);
                 foreach (var item in root.Elements("ConnectionSetting"))
                 {
                     ConnectionSetting cs = new ConnectionSetting();
                     cs.Provider         = (DatabaseType)Enum.Parse(typeof(DatabaseType), item.Element("Provider").Value);
                     cs.Name             = item.Element("Name").Value;
                     cs.ConnectionString = item.Element("ConnectionString").Value;
                     list.Add(cs);
                 }
             }
         }
         catch (Exception ex)
         {
             Console.WriteLine(ex.Message);
             Console.WriteLine(ex.StackTrace);
             return(list);
         }
     }
     return(list);
 }
コード例 #2
0
 public CodeBuilder(string[] tables, string table_name, string template_name, string @namespace, Entities.ConnectionSetting setting)
 {
     this._template_name = template_name;
     this._namespace     = @namespace;
     this._table_name    = table_name;
     this._setting       = setting;
     this._tables        = tables;
 }
コード例 #3
0
        private static List <ITableSchema> GetAllTableSchema(Entities.ConnectionSetting setting, string[] tables, string guid)
        {
            if (tableSchemas.Count > 0 && flag == guid)
            {
                return(tableSchemas);
            }
            flag = guid;
            int count = tables.Length;
            int step  = 100 % count == 0 ? 100 / count : 100 / count + 1;

            tableSchemas.Clear();
            foreach (string name in tables)
            {
                DataFactory  fac = DatabaseResolver.GetDataFactory(setting);
                ITableSchema its = fac.GetTableSchema(name);
                tableSchemas.Add(its);
                ExtendFunctions.OnProcess(step);
            }
            return(tableSchemas);
        }
コード例 #4
0
 public ConnectionSettingCollection Add(ConnectionSetting setting)
 {
     this._settings.Add(setting);
     Save2File();
     return(this);
 }
コード例 #5
0
 public void Remove(ConnectionSetting cs)
 {
     this._settings.Remove(cs);
     Save2File();
 }