Exemplo n.º 1
0
        /// <summary>
        /// 数据库URL
        /// </summary>
        /// <param name="url">数据库URL字符串</param>
        public MagpieUrl(string url)
        {
            var builder = new MagpieUrlBuilder(url);

            _serverSettings = builder.ToServerSettings();
            _url            = builder.ToString();
        }
Exemplo n.º 2
0
        /// <summary>
        /// 根据数据库配置生成数据库服务器
        /// </summary>
        /// <param name="settings">数据库配置</param>
        /// <returns>数据库服务器</returns>
        public static MagpieServer Create(MagpieServerSettings settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }

            lock (__staticLock)
            {
                MagpieServer server;
                if (!__servers.TryGetValue(settings, out server))
                {
                    if (__servers.Count >= MaxServerCount)
                    {
                        var message = string.Format(CultureInfo.InvariantCulture, "Already created {0} servers which is the maximum number of servers allowed.", MaxServerCount);
                        throw new MagpieException(message);
                    }
                    server = new MagpieServer(settings);
                    __servers.Add(settings, server);
                }
                return(server);
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// 数据库服务器
 /// </summary>
 /// <param name="settings">数据库服务器配置</param>
 public MagpieServer(MagpieServerSettings settings)
 {
     _settings     = settings;
     _sequentialId = Interlocked.Increment(ref __nextSequentialId);
 }
Exemplo n.º 4
0
    /// <summary>
    /// 根据数据库配置生成数据库服务器
    /// </summary>
    /// <param name="settings">数据库配置</param>
    /// <returns>数据库服务器</returns>
    public static MagpieServer Create(MagpieServerSettings settings)
    {
      if (settings == null)
        throw new ArgumentNullException("settings");

      lock (__staticLock)
      {
        MagpieServer server;
        if (!__servers.TryGetValue(settings, out server))
        {
          if (__servers.Count >= MaxServerCount)
          {
            var message = string.Format(CultureInfo.InvariantCulture, "Already created {0} servers which is the maximum number of servers allowed.", MaxServerCount);
            throw new MagpieException(message);
          }
          server = new MagpieServer(settings);
          __servers.Add(settings, server);
        }
        return server;
      }
    }
Exemplo n.º 5
0
 /// <summary>
 /// 数据库服务器
 /// </summary>
 /// <param name="settings">数据库服务器配置</param>
 public MagpieServer(MagpieServerSettings settings)
 {
   _settings = settings;
   _sequentialId = Interlocked.Increment(ref __nextSequentialId);
 }