internal static void LoadAllDataCommandFiles()
        {
            DataCommandFileList fileList = ConfigHelper.LoadSqlConfigListFile();

            if (fileList == null || fileList.FileList == null || fileList.FileList.Length <= 0)
            {
                s_ConfigCache = new Dictionary <string, DataCommandConfig>(0);
                return;
            }
            Dictionary <string, DataCommandConfig> cache = new Dictionary <string, DataCommandConfig>();

            foreach (var file in fileList.FileList)
            {
                string path = file.FileName;
                string root = Path.GetPathRoot(path);
                if (root == null || root.Trim().Length <= 0)
                {
                    path = Path.Combine(ConfigHelper.ConfigFolder, path);
                }
                DataOperations op = ConfigHelper.LoadDataCommandList(path);
                if (op != null && op.DataCommand != null && op.DataCommand.Length > 0)
                {
                    foreach (var da in op.DataCommand)
                    {
                        if (cache.ContainsKey(da.Name))
                        {
                            throw new ApplicationException("Duplicate name '" + da.Name + "' for data command in file '" + path + "'.");
                        }
                        cache.Add(da.Name, da);
                    }
                }
            }
            s_ConfigCache = cache;
        }
Exemple #2
0
        private static Dictionary <string, DataCommandConfig> GetAllDataCommandConfigInfos(out List <string> configFileList)
        {
            DataCommandFileList fileList = ConfigHelper.LoadSqlConfigListFile();

            if (fileList == null || fileList.FileList == null || fileList.FileList.Length <= 0)
            {
                configFileList = new List <string>(1);
                return(new Dictionary <string, DataCommandConfig>(0));
            }
            configFileList = new List <string>(fileList.FileList.Length + 1);
            Dictionary <string, DataCommandConfig> cache = new Dictionary <string, DataCommandConfig>();

            foreach (var file in fileList.FileList)
            {
                string path = file.FileName;
                string root = Path.GetPathRoot(path);
                if (root == null || root.Trim().Length <= 0)
                {
                    path = Path.Combine(ConfigHelper.ConfigFolder, path);
                }
                if (!string.IsNullOrWhiteSpace(path) && File.Exists(path))
                {
                    configFileList.Add(path);
                }
                DataOperations op = ConfigHelper.LoadDataCommandList(path);
                if (op != null && op.DataCommand != null && op.DataCommand.Length > 0)
                {
                    foreach (var da in op.DataCommand)
                    {
                        if (cache.ContainsKey(da.Name))
                        {
                            throw new ApplicationException("Duplicate name '" + da.Name + "' for data command in file '" + path + "'.");
                        }
                        cache.Add(da.Name, da);
                    }
                }
            }
            return(cache);
        }