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(); }
// 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(); }
/// <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); }
public CallAPI(APIFunction function, params Tree.Node[] arguments) { d_function = function; d_arguments = arguments; }
public virtual bool IsAvailable(APIFunction function) { return((AvailableFunctions.Contains(function) && VerifyAPI()) || IsPublicFunction(function)); }
public virtual bool IsPublicFunction(APIFunction function) { return(PublicFunctions.Contains(function)); }
/// <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; }