예제 #1
0
        public static void Register(string connectionStringName)
        {
            DbSetting setting;
            if (!cache.TryGetValue(connectionStringName, out setting))
            {
                setting = new DbSetting();

                setting.ConnectionString = ConfigurationManager.ConnectionStrings[connectionStringName].ConnectionString;
                int index = setting.ConnectionString.LastIndexOf('/');
                if (index < 0)
                {
                    throw new ArgumentException("wrong connection string setting of mongodb!");
                }
                setting.DbName = setting.ConnectionString.Substring(index + 1);

                cache[connectionStringName] = setting;
            }
        }
예제 #2
0
        internal static bool GetDbSetting(string connectionStringName, out DbSetting setting)
        {
            setting = null;
            if (string.IsNullOrEmpty(connectionStringName))
            {
                if (cache.Count > 0)
                {
                    setting = cache.First().Value;
                }
                else
                {
                    return(false);
                }
            }
            else if (!cache.TryGetValue(connectionStringName, out setting))
            {
                return(false);
            }

            return(true);
        }
예제 #3
0
        internal static bool GetDbSetting(string connectionStringName, out DbSetting setting)
        {
            setting = null;
            if (string.IsNullOrEmpty(connectionStringName))
            {
                if (cache.Count > 0)
                {
                    setting = cache.First().Value;
                }
                else
                {
                    return false;
                }
            }
            else if (!cache.TryGetValue(connectionStringName, out setting))
            {
                return false;
            }

            return true;
        }