/// <summary>
        /// 指定一个服务器初始化Client
        /// </summary>
        /// <param name="baseUri"></param>
        public ServerClient(string baseUri, string cookieFile = "")
        {
            client           = new RestClient(baseUri);
            client.UserAgent = ua;
            cookieFilePath   = cookieFile;

            if (string.IsNullOrEmpty(cookieFile))
            {
                client.CookieContainer = new CookieContainer();
            }
            else
            {
                client.CookieContainer = CookieContainerExtension.ReadFrom(cookieFile);
                loadCookie(baseUri);
            }

            client.ThrowOnDeserializationError = true;
            client.UseSerializer(
                () => new MongoDBJsonSerializer()
                );
        }
Exemple #2
0
        /// <summary>
        /// 指定一个服务器初始化Client
        /// </summary>
        /// <param name="baseUri"></param>
        public ServerClient(string baseUri, string gameVersion = "1.0", string cookieFile = "")
        {
            client           = new RestClient(baseUri);
            client.UserAgent = uaVersionKey + "/" + gameVersion + " " + additionalUserAgent();
            cookieFilePath   = cookieFile;
            client.AddDefaultHeader("Accept-Language", CultureInfo.CurrentCulture.Name);

            if (string.IsNullOrEmpty(cookieFile))
            {
                client.CookieContainer = new CookieContainer();
            }
            else
            {
                client.CookieContainer = CookieContainerExtension.ReadFrom(cookieFile);
                loadCookie(baseUri);
            }

            client.ThrowOnDeserializationError = true;
            client.UseSerializer(
                () => new MongoDBJsonSerializer()
                );
        }