コード例 #1
0
ファイル: JavaScript.cs プロジェクト: codyn-net/rawc
        private void WriteAPIFunction(APIFunction api)
        {
            if (api.Private && api.Body.Count == 0)
            {
                return;
            }

            d_writer.Write("Cdn.Networks.{0}.prototype.{1} = function(", CPrefix, api.Name);

            for (int i = 0; i < api.Arguments.Length; i += 2)
            {
                if (i != 0)
                {
                    d_writer.Write(", ");
                }

                var name = api.Arguments[i + 1];

                d_writer.Write(name);
            }

            d_writer.WriteLine(")\n{");

            if (api.Body.Count != 0)
            {
                WriteComputationNodes(api.Body);
            }

            d_writer.WriteLine("}");
            d_writer.WriteLine();
        }
コード例 #2
0
ファイル: GetAPI.cs プロジェクト: Stamp-Shot/OrganizerSide
    // Use this for initialization
    void Start()
    {
        var buffByte        = CameraReader.bytes;                                             //元画像取得
        var annotationsData = APIFunction.RequestVisionAPI(Convert.ToBase64String(buffByte)); //画像を投げて結果を受け取る

        var list1 = new List <string>();
        var list2 = new List <float>();

        foreach (var item in annotationsData)
        {
            //リストに追加
            list1.Add(item.description);
            list2.Add(item.score);
        }

        SpotElement[] spoele = new SpotElement[list1.Count];

        //配列にぶち込む
        for (int i = 0; i < list1.Count; i++)
        {
            spoele[i] = new SpotElement();

            spoele[i].name  = list1[i];
            spoele[i].score = list2[i];

            var elem = GameObject.Instantiate(prefab) as RectTransform;
            elem.SetParent(transform, false);

            var text = elem.GetComponentInChildren <Text>();
            text.text = list1[i] + "\n" + list2[i].ToString();
        }

        // JSONにシリアライズ
        var json = JsonHelper.ToJson <SpotElement>(spoele, true);

        // フォルダに保存する
        var path   = "/sdcard/StampShot/course/spot/json/API/testAPI.json"; //ファイル指定
        var writer = new StreamWriter(path, false);                         // 上書き

        writer.WriteLine(json);
        writer.Flush();
        writer.Close();
    }
コード例 #3
0
        /// <summary>
        /// Gets the data via a web request with the specified APIFunction and argument.
        /// </summary>
        /// <param name="apiFunction">APIFunction to call.</param>
        /// <param name="argument">Argument to pass.</param>
        /// <returns>Response from the WebRequest.</returns>
        public static string GetWebRequestResponse(APIFunction apiFunction, string argument)
        {
            ServicePointManager.DefaultConnectionLimit = 20;
            ServicePointManager.Expect100Continue      = false;
            ServicePointManager.UseNagleAlgorithm      = false;

            WebRequest request;

            if (apiFunction != APIFunction.GetUserSummary)
            {
                request = WebRequest.Create("http://retroachievements.org/API/API_" + apiFunction + ".php?z=" + RAToolSetWPF.Properties.Settings.Default.Username +
                                            "&y=" + RAToolSetWPF.Properties.Settings.Default.APIKey + "&i=" + argument);
            }
            else
            {
                // needed to use argument 'u' and 'g'
                request = WebRequest.Create("http://retroachievements.org/API/API_" + apiFunction + ".php?z=" + RAToolSetWPF.Properties.Settings.Default.Username +
                                            "&y=" + RAToolSetWPF.Properties.Settings.Default.APIKey + "&u=" + argument + "&g=0");
            }

            request.Proxy = new WebProxy();
            string text;
            var    response = (HttpWebResponse)request.GetResponse();

            using (var sr = new StreamReader(response.GetResponseStream()))
            {
                text = sr.ReadToEnd();
            }

            text = text.Replace("[", "").Replace("]", "");

            if (apiFunction != APIFunction.GetGameExtended)
            {
                text = text.Replace("},", "};");
            }

            return(text);
        }
コード例 #4
0
ファイル: CallAPI.cs プロジェクト: codyn-net/rawc
 public CallAPI(APIFunction function, params Tree.Node[] arguments)
 {
     d_function  = function;
     d_arguments = arguments;
 }
コード例 #5
0
ファイル: ExchangeBase.cs プロジェクト: vinhins/IntTrader
 public virtual bool IsAvailable(APIFunction function)
 {
     return((AvailableFunctions.Contains(function) && VerifyAPI()) || IsPublicFunction(function));
 }
コード例 #6
0
ファイル: ExchangeBase.cs プロジェクト: vinhins/IntTrader
 public virtual bool IsPublicFunction(APIFunction function)
 {
     return(PublicFunctions.Contains(function));
 }
コード例 #7
0
ファイル: MainViewModel.cs プロジェクト: coczero/RAToolSet
        /// <summary>
        /// Gets the data via a web request with the specified APIFunction and argument.
        /// </summary>
        /// <param name="apiFunction">APIFunction to call.</param>
        /// <param name="argument">Argument to pass.</param>
        /// <returns>Response from the WebRequest.</returns>
        public static string GetWebRequestResponse(APIFunction apiFunction, string argument)
        {
            ServicePointManager.DefaultConnectionLimit = 20;
              ServicePointManager.Expect100Continue = false;
              ServicePointManager.UseNagleAlgorithm = false;

              WebRequest request;

              if (apiFunction != APIFunction.GetUserSummary)
              {
            request = WebRequest.Create("http://retroachievements.org/API/API_" + apiFunction + ".php?z=" + RAToolSetWPF.Properties.Settings.Default.Username +
              "&y=" + RAToolSetWPF.Properties.Settings.Default.APIKey + "&i=" + argument);
              }
              else
              {
            // needed to use argument 'u' and 'g'
            request = WebRequest.Create("http://retroachievements.org/API/API_" + apiFunction + ".php?z=" + RAToolSetWPF.Properties.Settings.Default.Username +
              "&y=" + RAToolSetWPF.Properties.Settings.Default.APIKey + "&u=" + argument + "&g=0");
              }

              request.Proxy = new WebProxy();
              string text;
              var response = (HttpWebResponse)request.GetResponse();

              using (var sr = new StreamReader(response.GetResponseStream()))
              {
            text = sr.ReadToEnd();
              }

              text = text.Replace("[", "").Replace("]", "");

              if (apiFunction != APIFunction.GetGameExtended)
            text = text.Replace("},", "};");

              return text;
        }