コード例 #1
0
        private IRestRequest CreateAuthenticatedRequest(Method requestType, string resource, object requestParameters, object requestBody, bool nativeAPI = false)
        {
            SortedDictionary <string, string> queryParams = GetObjectProperties(requestParameters);

            int timeNow = (int)((DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds);

            queryParams.Add("auth_key", this._appKey);
            queryParams.Add("auth_timestamp", timeNow.ToString());
            queryParams.Add("auth_version", "1.0");

            if (requestBody != null)
            {
                JsonSerializer serializer   = new JsonSerializer();
                var            bodyDataJson = serializer.Serialize(requestBody);
                var            bodyMD5      = CryptoHelper.GetMd5Hash(bodyDataJson);
                queryParams.Add("body_md5", bodyMD5);
            }

            string queryString = string.Empty;

            foreach (KeyValuePair <string, string> parameter in queryParams)
            {
                queryString += parameter.Key + "=" + parameter.Value + "&";
            }
            queryString = queryString.TrimEnd('&');

            resource = resource.TrimStart('/');
            string path;

            if (!nativeAPI)
            {
                path = string.Format("/apps/{0}/{1}", this._appId, resource);
            }
            else
            {
                path = string.Format("/{0}/{1}/apps/{2}/{3}", _options.Notification_Prefix, _options.Notificaiton_Version, this._appId, resource);
            }

            string authToSign = String.Format(
                Enum.GetName(requestType.GetType(), requestType) +
                "\n{0}\n{1}",
                path,
                queryString);

            var authSignature = CryptoHelper.GetHmac256(_appSecret, authToSign);

            var requestUrl = path + "?" + queryString + "&auth_signature=" + authSignature;
            var request    = new RestRequest(requestUrl);

            request.RequestFormat = DataFormat.Json;
            request.Method        = requestType;
            request.AddBody(requestBody);

            request.AddHeader("Pusher-Library-Name", LIBRARY_NAME);
            request.AddHeader("Pusher-Library-Version", VERSION.ToString(3));

            return(request);
        }
コード例 #2
0
ファイル: MinMax.cs プロジェクト: francisquinha/IART
 public void printConfigs()
 {
     System.Console.WriteLine("Version: " + version.ToString());
     if (useSmartDepth)
     {
         System.Console.WriteLine("Depth: Using Smart Depth");
     }
     else
     {
         System.Console.WriteLine("Depth: " + max_depth);
     }
     System.Console.WriteLine(rules.toDisplayString());
 }