public static JsonObject FromException(Exception e, bool includeStackTrace) { if (e == null) throw new ArgumentNullException("e"); JsonObject error = new JsonObject(); error.Put("name", "JSONRPCError"); error.Put("message", e.GetBaseException().Message); if (includeStackTrace) error.Put("stackTrace", e.StackTrace); JsonArray errors = new JsonArray(); do { errors.Put(ToLocalError(e)); e = e.InnerException; } while (e != null); error.Put("errors", errors); return error; }
public Collection<ApiAudioGenre> GetGenres() { var genres = new Collection<ApiAudioGenre>(); var properties = new JsonArray(new[] { "title", "thumbnail" }); var param = new JsonObject(); param["properties"] = properties; var result = (JsonObject)_parent.JsonCommand("AudioLibrary.GetGenres", param); if (result != null) { if (result.Contains("genres")) { foreach (JsonObject genre in (JsonArray)result["genres"]) { try { var gen = new ApiAudioGenre { IdGenre = (long)(JsonNumber)genre["genreid"], Name = genre["title"].ToString(), AlbumCount = 0, Thumb = genre["thumbnail"].ToString() }; genres.Add(gen); } catch (Exception) { } } } } return genres; }
public void AddNullValueViaIList() { IList list = new JsonArray(); list.Add(null); Assert.AreEqual(1, list.Count); Assert.IsNull(list[0]); }
public void AddNullValue() { JsonArray a = new JsonArray(); a.Add(null); Assert.AreEqual(1, a.Count); Assert.IsNull(a[0]); }
public Jayrock.Json.JsonArray getFileJsonArray() { DatabaseAccess dbAccess = new DatabaseAccess(); Jayrock.Json.JsonArray images = new Jayrock.Json.JsonArray(); Jayrock.Json.JsonObject image; System.Data.DataTable dt; string sql = string.Format(" select ID, Name FileName, Description from [File] where parentid = {0} order by ID ", ID.ToString()); dbAccess.open(); try { dt = dbAccess.select(sql); } catch (Exception ex) { throw ex; } finally { dbAccess.close(); } foreach (System.Data.DataRow row in dt.Rows) { image = new Jayrock.Json.JsonObject(); foreach (System.Data.DataColumn col in dt.Columns) { image.Accumulate(col.ColumnName.ToLower(), row[col.ColumnName]); } images.Add(image); } return(images); }
public override bool Process(HttpServer.IHttpRequest request, HttpServer.IHttpResponse response, HttpServer.Sessions.IHttpSession session) { if (request.UriPath == Url) { ThreadStore.UpdateThreadStoreStats(); ThreadStoreStats stats = ThreadStore.StoreStats; JsonArray ja = new JsonArray(); IEnumerable<string> boards = Program.ValidBoards.Keys; for (int i = 0, j = boards.Count(); i < j; i++) { string boardName = boards.ElementAt(i); int threadCount = stats[boardName]; if (threadCount > 0) { JsonArray inner = new JsonArray(); inner.Add(boardName); inner.Add(threadCount); ja.Add(inner); } } WriteJsonResponse(response, ja.ToString()); return true; } return false; }
public Collection<ApiAudioArtist> GetArtists() { var artists = new Collection<ApiAudioArtist>(); var properties = new JsonArray(new[] { "thumbnail", "fanart", "description" }); var param = new JsonObject(); param["properties"] = properties; var result = (JsonObject)_parent.JsonCommand("AudioLibrary.GetArtists", param); if (result != null) { if (result.Contains("artists")) { foreach (JsonObject genre in (JsonArray)result["artists"]) { try { var artist = new ApiAudioArtist { IdArtist = (long)(JsonNumber)genre["artistid"], Name = genre["artist"].ToString(), Thumb = genre["thumbnail"].ToString(), Fanart = genre["fanart"].ToString(), Biography = genre["description"].ToString() }; artists.Add(artist); } catch (Exception) { } } } } return artists; }
public Jayrock.Json.JsonArray getSystemLinkList() { Jayrock.Json.JsonArray ja = new Jayrock.Json.JsonArray(); Jayrock.Json.JsonObject jo; string sql = "select ID, name, link from OtherSystemLink"; dbAccess.open(); try { System.Data.DataTable dt = dbAccess.select(sql); foreach (System.Data.DataRow dr in dt.Rows) { jo = new JsonObject(); foreach (System.Data.DataColumn col in dt.Columns) { jo.Accumulate(col.ColumnName.ToLower(), dr[col.ColumnName].ToString()); } ja.Add(jo); } } catch { throw; } finally { dbAccess.close(); } return(ja); }
public void ContentsClearedBeforeImporting() { JsonArray a = new JsonArray(); a.Add(new object()); Assert.AreEqual(1, a.Length); a.Import(new JsonTextReader(new StringReader("[123]"))); Assert.AreEqual(1, a.Length); }
private void Push() { _valueStack.Push(_value); _memberStack.Push(_member); _array = null; _object = null; _value = null; _member = null; }
public static JsonObject TorrentSetLocation(JsonArray ids, string location, bool move) { JsonObject request = CreateBasicObject(ProtocolConstants.METHOD_TORRENT_SET_LOCATION, ResponseTag.DoNothing); JsonObject args = GetArgObject(request); args.Put(ProtocolConstants.KEY_IDS, ids); args.Put(ProtocolConstants.FIELD_LOCATION, location); args.Put(ProtocolConstants.FIELD_MOVE, move); return request; }
public void Import() { JsonArray a = new JsonArray(); a.Import(new JsonTextReader(new StringReader("[123,'Hello World',true]"))); Assert.AreEqual(3, a.Length); Assert.AreEqual(123, (int) (JsonNumber) a[0]); Assert.AreEqual("Hello World", a[1]); Assert.AreEqual(true, a[2]); }
public static JsonObject Generic(string method, JsonArray ids) { JsonObject request = CreateBasicObject(method); JsonObject args = GetArgObject(request); if (ids != null) args.Put(ProtocolConstants.KEY_IDS, ids); return request; }
public static JsonObject RemoveTorrent(JsonArray ids, bool delete) { JsonObject request = CreateBasicObject(ProtocolConstants.METHOD_TORRENTREMOVE); JsonObject arguments = GetArgObject(request); if (delete && Program.DaemonDescriptor.Version >= 1.5) arguments.Put(ProtocolConstants.FIELD_DELETELOCALDATA, true); arguments.Put(ProtocolConstants.KEY_IDS, ids); return request; }
public override string GetString(IEnumerable<IFreeDocument> datas) { var nodeGroup = new JsonArray(); foreach (IFreeDocument data in datas) { nodeGroup.Add(GetJsonObject(data)); } return nodeGroup.ToString(); }
public void Export() { JsonArray a = new JsonArray(new object[] { 123, "Hello World", true }); JsonRecorder writer = new JsonRecorder(); a.Export(writer); JsonReader reader = writer.CreatePlayer(); reader.ReadToken(JsonTokenClass.Array); Assert.AreEqual(a[0], reader.ReadNumber().ToInt32()); Assert.AreEqual(a[1], reader.ReadString()); Assert.AreEqual(a[2], reader.ReadBoolean()); reader.ReadToken(JsonTokenClass.EndArray); }
public Collection<ApiMovie> GetMovies() { var movies = new Collection<ApiMovie>(); var properties = new JsonArray(new[] { "title", "plot", "genre", "year", "fanart", "thumbnail", "playcount", "studio", "rating", "runtime", "mpaa", "originaltitle", "director", "votes" }); var param = new JsonObject(); param["properties"] = properties; var result = (JsonObject)_parent.JsonCommand("VideoLibrary.GetMovies", param); if (result != null) { if (result.Contains("movies")) { foreach (JsonObject genre in (JsonArray)result["movies"]) { try { var t = TimeSpan.FromSeconds((long)(JsonNumber)genre["runtime"]); var duration = string.Format("{0:D2}:{1:D2}", t.Hours, t.Minutes); var movie = new ApiMovie { Title = genre["title"].ToString(), Plot = genre["plot"].ToString(), Votes = genre["votes"].ToString(), Rating = genre["rating"].ToString(), Year = (long)(JsonNumber)genre["year"], IdScraper = "", Length = duration, Mpaa = genre["mpaa"].ToString(), Genre = _parent.JsonArrayToString((JsonArray)genre["genre"]), Director = _parent.JsonArrayToString((JsonArray)genre["director"]), OriginalTitle = genre["originaltitle"].ToString(), Studio = _parent.JsonArrayToString((JsonArray)genre["studio"]), IdFile = 0, IdMovie = (long)(JsonNumber)genre["movieid"], FileName = "", Path = "", PlayCount = 0, Thumb = genre["thumbnail"].ToString(), Fanart = genre["fanart"].ToString(), Hash = Xbmc.Hash(genre["thumbnail"].ToString()) }; movies.Add(movie); } catch (Exception) { } } } } return movies; }
private void Pop() { object current = _value; object popped = _valueStack.Pop(); _member = (string) _memberStack.Pop(); if (popped == null) // Final result? return; _object = popped as JsonObject; _array = _object == null ? (JsonArray) popped : null; _value = popped; WriteValue(current); }
public Collection<ApiTvSeason> GetTvSeasons() { var seasons = new Collection<ApiTvSeason>(); var properties = new JsonArray(new[] { "title" }); var param = new JsonObject(); param["properties"] = properties; var result = (JsonObject)_parent.JsonCommand("VideoLibrary.GetTVShows", param); if (result != null) { if (result.Contains("tvshows")) { foreach (JsonObject show in (JsonArray)result["tvshows"]) { var properties2 = new JsonArray(new[] { "tvshowid", "fanart", "thumbnail", "season", "showtitle", "episode" }); var param2 = new JsonObject(); param2["properties"] = properties2; param2["tvshowid"] = (long)(JsonNumber)show["tvshowid"]; var result2 = (JsonObject)_parent.JsonCommand("VideoLibrary.GetSeasons", param2); if (result2 == null) continue; if (!result2.Contains("seasons")) continue; foreach (JsonObject genre in (JsonArray)result2["seasons"]) { try { var tvShow = new ApiTvSeason { SeasonNumber = (long)(JsonNumber)genre["season"], IdShow = (long)(JsonNumber)genre["tvshowid"], Show = genre["showtitle"].ToString(), Thumb = genre["thumbnail"].ToString(), EpisodeCount = (long)(JsonNumber)genre["episode"], Fanart = genre["fanart"].ToString(), Hash = Xbmc.Hash(genre["thumbnail"].ToString()) }; seasons.Add(tvShow); } catch (Exception) { } } } } } return seasons; }
public void ImportIsExceptionSafe() { JsonArray a = new JsonArray(); object o = new object(); a.Add(o); try { a.Import(new JsonTextReader(new StringReader("[123,456,"))); } catch (JsonException) { } Assert.AreEqual(1, a.Count); Assert.AreSame(o, a[0]); }
public override bool Process(HttpServer.IHttpRequest request, HttpServer.IHttpResponse response, HttpServer.Sessions.IHttpSession session) { if (request.UriPath.StartsWith(Url)) { string day_number = request.QueryString[UrlParameters.DayNumber].Value; int dayNumber = 0; DateTime day = DateTime.Now; if (Int32.TryParse(day_number, out dayNumber)) { day = new DateTime(day.Year, 1, 1); dayNumber--; if (!DateTime.IsLeapYear(day.Year) && dayNumber == 365) { dayNumber--; } day = day.AddDays(dayNumber); } var sdata = NetworkUsageCounter.GetDayStats(day); JsonArray ja = new JsonArray(); for (int i = 0; i < sdata.Length; i++) { double t = sdata[i].Value / 1024 / 1024; JsonArray inner = new JsonArray(); inner.Add(sdata[i].Key); inner.Add(Math.Round(t, 2, MidpointRounding.AwayFromZero)); ja.Add(inner); } WriteJsonResponse(response, ja.ToString()); return true; } return false; }
public static JsonObject Reannounce(ReannounceMode mode, JsonArray ids) { JsonObject request = CreateBasicObject(ProtocolConstants.METHOD_TORRENTREANNOUNCE); JsonObject arguments = GetArgObject(request); switch (mode) { case ReannounceMode.RecentlyActive: arguments.Put(ProtocolConstants.KEY_IDS, ProtocolConstants.VALUE_RECENTLY_ACTIVE); break; case ReannounceMode.All: arguments.Put(ProtocolConstants.KEY_IDS, new JsonArray()); break; case ReannounceMode.Specific: arguments.Put(ProtocolConstants.KEY_IDS, ids); break; } return request; }
public JsonArray GetSignalsNearby(JsonObject param) { CheckRequest(param["ajaxSessionKey"].ToString()); JsonArray ar = new JsonArray(); SignalManager sm = new SignalManager(); List<Signal> ret = sm.SearchNearZip(param["zip"].ToString()); for (int i = 0; i < ret.Count; i++) { JsonObject obj = new JsonObject(); obj["signal"] = ret[i]; obj["description"] = GetSignalDescription(ret[i]); ar.Push(obj); } return ar; }
public Jayrock.Json.JsonArray getImageJsonArray() { DatabaseAccess dbAccess = new DatabaseAccess(); Jayrock.Json.JsonArray images = new Jayrock.Json.JsonArray(); Jayrock.Json.JsonObject image; System.Data.DataTable dt; string sql = "select ID, FileName, MIME from [Image] where Category = '" + GlobalSetting.ArticleCategory.Event + "' and ParentID = " + ID.ToString(); dbAccess.open(); try { dt = dbAccess.select(sql); } catch (Exception ex) { throw ex; } finally { dbAccess.close(); } foreach (System.Data.DataRow row in dt.Rows) { image = new Jayrock.Json.JsonObject(); foreach (System.Data.DataColumn col in dt.Columns) { image.Accumulate(col.ColumnName.ToLower(), row[col.ColumnName]); } images.Add(image); } return(images); }
public FileListViewItem(JsonObject file, ImageList img, int index, JsonArray wanted, JsonArray priorities) : base() { for (int i = 0; i < 6; i++) base.SubItems.Add(""); string name = (string)file[ProtocolConstants.FIELD_NAME]; this.FileName = Toolbox.TrimPath(name); base.SubItems[0].Tag = name.Length != this.FileName.Length; this.FileIndex = index; string[] split = this.Name.Split('.'); if (split.Length > 1) { this.Extension = split[split.Length - 1].ToLower(); if (Program.Form.fileIconImageList.Images.ContainsKey(this.Extension) || IconReader.AddToImgList(this.Extension, Program.Form.fileIconImageList)) { this.TypeName = IconReader.GetTypeName(this.Extension); base.ImageKey = this.Extension; } else this.TypeName = this.Extension; } this.FileSize = Toolbox.ToLong(file[ProtocolConstants.FIELD_LENGTH]); this.Update(file, wanted, priorities); }
private void TradeLsit(HttpContext context,string action) { int RowCount = 0; int PageCount = 0; decimal Balance = 0.0M; JsonObject json = new JsonObject(); string strID = context.Request.Params["UserId"]; int uid = Common.Globals.SafeInt(strID, 0); string strIndex = context.Request.Params["PageIndex"]; int PageIndex = Common.Globals.SafeInt(strIndex, 1); int PageSize = 10; List<Model.Tao.TradeDetails> list = null; if (action == "currentMon") { list = bll.GetListByUId(out RowCount, out PageCount, out Balance, uid, PageIndex, PageSize, true); } else { list = bll.GetListByUId(out RowCount, out PageCount, out Balance, uid, PageIndex, PageSize, false); } if (list.Count > 0) { JsonArray data = new JsonArray(); list.ForEach(info => data.Add(new JsonObject( new string[] { "ID", "DataTime", "InCome", "Pay", "Balance", "Remark" }, new object[] { info.ID, info.CreateDate.ToString("yyyy-MM-dd HH:mm:ss"), info.TradeAmount, info.Pay, info.Balance, info.Remark } ))); json.Put(TAO_KEY_STATUS, TAO_STATUS_SUCCESS); json.Put(TAO_KEY_DATA, data); json.Put("ROWCOUNT", RowCount); json.Put("PAGECOUNT", PageCount); json.Put("BALANCE", Balance); } else { json.Put(TAO_KEY_STATUS, TAO_STATUS_FAILED); } context.Response.Write(json.ToString()); }
public static void Main(string[] args) { JsonWsp.Client cli = new JsonWsp.Client("http://10.1.5.160/service/AccessService/jsonwsp/description"); cli.SetViaProxy(true); if (args.Length == 0) { Console.WriteLine("Usage: jsontest.exe <session_id>"); return; } Console.WriteLine("Call listPermissions"); Console.WriteLine("--------------------"); // Build arguments JsonObject args_dict = new JsonObject(); args_dict.Add("session_id", args[0]); // Call method JsonObject result = CommonCall(cli, "listPermissions", args_dict); if (result != null) { Jayrock.Json.JsonArray perm = (Jayrock.Json.JsonArray)result["access_identifiers"]; foreach (string i in perm) { Console.WriteLine(i); } } Console.WriteLine(); Console.WriteLine("Call hasPermissions"); Console.WriteLine("-------------------"); // Build arguments JsonObject args_dict2 = new JsonObject(); args_dict2.Add("session_id", args[0]); args_dict2.Add("access_identifier", "product.web.10finger"); // Call method result = CommonCall(cli, "hasPermission", args_dict2); // Print if (result != null) { bool access = (bool)result["has_permission"]; if (access) { Console.WriteLine("Access Granted"); } else { Console.WriteLine("Access Denied"); } } Console.WriteLine(); Console.WriteLine("Call getUserInfo"); Console.WriteLine("----------------"); cli = new JsonWsp.Client("http://10.1.5.160/service/UserService/jsonwsp/description"); result = CommonCall(cli, "getUserInfo", args_dict); if (result != null) { JsonObject user_info = (JsonObject)result["user_info"]; Console.WriteLine("Org-name: " + user_info["org_name"]); Console.WriteLine("Org-domain: " + user_info["org_domain"]); Console.WriteLine("Org-code: " + user_info["org_code"]); Console.WriteLine("Org-type: " + user_info["org_type"]); Console.WriteLine("Given Name: " + user_info["given_name"]); Console.WriteLine("Surname: " + user_info["surname"]); Console.WriteLine("Uid: " + user_info["uid"]); Console.WriteLine("Common-name: " + user_info["common_name"]); } }
public void CannotUseNullReaderWithImport() { IJsonImportable array = new JsonArray(); array.Import(new ImportContext(), null); }
public void CannotUseNullContextWithImport() { IJsonImportable array = new JsonArray(); array.Import(null, (new JsonRecorder()).CreatePlayer()); }
public void CannotUseNullArgWithExport() { IJsonExportable array = new JsonArray(); array.Export(null, null); }
protected override void WriteStartArrayImpl() { Push(); _value = _array = new JsonArray(); }
private static JsonObject Files(int id, bool includePriorities) { JsonObject request = CreateBasicObject(ProtocolConstants.METHOD_TORRENTGET, ResponseTag.UpdateFiles); JsonObject arguments = GetArgObject(request); JsonArray ids = new JsonArray(); ids.Push(id); arguments.Put(ProtocolConstants.KEY_IDS, ids); JsonArray fields = new JsonArray(); fields.Put(ProtocolConstants.FIELD_FILES); fields.Put(ProtocolConstants.FIELD_ID); if (includePriorities) { fields.Put(ProtocolConstants.FIELD_PRIORITIES); fields.Put(ProtocolConstants.FIELD_WANTED); } arguments.Put(ProtocolConstants.KEY_FIELDS, fields); return request; }
public static JsonObject TorrentAddByFile(string file, bool deleteAfter, JsonArray high, JsonArray normal, JsonArray low, JsonArray wanted, JsonArray unwanted, string destination, int peerLimit) { return TorrentAddByFile(file, deleteAfter, high, normal, low, wanted, unwanted, destination, peerLimit, !Program.Settings.Current.StartPaused); }
public static JsonObject TorrentGet() { JsonObject request = CreateBasicObject(ProtocolConstants.METHOD_TORRENTGET, ResponseTag.TorrentGet); JsonObject arguments = GetArgObject(request); JsonArray fields = new JsonArray(new string[]{ ProtocolConstants.FIELD_ID, ProtocolConstants.FIELD_ADDEDDATE, ProtocolConstants.FIELD_HAVEVALID, ProtocolConstants.FIELD_HAVEUNCHECKED, ProtocolConstants.FIELD_ETA, ProtocolConstants.FIELD_RECHECKPROGRESS, ProtocolConstants.FIELD_LEECHERS, ProtocolConstants.FIELD_RATEDOWNLOAD, ProtocolConstants.FIELD_RATEUPLOAD, ProtocolConstants.FIELD_SEEDERS, ProtocolConstants.FIELD_TOTALSIZE, ProtocolConstants.FIELD_DOWNLOADEDEVER, ProtocolConstants.FIELD_UPLOADEDEVER, ProtocolConstants.FIELD_STATUS, ProtocolConstants.FIELD_LEFTUNTILDONE, ProtocolConstants.FIELD_ANNOUNCEURL, ProtocolConstants.FIELD_DOWNLOADLIMIT, ProtocolConstants.FIELD_DOWNLOADLIMITMODE, ProtocolConstants.FIELD_UPLOADLIMIT, ProtocolConstants.FIELD_UPLOADLIMITED, ProtocolConstants.FIELD_UPLOADLIMITMODE, ProtocolConstants.FIELD_SPEEDLIMITDOWN, ProtocolConstants.FIELD_DOWNLOADLIMITED, ProtocolConstants.FIELD_SPEEDLIMITDOWNENABLED, ProtocolConstants.FIELD_SPEEDLIMITUP, ProtocolConstants.FIELD_SPEEDLIMITUPENABLED, ProtocolConstants.FIELD_SECONDSDOWNLOADING, ProtocolConstants.FIELD_SECONDSSEEDING, ProtocolConstants.FIELD_NAME, ProtocolConstants.FIELD_QUEUE_POSITION, ProtocolConstants.FIELD_ERRORSTRING, ProtocolConstants.FIELD_PEERS, ProtocolConstants.FIELD_PEERSGETTINGFROMUS, ProtocolConstants.FIELD_PEERSSENDINGTOUS, ProtocolConstants.FIELD_PIECECOUNT, ProtocolConstants.FIELD_PIECES, ProtocolConstants.FIELD_PIECESIZE, //ProtocolConstants.FIELD_PIECECOMPLETE, ProtocolConstants.FIELD_MAXCONNECTEDPEERS, ProtocolConstants.FIELD_COMMENT, ProtocolConstants.FIELD_SWARMSPEED, ProtocolConstants.FIELD_DATECREATED, ProtocolConstants.FIELD_CREATOR, ProtocolConstants.FIELD_TRACKERS, ProtocolConstants.FIELD_TRACKERSTATS, ProtocolConstants.FIELD_HASHSTRING, ProtocolConstants.FIELD_DOWNLOADDIR, ProtocolConstants.FIELD_BANDWIDTHPRIORITY, ProtocolConstants.FIELD_SEEDRATIOLIMIT, ProtocolConstants.FIELD_SEEDRATIOMODE, ProtocolConstants.FIELD_SEEDIDLELIMIT, ProtocolConstants.FIELD_SEEDIDLEMODE, ProtocolConstants.FIELD_HONORSSESSIONLIMITS, ProtocolConstants.FIELD_DONEDATE, ProtocolConstants.FIELD_SIZEWHENDONE }); arguments.Put(ProtocolConstants.KEY_FIELDS, fields); return request; }
public static JsonObject TorrentAddByFile(string file, bool deleteAfter, JsonArray high, JsonArray normal, JsonArray low, JsonArray wanted, JsonArray unwanted, string destination, int peerLimit, bool startTorrent) { FileStream inFile = new FileStream(file, FileMode.Open, FileAccess.Read); byte[] binaryData = new byte[inFile.Length]; if (inFile.Read(binaryData, 0, (int)inFile.Length) < 1) { throw new Exception(OtherStrings.EmptyFile); } inFile.Close(); JsonObject request = CreateBasicObject(ProtocolConstants.METHOD_TORRENTADD); JsonObject arguments = GetArgObject(request); arguments.Put(ProtocolConstants.FIELD_METAINFO, Convert.ToBase64String(binaryData, 0, binaryData.Length)); arguments.Put(ProtocolConstants.FIELD_PAUSED, !startTorrent); if (high != null) arguments.Put(ProtocolConstants.PRIORITY_HIGH, high); if (normal != null) arguments.Put(ProtocolConstants.PRIORITY_NORMAL, normal); if (low != null) arguments.Put(ProtocolConstants.PRIORITY_LOW, low); if (wanted != null) arguments.Put(ProtocolConstants.FILES_WANTED, wanted); if (unwanted != null) arguments.Put(ProtocolConstants.FILES_UNWANTED, unwanted); if (destination != null) arguments.Put(ProtocolConstants.DOWNLOAD_DIR, destination); if (peerLimit > 0) arguments.Put(ProtocolConstants.FIELD_PEERLIMIT, peerLimit); if (deleteAfter && File.Exists(file)) { try { File.Delete(file); } catch (Exception e) { Program.LogDebug("Could not delete torrent: " + file, e.ToString()); } } return request; }