public void Can_Deserialize_Elements_With_Namespace() { var doc = CreateElementsXml(); var response = new RestResponse { Content = doc }; var d = new XmlDeserializer(); d.Namespace = "http://restsharp.org"; var p = d.Deserialize<PersonForXml>(response); Assert.Equal("John Sheehan", p.Name); Assert.Equal(new DateTime(2009, 9, 25, 0, 6, 1), p.StartDate); Assert.Equal(28, p.Age); Assert.Equal(long.MaxValue, p.BigNumber); Assert.Equal(99.9999m, p.Percent); Assert.Equal(false, p.IsCool); Assert.Equal(new Guid(GuidString), p.UniqueId); Assert.Equal(new Uri("http://example.com", UriKind.RelativeOrAbsolute), p.Url); Assert.Equal(new Uri("/foo/bar", UriKind.RelativeOrAbsolute), p.UrlPath); Assert.NotNull(p.Friends); Assert.Equal(10, p.Friends.Count); Assert.NotNull(p.BestFriend); Assert.Equal("The Fonz", p.BestFriend.Name); Assert.Equal(1952, p.BestFriend.Since); }
public void Can_Deserialize_Attributes_Without_Matching_Case_On_Default_Root() { var doc = CreateLowercaseDashesXml(); var response = new RestResponse { Content = doc }; var d = new XmlDeserializer(); var p = d.Deserialize<PersonForXml>(response); Assert.Equal("John Sheehan", p.Name); Assert.Equal(new DateTime(2009, 9, 25, 0, 6, 1), p.StartDate); Assert.Equal(28, p.Age); Assert.Equal(long.MaxValue, p.BigNumber); Assert.Equal(99.9999m, p.Percent); Assert.Equal(false, p.IsCool); Assert.Equal(new Guid(GuidString), p.UniqueId); Assert.Equal(new Uri("http://example.com", UriKind.RelativeOrAbsolute), p.Url); Assert.Equal(new Uri("/foo/bar", UriKind.RelativeOrAbsolute), p.UrlPath); Assert.NotNull(p.Friends); Assert.Equal(10, p.Friends.Count); Assert.NotNull(p.BestFriend); Assert.Equal("The Fonz", p.BestFriend.Name); Assert.Equal(1952, p.BestFriend.Since); Assert.NotNull(p.Foes); Assert.Equal(5, p.Foes.Count); Assert.Equal("Yankees", p.Foes.Team); }
public void Can_deserialize_to_dynamic_single() { var serializer = new DefaultJsonSerializer(); var response = new RestResponse<dynamic>(); response.SetContent(SingleInput); var proxy = serializer.DeserializeDynamic(response); Assert.IsNotNull(proxy); }
public void Can_deserialize_to_dynamic_collection() { var serializer = new JsonSerializer(); var response = new RestResponse<JsonObject>(); response.SetContent(DoubleInput); var proxy = serializer.DeserializeDynamic(response); Assert.IsNotNull(proxy); }
public void Can_Deserialize_AcoustID_Xml() { var xmlpath = PathFor("AcoustID.xml"); var doc = XDocument.Load(xmlpath); var response = new RestResponse { Content = doc.ToString() }; var d = new XmlDeserializer(); var output = d.Deserialize<MTB.Worker.AcoustID.Response>(response); }
public void Can_Deserialize_DateTime() { var doc = File.ReadAllText(Path.Combine("SampleData", "datetimes.txt")); var d = new JsonDeserializer(); var response = new RestResponse { Content = doc }; var payload = d.Deserialize<DateTimeTestStructure>(response); Assert.Equal( new DateTime(2011, 6, 30, 8, 15, 46, DateTimeKind.Utc).ToString("u"), payload.DateTime.ToString("u")); }
public void Can_Deserialize_Boolean_From_Number() { var xmlpath = PathFor("boolean_from_number.xml"); var doc = XDocument.Load(xmlpath); var response = new RestResponse { Content = doc.ToString() }; var d = new XmlDeserializer(); var output = d.Deserialize<SampleClasses.BooleanTest>(response); Assert.True(output.Value); }
public void Can_deserialize_all_test_cases() { var serializer = new DefaultJsonSerializer(); var files = Directory.GetFiles("Json", "*.json"); foreach(var file in files) { var json = File.ReadAllText(file); var response = new RestResponse<dynamic>(); response.SetContent(json); var proxy = serializer.DeserializeDynamic(response); Assert.IsNotNull(proxy); } }
public void Can_Deserialize_Custom_Formatted_Date() { var format = "dd yyyy MMM, hh:mm ss tt"; var date = new DateTime(2010, 2, 8, 11, 11, 11); var formatted = new { StartDate = date.ToString(format) }; var data = JsonConvert.SerializeObject(formatted); var response = new RestResponse { Content = data }; var json = new JsonDeserializer { DateFormat = format }; var output = json.Deserialize<PersonForJson>(response); Assert.Equal(date, output.StartDate); }
public void Can_Deserialize_Custom_Formatted_Date() { var format = "dd yyyy MMM, hh:mm ss tt zzz"; var date = new DateTime(2010, 2, 8, 11, 11, 11); var doc = new XDocument(); var root = new XElement("Person"); root.Add(new XElement("StartDate", date.ToString(format))); doc.Add(root); var xml = new XmlDeserializer(); xml.DateFormat = format; var response = new RestResponse { Content = doc.ToString() }; var output = xml.Deserialize<PersonForXml>(response); Assert.Equal(date, output.StartDate); }
public void Can_Deserialize_Attributes_On_Default_Root() { var doc = CreateAttributesXml(); var response = new RestResponse { Content = doc }; var d = new XmlDeserializer(); var p = d.Deserialize<PersonForXml>(response); Assert.Equal("John Sheehan", p.Name); Assert.Equal(new DateTime(2009, 9, 25, 0, 6, 1), p.StartDate); Assert.Equal(28, p.Age); Assert.Equal(long.MaxValue, p.BigNumber); Assert.Equal(99.9999m, p.Percent); Assert.Equal(false, p.IsCool); Assert.Equal(new Guid(GuidString), p.UniqueId); Assert.NotNull(p.BestFriend); Assert.Equal("The Fonz", p.BestFriend.Name); Assert.Equal(1952, p.BestFriend.Since); }
public void Can_Deserialize_Attributes_With_Namespace() { string doc = CreateAttributesXml(); RestResponse response = new RestResponse { Content = doc }; XmlDeserializer d = new XmlDeserializer { Namespace = "http://restsharp.org" }; PersonForXml p = d.Deserialize<PersonForXml>(response); Assert.AreEqual("John Sheehan", p.Name); Assert.AreEqual(new DateTime(2009, 9, 25, 0, 6, 1), p.StartDate); Assert.AreEqual(28, p.Age); Assert.AreEqual(long.MaxValue, p.BigNumber); Assert.AreEqual(99.9999m, p.Percent); Assert.AreEqual(false, p.IsCool); Assert.AreEqual(new Guid(GUID_STRING), p.UniqueId); Assert.AreEqual(new Uri("http://example.com", UriKind.RelativeOrAbsolute), p.Url); Assert.AreEqual(new Uri("/foo/bar", UriKind.RelativeOrAbsolute), p.UrlPath); Assert.NotNull(p.BestFriend); Assert.AreEqual("The Fonz", p.BestFriend.Name); Assert.AreEqual(1952, p.BestFriend.Since); }
public void Can_Deserialize_Various_Enum_Values() { var data = File.ReadAllText (Path.Combine ("SampleData", "jsonenums.txt")); var response = new RestResponse { Content = data }; var json = new JsonDeserializer (); var output = json.Deserialize<JsonEnumsTestStructure>(response); Assert.Equal (output.Upper, Disposition.Friendly); Assert.Equal (output.Lower, Disposition.Friendly); Assert.Equal (output.CamelCased, Disposition.SoSo); Assert.Equal (output.Underscores, Disposition.SoSo); Assert.Equal (output.LowerUnderscores, Disposition.SoSo); Assert.Equal (output.Dashes, Disposition.SoSo); Assert.Equal (output.LowerDashes, Disposition.SoSo); }
public void Can_Deserialize_To_Dictionary_String_String_With_Dynamic_Values() { var doc = CreateDynamicJsonStringDictionary (); var d = new JsonDeserializer (); var response = new RestResponse { Content = doc }; var bd = d.Deserialize<Dictionary<string, string>> (response); Assert.Equal ("[\"Value1\",\"Value2\"]", bd["Thing1"]); Assert.Equal ("Thing2", bd["Thing2"]); Assert.Equal ("{\"Name\":\"ThingRed\",\"Color\":\"Red\"}", bd["ThingRed"]); Assert.Equal ("{\"Name\":\"ThingBlue\",\"Color\":\"Blue\"}", bd["ThingBlue"]); }
internal async Task UnfollowUserAsync(string userId, RequestOptions options) { RestResponse response = await SendAsync("DELETE", $"me/follows/{userId}", options).ConfigureAwait(false); }
internal async Task ModifyGfyDescriptionAsync(string gfyId, string newDescription, RequestOptions options) { RestResponse response = await SendJsonAsync("PUT", $"me/gfycats/{gfyId}/description", new { value = newDescription }, options).ConfigureAwait(false); }
internal async Task ModifyGfyTagsAsync(string gfyId, IEnumerable <string> newTags, RequestOptions options) { RestResponse response = await SendJsonAsync("PUT", $"me/gfycats/{gfyId}/tags", new { value = newTags }, options).ConfigureAwait(false); }
internal async Task UploadProfileImageAsync(string url, Stream picStream, RequestOptions options) { options = options ?? RequestOptions.CreateFromDefaults(Config); options.UseAccessToken = false; RestResponse response = await SendBinaryStreamAsync("PUT", url, picStream, options).ConfigureAwait(false); }
public void Can_Deserialize_TimeSpan() { var culture = CultureInfo.InvariantCulture; var doc = new XDocument(culture); TimeSpan? nullTimespan = null; TimeSpan? nullValueTimeSpan = new TimeSpan(21, 30, 7); var root = new XElement("Person"); root.Add(new XElement("Tick", new TimeSpan(468006))); root.Add(new XElement("Millisecond", new TimeSpan(0, 0, 0, 0, 125))); root.Add(new XElement("Second", new TimeSpan(0, 0, 8))); root.Add(new XElement("Minute", new TimeSpan(0, 55, 2))); root.Add(new XElement("Hour", new TimeSpan(21, 30, 7))); root.Add(new XElement("NullableWithoutValue", nullTimespan)); root.Add(new XElement("NullableWithValue", nullValueTimeSpan)); doc.Add(root); var xml = new XmlDeserializer { Culture = culture, }; var response = new RestResponse { Content = doc.ToString() }; var d = new XmlDeserializer() { Culture = culture, }; var payload = d.Deserialize<TimeSpanTestStructure>(response); Assert.Equal(new TimeSpan(468006), payload.Tick); Assert.Equal(new TimeSpan(0, 0, 0, 0, 125), payload.Millisecond); Assert.Equal(new TimeSpan(0, 0, 8), payload.Second); Assert.Equal(new TimeSpan(0, 55, 2), payload.Minute); Assert.Equal(new TimeSpan(21, 30, 7), payload.Hour); Assert.Null(payload.NullableWithoutValue); Assert.NotNull(payload.NullableWithValue); Assert.Equal(new TimeSpan(21, 30, 7), payload.NullableWithValue.Value); }
internal async Task MoveBookmarkFolderAsync(string folderId, string parentId, RequestOptions options) { RestResponse response = await SendJsonAsync("PUT", $"me/bookmark-folders/{folderId}", new { parent_id = parentId }, options).ConfigureAwait(false); }
internal async Task ModifyBookmarkFolderTitleAsync(string folderId, string newTitle, RequestOptions options) { RestResponse response = await SendJsonAsync("PUT", $"me/bookmark-folders/{folderId}/name", new { value = newTitle }, options).ConfigureAwait(false); }
internal async Task DeleteBookmarkFolderAsync(string folderId, RequestOptions options) { RestResponse response = await SendAsync("DELETE", $"me/bookmark-folders/{folderId}", options).ConfigureAwait(false); }
internal async Task <Models.Folder> GetBookmarkFolderContentsAsync(string folderId, RequestOptions options) { RestResponse response = await SendAsync("GET", $"me/bookmark-folders/{folderId}", options).ConfigureAwait(false); return(await response.ReadAsJsonAsync <Models.Folder>(Config).ConfigureAwait(false)); }
internal async Task <IEnumerable <Models.FolderInfo> > GetCurrentUserBookmarkFoldersAsync(RequestOptions options) { RestResponse response = await SendAsync("GET", "me/bookmark-folders", options).ConfigureAwait(false); return(await response.ReadAsJsonAsync <IEnumerable <Models.FolderInfo> >(Config).ConfigureAwait(false)); }
internal async Task <FollowersResponse> GetFollowersAsync(RequestOptions options) { RestResponse response = await SendAsync("GET", "me/followers", options).ConfigureAwait(false); return(await response.ReadAsJsonAsync <FollowersResponse>(Config).ConfigureAwait(false)); }
public void Ignore_Protected_Property_That_Exists_In_Data() { var doc = CreateJson(); var d = new JsonDeserializer(); var response = new RestResponse { Content = doc }; var p = d.Deserialize<PersonForJson>(response); Assert.Null(p.IgnoreProxy); }
public void Can_Deserialize_Google_Weather_Xml() { var xmlpath = PathFor("GoogleWeather.xml"); var doc = XDocument.Load(xmlpath); var response = new RestResponse { Content = doc.ToString() }; var d = new XmlDeserializer(); var output = d.Deserialize<SampleClasses.xml_api_reply>(response); Assert.NotEmpty(output.weather); Assert.Equal(4, output.weather.Count); Assert.Equal("Sunny", output.weather[0].condition.data); }
internal async Task CreateBookmarkFolderAsync(string folderId, string title, RequestOptions options) { RestResponse response = await SendJsonAsync("POST", $"me/bookmark-folders/{folderId}", new { folderName = title }, options).ConfigureAwait(false); }
internal async Task <ProfileImageUploadStatus> GetProfileImageUploadStatusAsync(string ticket, RequestOptions options) { RestResponse response = await SendAsync("GET", $"me/profile_image_url/status/{ticket}", options).ConfigureAwait(false); return((ProfileImageUploadStatus)Enum.Parse(typeof(ProfileImageUploadStatus), (await response.ReadAsStringAsync().ConfigureAwait(false)).Trim('"'), true)); }
internal async Task ModifyGfyNsfwSettingAsync(string gfyId, NsfwSetting newSetting, RequestOptions options) { RestResponse response = await SendJsonAsync("PUT", $"me/gfycats/{gfyId}/nsfw", new { value = newSetting }, options).ConfigureAwait(false); }
internal async Task ModifyGfyTitleAsync(string gfyId, string newTitle, RequestOptions options) { RestResponse response = await SendJsonAsync("PUT", $"me/gfycats/{gfyId}/title", new { value = newTitle }, options).ConfigureAwait(false); }
internal async Task DeleteGfyAsync(string gfyId, RequestOptions options) { RestResponse response = await SendAsync("DELETE", $"me/gfycats/{gfyId}", options).ConfigureAwait(false); }
internal async Task <IEnumerable <string> > GetGfyGeoWhitelistAsync(string gfyId, RequestOptions options) { RestResponse response = await SendAsync("GET", $"me/gfycats/{gfyId}/geo-whitelist", options).ConfigureAwait(false); return((await response.ReadAsJsonAsync <GeoWhitelistShared>(Config).ConfigureAwait(false)).GeoWhitelist); }
public void Can_Deserialize_TimeSpan() { var doc = File.ReadAllText(Path.Combine("SampleData", "timespans.txt")); var d = new JsonDeserializer(); var response = new RestResponse { Content = doc }; var payload = d.Deserialize<TimeSpanTestStructure>(response); Assert.Equal(new TimeSpan(468006), payload.Tick); Assert.Equal(new TimeSpan(0, 0, 0, 0, 125), payload.Millisecond); Assert.Equal(new TimeSpan(0, 0, 8), payload.Second); Assert.Equal(new TimeSpan(0, 55, 2), payload.Minute); Assert.Equal(new TimeSpan(21, 30, 7), payload.Hour); Assert.Null(payload.NullableWithoutValue); Assert.NotNull(payload.NullableWithValue); Assert.Equal(new TimeSpan(21, 30, 7), payload.NullableWithValue.Value); }
internal async Task ModifyGfyPublishedSettingAsync(string gfyId, bool published, RequestOptions options) { RestResponse response = await SendJsonAsync("PUT", $"me/gfycats/{gfyId}/published", new { value = published }, options).ConfigureAwait(false); }
internal async Task <ClientAccountAuthResponse> CreateAccountAsync(AccountCreationRequest account, RequestOptions options) { RestResponse response = await SendJsonAsync("POST", "users", account, options).ConfigureAwait(false); return(await response.ReadAsJsonAsync <ClientAccountAuthResponse>(Config).ConfigureAwait(false)); }
internal async Task RemoveDislikeGfyAsync(string gfyid, RequestOptions options) { RestResponse response = await SendJsonAsync("PUT", $"me/gfycats/{gfyid}/dislike", new { value = 0 }, options).ConfigureAwait(false); }
public void Can_Deserialize_JsonNet_Dates() { var doc = File.ReadAllText(Path.Combine("SampleData", "person.json.txt")); var d = new JsonDeserializer(); var response = new RestResponse { Content = doc }; var person = d.Deserialize<PersonForJson>(response); Assert.Equal( new DateTime(2011, 6, 30, 8, 15, 46, DateTimeKind.Utc).ToString("u"), person.StartDate.ToString("u")); }
internal async Task MoveBookmarkedGfysAsync(string folderId, GfyFolderAction action, RequestOptions options) { RestResponse response = await SendJsonAsync("PATCH", $"me/bookmark-folders/{folderId}", action, options).ConfigureAwait(false); }
public void Can_Deserialize_Quoted_Primitive() { var doc = new JObject(); doc["Age"] = "28"; var d = new JsonDeserializer(); var response = new RestResponse { Content = doc.ToString() }; var p = d.Deserialize<PersonForJson>(response); Assert.Equal(28, p.Age); }
public void Can_Deserialize_Iso_Json_Dates() { var doc = CreateIsoDateJson(); var d = new JsonDeserializer(); var response = new RestResponse { Content = doc }; var bd = d.Deserialize<Birthdate>(response); Assert.Equal(new DateTime(1910, 9, 25, 9, 30, 25, DateTimeKind.Utc), bd.Value); }
internal async Task <BookmarkedResult> GetBookmarkedStatusAsync(string gfyId, RequestOptions options) { RestResponse response = await SendAsync("GET", $"me/bookmark-folders/{gfyId}", options).ConfigureAwait(false); return(await response.ReadAsJsonAsync <BookmarkedResult>(Config).ConfigureAwait(false)); }
public void Can_Deserialize_Nullable_DateTime_With_Null() { var doc = File.ReadAllText(Path.Combine("SampleData", "datetimes.txt")); var d = new JsonDeserializer(); var response = new RestResponse { Content = doc }; var payload = d.Deserialize<DateTimeTestStructure>(response); Assert.Null(payload.NullableDateTimeWithNull); }
internal async Task <IEnumerable <Models.AlbumInfo> > GetAlbumsAsync(RequestOptions options) { RestResponse response = await SendAsync("GET", "me/album-folders", options).ConfigureAwait(false); return(await response.ReadAsJsonAsync <IEnumerable <Models.AlbumInfo> >(Config).ConfigureAwait(false)); }
public void Can_Deserialize_Root_Json_Array_To_List() { var data = File.ReadAllText(Path.Combine("SampleData", "jsonarray.txt")); var response = new RestResponse { Content = data }; var json = new JsonDeserializer(); var output = json.Deserialize<List<status>>(response); Assert.Equal(4, output.Count); }
internal async Task <IEnumerable <Models.AlbumInfo> > GetAlbumsForUserAsync(string userId, RequestOptions options) { RestResponse response = await SendAsync("GET", $"users/{userId}/albums", options).ConfigureAwait(false); return((await response.ReadAsJsonAsync <UserAlbumsResponse>(Config).ConfigureAwait(false)).Items); }
public void Can_Deserialize_To_Dictionary_String_String() { var doc = CreateJsonStringDictionary(); var d = new JsonDeserializer(); var response = new RestResponse { Content = doc }; var bd = d.Deserialize<Dictionary<string,string>>(response); Assert.Equal(bd["Thing1"], "Thing1"); Assert.Equal(bd["Thing2"], "Thing2"); Assert.Equal(bd["ThingRed"], "ThingRed"); Assert.Equal(bd["ThingBlue"], "ThingBlue"); }
internal async Task <Models.Album> GetAlbumContentsAsync(string albumId, RequestOptions options) { RestResponse response = await SendAsync("GET", $"me/albums/{albumId}", options).ConfigureAwait(false); return(await response.ReadAsJsonAsync <Models.Album>(Config).ConfigureAwait(false)); }
public void Can_Deserialize_Unix_Json_Dates() { var doc = CreateUnixDateJson(); var d = new JsonDeserializer(); var response = new RestResponse { Content = doc }; var bd = d.Deserialize<Birthdate>(response); Assert.Equal(new DateTime(2011, 6, 30, 8, 15, 46, DateTimeKind.Utc), bd.Value); }
internal async Task <Models.Album> GetAlbumContentsByLinkTextAsync(string userId, string albumLinkText, RequestOptions options) { RestResponse response = await SendAsync("GET", $"users/{userId}/album_links/{albumLinkText}", options).ConfigureAwait(false); return(await response.ReadAsJsonAsync <Models.Album>(Config).ConfigureAwait(false)); }
public void Can_Deserialize_With_Default_Root() { var doc = CreateJson(); var d = new JsonDeserializer(); var response = new RestResponse { Content = doc }; var p = d.Deserialize<PersonForJson>(response); Assert.Equal("John Sheehan", p.Name); Assert.Equal(new DateTime(2009, 9, 25, 0, 6, 1, DateTimeKind.Utc), p.StartDate); Assert.Equal(28, p.Age); Assert.Equal(long.MaxValue, p.BigNumber); Assert.Equal(99.9999m, p.Percent); Assert.Equal(false, p.IsCool); Assert.Equal(new Uri("http://example.com", UriKind.RelativeOrAbsolute), p.Url); Assert.Equal(new Uri("/foo/bar", UriKind.RelativeOrAbsolute), p.UrlPath); Assert.Equal(Guid.Empty, p.EmptyGuid); Assert.Equal(new Guid(GuidString), p.Guid); Assert.Equal(Order.Third, p.Order); Assert.Equal(Disposition.SoSo, p.Disposition); Assert.NotNull(p.Friends); Assert.Equal(10, p.Friends.Count); Assert.NotNull(p.BestFriend); Assert.Equal("The Fonz", p.BestFriend.Name); Assert.Equal(1952, p.BestFriend.Since); Assert.NotEmpty(p.Foes); Assert.Equal("Foe 1", p.Foes["dict1"].Nickname); Assert.Equal("Foe 2", p.Foes["dict2"].Nickname); }
internal async Task ModifyNsfwSettingAsync(string albumId, NsfwSetting setting, RequestOptions options) { RestResponse response = await SendJsonAsync("PUT", $"me/albums/{albumId}/nsfw", new { value = setting }, options).ConfigureAwait(false); }
public void Can_Deserialize_Eventful_Xml() { var xmlpath = PathFor("eventful.xml"); var doc = XDocument.Load(xmlpath); var response = new RestResponse { Content = doc.ToString() }; var d = new XmlDeserializer(); var output = d.Deserialize<SampleClasses.VenueSearch>(response); Assert.NotEmpty(output.venues); Assert.Equal(3, output.venues.Count); Assert.Equal("Tivoli", output.venues[0].name); Assert.Equal("http://eventful.com/brisbane/venues/tivoli-/V0-001-002169294-8", output.venues[1].url); Assert.Equal("V0-001-000266914-3", output.venues[2].id); }
internal async Task ModifyOrderAsync(string albumId, IEnumerable <string> gfyIdsInNewOrder, RequestOptions options) { RestResponse response = await SendJsonAsync("PUT", $"me/albums/{albumId}/order", new { newOrder = gfyIdsInNewOrder }, options).ConfigureAwait(false); }
public void Can_Deserialize_Lastfm_Xml() { var xmlpath = PathFor("Lastfm.xml"); var doc = XDocument.Load(xmlpath); var response = new RestResponse { Content = doc.ToString() }; var d = new XmlDeserializer(); var output = d.Deserialize<SampleClasses.Lastfm.Event>(response); //Assert.NotEmpty(output.artists); Assert.Equal("http://www.last.fm/event/328799+Philip+Glass+at+Barbican+Centre+on+12+June+2008", output.url); Assert.Equal("http://www.last.fm/venue/8777860+Barbican+Centre", output.venue.url); }
internal async Task DeleteAsync(string albumId, RequestOptions options) { RestResponse response = await SendAsync("DELETE", $"me/albums/{albumId}", options).ConfigureAwait(false); }
public void Ignore_ReadOnly_Property_That_Exists_In_Data() { var doc = CreateElementsXml(); var response = new RestResponse { Content = doc }; var d = new XmlDeserializer(); var p = d.Deserialize<PersonForXml>(response); Assert.Null(p.ReadOnlyProxy); }
internal async Task <UploadKey> GetUploadKeyAsync(GfyParameters parameters, RequestOptions options) { RestResponse response = await SendJsonAsync("POST", "gfycats", parameters, options).ConfigureAwait(false); return(await response.ReadAsJsonAsync <UploadKey>(Config).ConfigureAwait(false)); }
private void TimedOutCallback(object state, bool timedOut) { if (!timedOut) { return; } var pair = state as Pair<WebRequest, IAsyncResult>; if (pair != null) { var request = pair.First; var result = pair.Second; #if WindowsPhone // Since this timeout is raised by a timer, check that // reponse has not been completed yet.. if (Interlocked.Increment(ref completed) != 1) { // We have finished so this is not actually a timeout return; } #endif TimedOut = true; request.Abort(); // [DC] LSP violation necessary for POST functionality; // [DC] We did not get far enough along to prepare a response if (result is WebQueryAsyncResult) { var response = new RestResponse { TimedOut = true, StatusCode = 0 }; #if TRACE // Just for cosmetic purposes Trace.WriteLineIf(TraceEnabled, string.Concat("RESPONSE: ", response.StatusCode)); Trace.WriteLineIf(TraceEnabled, "\r\n"); #endif foreach(var postHandle in _postHandles) { postHandle.AsyncState = response; postHandle.Signal(); } _postHandles.Clear(); } } }
internal async Task PostGfyStreamAsync(UploadKey key, Stream stream, RequestOptions options) { options = options ?? RequestOptions.CreateFromDefaults(Config); options.UseAccessToken = false; RestResponse response = await SendStreamAsync("POST", "https://filedrop.gfycat.com/", stream, key.Gfycat, options).ConfigureAwait(false); // uploads as multipart }