diff --git a/src/SparkPost.Tests/CastingHelpers.cs b/src/SparkPost.Tests/CastingHelpers.cs new file mode 100644 index 00000000..d38362fd --- /dev/null +++ b/src/SparkPost.Tests/CastingHelpers.cs @@ -0,0 +1,15 @@ +namespace SparkPost.Tests +{ + public static class CastingHelpers + { + public static T CastAs(this object @object) where T : class + { + return @object as T; + } + + public static T CastTo(this object @object) + { + return (T)@object; + } + } +} diff --git a/src/SparkPost.Tests/ClientTests.cs b/src/SparkPost.Tests/ClientTests.cs index d5001cd6..5c530485 100644 --- a/src/SparkPost.Tests/ClientTests.cs +++ b/src/SparkPost.Tests/ClientTests.cs @@ -2,7 +2,7 @@ using System.Net.Http; using AutoMoq.Helpers; using NUnit.Framework; -using Should; +using Shouldly; namespace SparkPost.Tests { @@ -46,7 +46,7 @@ public void It_should_allow_the_overriding_of_the_http_client_building() [Test] public void It_should_default_to_async() { - client.CustomSettings.SendingMode.ShouldEqual(SendingModes.Async); + client.CustomSettings.SendingMode.ShouldBe(SendingModes.Async); } [Test] @@ -59,7 +59,7 @@ public void it_should_have_inbound_domains() public void It_should_set_any_subaccount_id_passed_to_it() { (new Client(Guid.NewGuid().ToString(), 1234)) - .SubaccountId.ShouldEqual(1234); + .SubaccountId.ShouldBe(1234); } } @@ -75,7 +75,7 @@ public void Setup() [Test] public void It_should_default_to_the_library_version() { - Subject.UserAgent.ShouldEqual($"csharp-sparkpost/1.14.0"); + Subject.UserAgent.ShouldBe($"csharp-sparkpost/1.14.0"); } [Test] @@ -83,7 +83,7 @@ public void It_should_allow_the_user_agent_to_be_changed() { var userAgent = Guid.NewGuid().ToString(); Subject.UserAgent = userAgent; - Subject.UserAgent.ShouldEqual(userAgent); + Subject.UserAgent.ShouldBe(userAgent); } } } diff --git a/src/SparkPost.Tests/DataMapperTests.cs b/src/SparkPost.Tests/DataMapperTests.cs index 6d595a72..fc0d6197 100644 --- a/src/SparkPost.Tests/DataMapperTests.cs +++ b/src/SparkPost.Tests/DataMapperTests.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Linq; using NUnit.Framework; -using Should; +using Shouldly; using SparkPost.ValueMappers; namespace SparkPost.Tests @@ -32,7 +32,7 @@ public void address() ["address"] .CastAs>() ["email"] - .ShouldEqual(value); + .ShouldBe(value); } [Test] @@ -40,7 +40,7 @@ public void return_path() { var value = Guid.NewGuid().ToString(); recipient.ReturnPath = value; - mapper.ToDictionary(recipient)["return_path"].ShouldEqual(value); + mapper.ToDictionary(recipient)["return_path"].ShouldBe(value); } [Test] @@ -54,7 +54,7 @@ public void tags() ["tags"]; theTags .CastAs>() - .Count().ShouldEqual(2); + .Count().ShouldBe(2); mapper.ToDictionary(recipient) ["tags"] .CastAs>() @@ -79,7 +79,7 @@ public void metadata() var value = Guid.NewGuid().ToString(); recipient.Metadata[key] = value; mapper.ToDictionary(recipient)["metadata"] - .CastAs>()[key].ShouldEqual(value); + .CastAs>()[key].ShouldBe(value); } [Test] @@ -95,7 +95,7 @@ public void substitution_data() var value = Guid.NewGuid().ToString(); recipient.SubstitutionData[key] = value; mapper.ToDictionary(recipient)["substitution_data"] - .CastAs>()[key].ShouldEqual(value); + .CastAs>()[key].ShouldBe(value); } [Test] @@ -111,7 +111,7 @@ public void do_not_alter_the_keys_passed_to_substitution_data() var value = Guid.NewGuid().ToString(); recipient.SubstitutionData[key] = value; mapper.ToDictionary(recipient)["substitution_data"] - .CastAs>()[key].ShouldEqual(value); + .CastAs>()[key].ShouldBe(value); } [Test] @@ -140,7 +140,7 @@ public void email() { var value = Guid.NewGuid().ToString(); address.Email = value; - mapper.ToDictionary(address)["email"].ShouldEqual(value); + mapper.ToDictionary(address)["email"].ShouldBe(value); } [Test] @@ -148,7 +148,7 @@ public void name() { var value = Guid.NewGuid().ToString(); address.Name = value; - mapper.ToDictionary(address)["name"].ShouldEqual(value); + mapper.ToDictionary(address)["name"].ShouldBe(value); } [Test] @@ -156,7 +156,7 @@ public void header_to() { var value = Guid.NewGuid().ToString(); address.HeaderTo = value; - mapper.ToDictionary(address)["header_to"].ShouldEqual(value); + mapper.ToDictionary(address)["header_to"].ShouldBe(value); } [Test] @@ -188,7 +188,7 @@ public void It_should_set_the_content_dictionary() mapper.ToDictionary(transmission)["content"] .CastAs>()["from"] .CastAs>()["email"] - .ShouldEqual(email); + .ShouldBe(email); } [Test] @@ -200,13 +200,13 @@ public void It_should_set_the_recipients() transmission.Recipients = new List { recipient1, recipient2 }; var result = mapper.ToDictionary(transmission)["recipients"] as IEnumerable>; - result.Count().ShouldEqual(2); + result.Count().ShouldBe(2); result.ToList()[0]["address"] .CastAs>() - ["email"].ShouldEqual(recipient1.Address.Email); + ["email"].ShouldBe(recipient1.Address.Email); result.ToList()[1]["address"] .CastAs>() - ["email"].ShouldEqual(recipient2.Address.Email); + ["email"].ShouldBe(recipient2.Address.Email); } [Test] @@ -216,7 +216,7 @@ public void It_should_set_the_recipients_to_a_list_id_if_a_list_id_is_provided() transmission.ListId = listId; var result = mapper.ToDictionary(transmission)["recipients"] as IDictionary; - result["list_id"].ShouldEqual(listId); + result["list_id"].ShouldBe(listId); } [Test] @@ -224,7 +224,7 @@ public void campaign_id() { var value = Guid.NewGuid().ToString(); transmission.CampaignId = value; - mapper.ToDictionary(transmission)["campaign_id"].ShouldEqual(value); + mapper.ToDictionary(transmission)["campaign_id"].ShouldBe(value); } [Test] @@ -232,7 +232,7 @@ public void description() { var value = Guid.NewGuid().ToString(); transmission.Description = value; - mapper.ToDictionary(transmission)["description"].ShouldEqual(value); + mapper.ToDictionary(transmission)["description"].ShouldBe(value); } [Test] @@ -240,7 +240,7 @@ public void return_path() { var value = Guid.NewGuid().ToString(); transmission.ReturnPath = value; - mapper.ToDictionary(transmission)["return_path"].ShouldEqual(value); + mapper.ToDictionary(transmission)["return_path"].ShouldBe(value); } [Test] @@ -256,7 +256,7 @@ public void metadata() var value = Guid.NewGuid().ToString(); transmission.Metadata[key] = value; mapper.ToDictionary(transmission)["metadata"] - .CastAs>()[key].ShouldEqual(value); + .CastAs>()[key].ShouldBe(value); } [Test] @@ -272,7 +272,7 @@ public void substitution_data() var value = Guid.NewGuid().ToString(); transmission.SubstitutionData[key] = value; mapper.ToDictionary(transmission)["substitution_data"] - .CastAs>()[key].ShouldEqual(value); + .CastAs>()[key].ShouldBe(value); } [Test] @@ -288,7 +288,7 @@ public void do_not_alter_the_keys_passed_to_substitution_data() var value = Guid.NewGuid().ToString(); transmission.SubstitutionData[key] = value; mapper.ToDictionary(transmission)["substitution_data"] - .CastAs>()[key].ShouldEqual(value); + .CastAs>()[key].ShouldBe(value); } [Test] @@ -297,17 +297,17 @@ public void options() transmission.Options.ClickTracking = true; mapper.ToDictionary(transmission)["options"] .CastAs>() - ["click_tracking"].ShouldEqual(true); + ["click_tracking"].ShouldBe(true); transmission.Options.ClickTracking = false; mapper.ToDictionary(transmission)["options"] .CastAs>() - ["click_tracking"].ShouldEqual(false); + ["click_tracking"].ShouldBe(false); transmission.Options.InlineCss = true; mapper.ToDictionary(transmission)["options"] .CastAs>() - ["inline_css"].ShouldEqual(true); + ["inline_css"].ShouldBe(true); } } @@ -344,7 +344,7 @@ public void It_should_set_the_CC_Header_for_only_the_cc_emails(bool useTo) .CastAs>() ["CC"]; - cc.ShouldEqual(recipient1.Address.Email + ", " + recipient3.Address.Email); + cc.ShouldBe(recipient1.Address.Email + ", " + recipient3.Address.Email); } [TestCase(true)] @@ -367,7 +367,7 @@ public void It_should_not_overwrite_any_existing_headers(bool useTo) .CastAs>() ["headers"] .CastAs>() - [key].ShouldEqual(value); + [key].ShouldBe(value); } [TestCase(true)] @@ -467,8 +467,8 @@ public void It_should_set_the_name_and_header_to_fields() foreach (var address in addresses) { - address["name"].ShouldEqual(toName); - address["header_to"].ShouldEqual(toEmail); + address["name"].ShouldBe(toName); + address["header_to"].ShouldBe(toEmail); } } @@ -488,7 +488,7 @@ public void It_should_format_addresses_correctly(string name, string address, st ["headers"] .CastAs>() ["CC"] - .ShouldEqual(result); + .ShouldBe(result); } [TestCase("Jones, Bob", "bob@jones.com ", "\"Jones, Bob\" ")] @@ -505,7 +505,7 @@ public void It_should_handle_white_space_in_the_email(string name, string addres ["headers"] .CastAs>() ["CC"] - .ShouldEqual(result); + .ShouldBe(result); } [TestCase(0)] @@ -529,9 +529,9 @@ public void It_should_use_new_or_legacy_handling(int numOfTos) ["CC"]; if (numOfTos == 1) - ccHeader.ShouldEqual(ccAddress); + ccHeader.ShouldBe(ccAddress); else - ccHeader.ShouldEqual($"<{ccAddress}>"); + ccHeader.ShouldBe($"<{ccAddress}>"); } [Test] @@ -548,7 +548,7 @@ public void It_should_use_legacy_handling_if_to_address_is_null() .CastAs>() ["CC"]; - ccHeader.ShouldEqual($"<{ccAddress}>"); + ccHeader.ShouldBe($"<{ccAddress}>"); } } @@ -574,9 +574,9 @@ public void from() var result = mapper.ToDictionary(content)["from"].CastAs>(); - result["email"].ShouldEqual(content.From.Email); - result["header_to"].ShouldEqual(content.From.HeaderTo); - result["name"].ShouldEqual(content.From.Name); + result["email"].ShouldBe(content.From.Email); + result["header_to"].ShouldBe(content.From.HeaderTo); + result["name"].ShouldBe(content.From.Name); } [Test] @@ -584,7 +584,7 @@ public void subject() { var value = Guid.NewGuid().ToString(); content.Subject = value; - mapper.ToDictionary(content)["subject"].ShouldEqual(value); + mapper.ToDictionary(content)["subject"].ShouldBe(value); } [Test] @@ -592,7 +592,7 @@ public void text() { var value = Guid.NewGuid().ToString(); content.Text = value; - mapper.ToDictionary(content)["text"].ShouldEqual(value); + mapper.ToDictionary(content)["text"].ShouldBe(value); } [Test] @@ -600,7 +600,7 @@ public void template_id() { var value = Guid.NewGuid().ToString(); content.TemplateId = value; - mapper.ToDictionary(content)["template_id"].ShouldEqual(value); + mapper.ToDictionary(content)["template_id"].ShouldBe(value); } [Test] @@ -608,7 +608,7 @@ public void html() { var value = Guid.NewGuid().ToString(); content.Html = value; - mapper.ToDictionary(content)["html"].ShouldEqual(value); + mapper.ToDictionary(content)["html"].ShouldBe(value); } [Test] @@ -616,7 +616,7 @@ public void reply_to() { var value = Guid.NewGuid().ToString(); content.ReplyTo = value; - mapper.ToDictionary(content)["reply_to"].ShouldEqual(value); + mapper.ToDictionary(content)["reply_to"].ShouldBe(value); } [Test] @@ -627,7 +627,7 @@ public void headers() content.Headers[key] = value; mapper.ToDictionary(content)["headers"] .CastAs>() - [key].ShouldEqual(value); + [key].ShouldBe(value); } [Test] @@ -650,7 +650,7 @@ public void attachments() .Select(x => x.CastAs>()) .Select(x => x["name"]); - names.Count().ShouldEqual(2); + names.Count().ShouldBe(2); names.ShouldContain(firstName); names.ShouldContain(secondName); } @@ -675,7 +675,7 @@ public void inline_images() .Select(x => x.CastAs>()) .Select(x => x["name"]); - names.Count().ShouldEqual(2); + names.Count().ShouldBe(2); names.ShouldContain(firstName); names.ShouldContain(secondName); } @@ -711,11 +711,11 @@ public void open_tracking() { options.OpenTracking = true; mapper.ToDictionary(options).CastAs>() - ["open_tracking"].ShouldEqual(true); + ["open_tracking"].ShouldBe(true); options.OpenTracking = false; mapper.ToDictionary(options).CastAs>() - ["open_tracking"].ShouldEqual(false); + ["open_tracking"].ShouldBe(false); } [Test] @@ -723,11 +723,11 @@ public void click_tracking() { options.ClickTracking = true; mapper.ToDictionary(options).CastAs>() - ["click_tracking"].ShouldEqual(true); + ["click_tracking"].ShouldBe(true); options.ClickTracking = false; mapper.ToDictionary(options).CastAs>() - ["click_tracking"].ShouldEqual(false); + ["click_tracking"].ShouldBe(false); } [Test] @@ -735,11 +735,11 @@ public void transactional() { options.Transactional = true; mapper.ToDictionary(options).CastAs>() - ["transactional"].ShouldEqual(true); + ["transactional"].ShouldBe(true); options.Transactional = false; mapper.ToDictionary(options).CastAs>() - ["transactional"].ShouldEqual(false); + ["transactional"].ShouldBe(false); } [Test] @@ -747,11 +747,11 @@ public void sandbox() { options.Sandbox = true; mapper.ToDictionary(options).CastAs>() - ["sandbox"].ShouldEqual(true); + ["sandbox"].ShouldBe(true); options.Sandbox = false; mapper.ToDictionary(options).CastAs>() - ["sandbox"].ShouldEqual(false); + ["sandbox"].ShouldBe(false); } [Test] @@ -759,11 +759,11 @@ public void skip_suppression() { options.SkipSuppression = true; mapper.ToDictionary(options).CastAs>() - ["skip_suppression"].ShouldEqual(true); + ["skip_suppression"].ShouldBe(true); options.SkipSuppression = false; mapper.ToDictionary(options).CastAs>() - ["skip_suppression"].ShouldEqual(false); + ["skip_suppression"].ShouldBe(false); } [Test] @@ -772,12 +772,12 @@ public void start_time() var startTime = "2015-02-11T08:00:00-04:00"; options.StartTime = DateTimeOffset.Parse(startTime); mapper.ToDictionary(options).CastAs>() - ["start_time"].ShouldEqual(startTime); + ["start_time"].ShouldBe(startTime); startTime = "2015-02-11T08:00:00-14:00"; options.StartTime = DateTimeOffset.Parse(startTime); mapper.ToDictionary(options).CastAs>() - ["start_time"].ShouldEqual(startTime); + ["start_time"].ShouldBe(startTime); } [Test] @@ -794,11 +794,11 @@ public void inline_css() { options.InlineCss = true; mapper.ToDictionary(options).CastAs>() - ["inline_css"].ShouldEqual(true); + ["inline_css"].ShouldBe(true); options.InlineCss = false; mapper.ToDictionary(options).CastAs>() - ["inline_css"].ShouldEqual(false); + ["inline_css"].ShouldBe(false); } [Test] @@ -807,7 +807,7 @@ public void ip_pool() var ipPool = Guid.NewGuid().ToString(); options.IpPool = ipPool; mapper.ToDictionary(options).CastAs>() - ["ip_pool"].ShouldEqual(ipPool); + ["ip_pool"].ShouldBe(ipPool); } } @@ -829,7 +829,7 @@ public void name() { var value = Guid.NewGuid().ToString(); file.Name = value; - mapper.ToDictionary(file)["name"].ShouldEqual(value); + mapper.ToDictionary(file)["name"].ShouldBe(value); } [Test] @@ -837,7 +837,7 @@ public void type() { var value = Guid.NewGuid().ToString(); file.Type = value; - mapper.ToDictionary(file)["type"].ShouldEqual(value); + mapper.ToDictionary(file)["type"].ShouldBe(value); } [Test] @@ -845,7 +845,7 @@ public void data() { var value = Guid.NewGuid().ToString(); file.Data = value; - mapper.ToDictionary(file)["data"].ShouldEqual(value); + mapper.ToDictionary(file)["data"].ShouldBe(value); } } @@ -864,28 +864,28 @@ public void Setup() public void Name() { var webhook = new Webhook {Name = Guid.NewGuid().ToString()}; - dataMapper.ToDictionary(webhook)["name"].ShouldEqual(webhook.Name); + dataMapper.ToDictionary(webhook)["name"].ShouldBe(webhook.Name); } [Test] public void Target() { var webhook = new Webhook {Target = Guid.NewGuid().ToString()}; - dataMapper.ToDictionary(webhook)["target"].ShouldEqual(webhook.Target); + dataMapper.ToDictionary(webhook)["target"].ShouldBe(webhook.Target); } [Test] public void AuthType() { var webhook = new Webhook {AuthType = Guid.NewGuid().ToString()}; - dataMapper.ToDictionary(webhook)["auth_type"].ShouldEqual(webhook.AuthType); + dataMapper.ToDictionary(webhook)["auth_type"].ShouldBe(webhook.AuthType); } [Test] public void AuthToken() { var webhook = new Webhook {AuthToken = Guid.NewGuid().ToString()}; - dataMapper.ToDictionary(webhook)["auth_token"].ShouldEqual(webhook.AuthToken); + dataMapper.ToDictionary(webhook)["auth_token"].ShouldBe(webhook.AuthToken); } [Test] @@ -900,7 +900,7 @@ public void Events() var dictionary = dataMapper.ToDictionary(webhook); var events = dictionary["events"] as IEnumerable; - events.Count().ShouldEqual(2); + events.Count().ShouldBe(2); events.ShouldContain(first); events.ShouldContain(second); } @@ -919,17 +919,17 @@ public void AuthRequestDetails() var dictionary = dataMapper.ToDictionary(webhook); var authRequestDetails = dictionary["auth_request_details"].CastAs>(); - authRequestDetails["url"].ShouldEqual("https://oauth.myurl.com/tokens"); + authRequestDetails["url"].ShouldBe("https://oauth.myurl.com/tokens"); authRequestDetails["body"] .CastAs>() ["client_id"] - .ShouldEqual(""); + .ShouldBe(""); authRequestDetails["body"] .CastAs>() ["client_secret"] - .ShouldEqual(""); + .ShouldBe(""); } [Test] @@ -946,8 +946,8 @@ public void AuthCredentials() var dictionary = dataMapper.ToDictionary(webhook); var authRequestDetails = dictionary["auth_credentials"] as Dictionary; - authRequestDetails["access_token"].ShouldEqual(""); - authRequestDetails["expires_in"].ShouldEqual(3600); + authRequestDetails["access_token"].ShouldBe(""); + authRequestDetails["expires_in"].ShouldBe(3600); } } @@ -967,35 +967,35 @@ public void Setup() public void Id() { var subaccount = new Subaccount { Id = 432 }; - dataMapper.ToDictionary(subaccount)["id"].ShouldEqual(subaccount.Id); + dataMapper.ToDictionary(subaccount)["id"].ShouldBe(subaccount.Id); } [Test] public void Name() { var subaccount = new Subaccount { Name = Guid.NewGuid().ToString() }; - dataMapper.ToDictionary(subaccount)["name"].ShouldEqual(subaccount.Name); + dataMapper.ToDictionary(subaccount)["name"].ShouldBe(subaccount.Name); } [Test] public void Status() { var subaccount = new Subaccount { Status = SubaccountStatus.Terminated }; - dataMapper.ToDictionary(subaccount)["status"].ShouldEqual(SubaccountStatus.Terminated.ToString().ToLowerInvariant()); + dataMapper.ToDictionary(subaccount)["status"].ShouldBe(SubaccountStatus.Terminated.ToString().ToLowerInvariant()); } [Test] public void IpPool() { var subaccount = new Subaccount { IpPool = Guid.NewGuid().ToString() }; - dataMapper.ToDictionary(subaccount)["ip_pool"].ShouldEqual(subaccount.IpPool); + dataMapper.ToDictionary(subaccount)["ip_pool"].ShouldBe(subaccount.IpPool); } [Test] public void ComplianceStatus() { var subaccount = new Subaccount { ComplianceStatus = Guid.NewGuid().ToString() }; - dataMapper.ToDictionary(subaccount)["compliance_status"].ShouldEqual(subaccount.ComplianceStatus); + dataMapper.ToDictionary(subaccount)["compliance_status"].ShouldBe(subaccount.ComplianceStatus); } } @@ -1011,9 +1011,9 @@ public void It_should_map_anything_using_our_conventions() var result = dataMapper.CatchAll(new {FirstName = "Test1", LastName = "Test2", TheDate = dateTime}); - result["first_name"].ShouldEqual("Test1"); - result["last_name"].ShouldEqual("Test2"); - ((string)result["the_date"]).Substring(0, 16).ShouldEqual("2016-01-02T03:04"); + result["first_name"].ShouldBe("Test1"); + result["last_name"].ShouldBe("Test2"); + ((string)result["the_date"]).Substring(0, 16).ShouldBe("2016-01-02T03:04"); } } @@ -1035,7 +1035,7 @@ public void name() { var value = Guid.NewGuid().ToString(); relayWebhook.Name = value; - mapper.ToDictionary(relayWebhook)["name"].ShouldEqual(value); + mapper.ToDictionary(relayWebhook)["name"].ShouldBe(value); } [Test] @@ -1045,7 +1045,7 @@ public void match_domain() relayWebhook.Match = new RelayWebhookMatch {Domain = value}; mapper.ToDictionary(relayWebhook)["match"] .CastAs>() - ["domain"].ShouldEqual(value); + ["domain"].ShouldBe(value); } [Test] @@ -1055,7 +1055,7 @@ public void match_protocol() relayWebhook.Match = new RelayWebhookMatch {Protocol = value}; mapper.ToDictionary(relayWebhook)["match"] .CastAs>() - ["protocol"].ShouldEqual(value); + ["protocol"].ShouldBe(value); } } @@ -1081,7 +1081,7 @@ public void Matches_on_status() .CastAs>() ["dkim_status"] .CastAs() - .ShouldEqual("pending"); + .ShouldBe("pending"); } [Test] @@ -1103,7 +1103,7 @@ public void Matches_on_dkim() .CastAs>() ["public_key"] .CastAs() - .ShouldEqual(publicKey); + .ShouldBe(publicKey); } [Test] diff --git a/src/SparkPost.Tests/License.txt b/src/SparkPost.Tests/License.txt deleted file mode 100644 index 5ead6991..00000000 --- a/src/SparkPost.Tests/License.txt +++ /dev/null @@ -1,22 +0,0 @@ - Copyright (c) 2010 Darren Cauthon - - Permission is hereby granted, free of charge, to any person - obtaining a copy of this software and associated documentation - files (the "Software"), to deal in the Software without - restriction, including without limitation the rights to use, - copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the - Software is furnished to do so, subject to the following - conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - OTHER DEALINGS IN THE SOFTWARE. diff --git a/src/SparkPost.Tests/ListMessageEventsResponseTests.cs b/src/SparkPost.Tests/ListMessageEventsResponseTests.cs index 4d4563a7..5642cd4e 100644 --- a/src/SparkPost.Tests/ListMessageEventsResponseTests.cs +++ b/src/SparkPost.Tests/ListMessageEventsResponseTests.cs @@ -1,5 +1,5 @@ using NUnit.Framework; -using Should; +using Shouldly; namespace SparkPost.Tests { diff --git a/src/SparkPost.Tests/MessageEventsQueryTests.cs b/src/SparkPost.Tests/MessageEventsQueryTests.cs index 9c3186ab..859c7c8e 100644 --- a/src/SparkPost.Tests/MessageEventsQueryTests.cs +++ b/src/SparkPost.Tests/MessageEventsQueryTests.cs @@ -1,5 +1,5 @@ using NUnit.Framework; -using Should; +using Shouldly; namespace SparkPost.Tests { diff --git a/src/SparkPost.Tests/Properties/AssemblyInfo.cs b/src/SparkPost.Tests/Properties/AssemblyInfo.cs deleted file mode 100644 index 318fa85b..00000000 --- a/src/SparkPost.Tests/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("SparkPost.Tests")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("SparkPost.Tests")] -[assembly: AssemblyCopyright("Copyright © 2016")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("52f2f4f4-3de2-49c6-87d8-bd6f825b9372")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/SparkPost.Tests/RelayWebhookTests.cs b/src/SparkPost.Tests/RelayWebhookTests.cs index 710e8585..6b39dccc 100644 --- a/src/SparkPost.Tests/RelayWebhookTests.cs +++ b/src/SparkPost.Tests/RelayWebhookTests.cs @@ -1,5 +1,5 @@ using NUnit.Framework; -using Should; +using Shouldly; namespace SparkPost.Tests { @@ -17,7 +17,7 @@ public void It_should_initialize_match() [Test] public void It_should_initialize_match_protocol() { - (new RelayWebhook()).Match.Protocol.ShouldEqual("SMTP"); + (new RelayWebhook()).Match.Protocol.ShouldBe("SMTP"); } } } diff --git a/src/SparkPost.Tests/RequestMethodFinderTests.cs b/src/SparkPost.Tests/RequestMethodFinderTests.cs index 5d533761..86068bef 100644 --- a/src/SparkPost.Tests/RequestMethodFinderTests.cs +++ b/src/SparkPost.Tests/RequestMethodFinderTests.cs @@ -1,6 +1,6 @@ using AutoMoq.Helpers; using NUnit.Framework; -using Should; +using Shouldly; using SparkPost.RequestMethods; namespace SparkPost.Tests diff --git a/src/SparkPost.Tests/RequestMethods/DeleteTests.cs b/src/SparkPost.Tests/RequestMethods/DeleteTests.cs index e7097bd0..f269819e 100644 --- a/src/SparkPost.Tests/RequestMethods/DeleteTests.cs +++ b/src/SparkPost.Tests/RequestMethods/DeleteTests.cs @@ -1,7 +1,7 @@ using System; using AutoMoq.Helpers; using NUnit.Framework; -using Should; +using Shouldly; using SparkPost.RequestMethods; namespace SparkPost.Tests.RequestMethods diff --git a/src/SparkPost.Tests/RequestSenders/RequestSenderTests.cs b/src/SparkPost.Tests/RequestSenders/RequestSenderTests.cs index 95296398..c4e2fa8e 100644 --- a/src/SparkPost.Tests/RequestSenders/RequestSenderTests.cs +++ b/src/SparkPost.Tests/RequestSenders/RequestSenderTests.cs @@ -2,7 +2,7 @@ using AutoMoq.Helpers; using Moq; using NUnit.Framework; -using Should; +using Shouldly; using SparkPost.RequestSenders; namespace SparkPost.Tests.RequestSenders diff --git a/src/SparkPost.Tests/SparkPost.Tests.csproj b/src/SparkPost.Tests/SparkPost.Tests.csproj index 5a2d99f7..241565f7 100644 --- a/src/SparkPost.Tests/SparkPost.Tests.csproj +++ b/src/SparkPost.Tests/SparkPost.Tests.csproj @@ -1,150 +1,16 @@ - - - + + - Debug - AnyCPU - {52F2F4F4-3DE2-49C6-87D8-BD6F825B9372} - Library - Properties - SparkPost.Tests - SparkPost.Tests - v4.5 - 512 - + netstandard1.6 - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\packages\AutoMoq.1.7.1.0\lib\net40\AutoMoq.dll - True - - - ..\packages\CastAs.4.0\lib\CastAs.dll - True - - - ..\packages\Unity.2.0\lib\20\Microsoft.Practices.ServiceLocation.dll - True - - - ..\packages\Unity.2.0\lib\20\Microsoft.Practices.Unity.dll - True - - - ..\packages\Unity.2.0\lib\20\Microsoft.Practices.Unity.Configuration.dll - True - - - ..\packages\Unity.2.0\lib\20\Microsoft.Practices.Unity.Interception.dll - True - - - ..\packages\Unity.2.0\lib\20\Microsoft.Practices.Unity.Interception.Configuration.dll - True - - - ..\packages\Moq.4.1.1308.2120\lib\net40\Moq.dll - True - - - False - ..\packages\Newtonsoft.Json.6.0.1\lib\net45\Newtonsoft.Json.dll - - - ..\packages\NUnitTestAdapter.2.0.0\lib\nunit.core.dll - False - - - ..\packages\NUnitTestAdapter.2.0.0\lib\nunit.core.interfaces.dll - False - - - ..\packages\NUnit.2.6.4\lib\nunit.framework.dll - True - - - ..\packages\NUnitTestAdapter.2.0.0\lib\nunit.util.dll - False - - - ..\packages\NUnitTestAdapter.2.0.0\lib\NUnit.VisualStudio.TestAdapter.dll - False - - - ..\packages\Should.1.1.20\lib\Should.dll - True - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {a5dda3e3-7b3d-46c3-b4bb-c627fba37812} - SparkPost - - - - - - + - + + + - + - - + \ No newline at end of file diff --git a/src/SparkPost.Tests/SubaccountTest.cs b/src/SparkPost.Tests/SubaccountTest.cs index 5a42d028..8caf104b 100644 --- a/src/SparkPost.Tests/SubaccountTest.cs +++ b/src/SparkPost.Tests/SubaccountTest.cs @@ -1,5 +1,5 @@ using NUnit.Framework; -using Should; +using Shouldly; namespace SparkPost.Tests { diff --git a/src/SparkPost.Tests/SuppressionTests.cs b/src/SparkPost.Tests/SuppressionTests.cs index 2473f1a6..beeb4bb0 100644 --- a/src/SparkPost.Tests/SuppressionTests.cs +++ b/src/SparkPost.Tests/SuppressionTests.cs @@ -6,7 +6,6 @@ using AutoMoq.Helpers; using Moq; using NUnit.Framework; -using Should; using SparkPost.RequestSenders; namespace SparkPost.Tests diff --git a/src/SparkPost.Tests/TransmissionTests.cs b/src/SparkPost.Tests/TransmissionTests.cs index 16b0c897..f9972f25 100644 --- a/src/SparkPost.Tests/TransmissionTests.cs +++ b/src/SparkPost.Tests/TransmissionTests.cs @@ -4,7 +4,7 @@ using System.Runtime.CompilerServices; using Moq; using NUnit.Framework; -using Should; +using Shouldly; using System.Net.Mail; using System.Net.Mime; using System.IO; @@ -74,8 +74,8 @@ public void Setup() [Test] public void From_should_match() { - transmission.Content.From.Name.ShouldEqual(mailMessage.From.DisplayName); - transmission.Content.From.Email.ShouldEqual(mailMessage.From.Address); + transmission.Content.From.Name.ShouldBe(mailMessage.From.DisplayName); + transmission.Content.From.Email.ShouldBe(mailMessage.From.Address); } [Test] diff --git a/src/SparkPost.Tests/Utilities/SnakeCaseTests.cs b/src/SparkPost.Tests/Utilities/SnakeCaseTests.cs index 2b0c12e8..52215af5 100644 --- a/src/SparkPost.Tests/Utilities/SnakeCaseTests.cs +++ b/src/SparkPost.Tests/Utilities/SnakeCaseTests.cs @@ -1,5 +1,5 @@ using NUnit.Framework; -using Should; +using Shouldly; using SparkPost.Utilities; namespace SparkPost.Tests.Utilities @@ -10,10 +10,10 @@ public class SnakeCaseTests [Test] public void It_should_convert_things_to_snake_case() { - SnakeCase.Convert("T").ShouldEqual("t"); - SnakeCase.Convert("Test").ShouldEqual("test"); - SnakeCase.Convert("TEST").ShouldEqual("t_e_s_t"); - SnakeCase.Convert("JohnGalt").ShouldEqual("john_galt"); + SnakeCase.Convert("T").ShouldBe("t"); + SnakeCase.Convert("Test").ShouldBe("test"); + SnakeCase.Convert("TEST").ShouldBe("t_e_s_t"); + SnakeCase.Convert("JohnGalt").ShouldBe("john_galt"); } [Test] diff --git a/src/SparkPost.Tests/app.config b/src/SparkPost.Tests/app.config deleted file mode 100644 index 4d8c53d1..00000000 --- a/src/SparkPost.Tests/app.config +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/src/SparkPost.Tests/packages.config b/src/SparkPost.Tests/packages.config deleted file mode 100644 index a0e36ec8..00000000 --- a/src/SparkPost.Tests/packages.config +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/src/SparkPost.sln b/src/SparkPost.sln index 176fb061..ea24a747 100644 --- a/src/SparkPost.sln +++ b/src/SparkPost.sln @@ -1,13 +1,11 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25420.1 +# Visual Studio 15 +VisualStudioVersion = 15.0.26430.13 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SparkPost", "SparkPost\SparkPost.csproj", "{A5DDA3E3-7B3D-46C3-B4BB-C627FBA37812}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SparkPost", "SparkPost\SparkPost.csproj", "{12A3D027-7A47-47FD-A166-14ED54833E70}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SparkPost.Tests", "SparkPost.Tests\SparkPost.Tests.csproj", "{52F2F4F4-3DE2-49C6-87D8-BD6F825B9372}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SparkPost.Acceptance", "SparkPost.Acceptance\SparkPost.Acceptance.csproj", "{8F62193B-1C44-4E92-96C7-8EBD610F7669}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SparkPost.Tests", "SparkPost.Tests\SparkPost.Tests.csproj", "{2F33494D-6335-404F-9554-B63549B67001}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -15,18 +13,14 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {A5DDA3E3-7B3D-46C3-B4BB-C627FBA37812}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A5DDA3E3-7B3D-46C3-B4BB-C627FBA37812}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A5DDA3E3-7B3D-46C3-B4BB-C627FBA37812}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A5DDA3E3-7B3D-46C3-B4BB-C627FBA37812}.Release|Any CPU.Build.0 = Release|Any CPU - {52F2F4F4-3DE2-49C6-87D8-BD6F825B9372}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {52F2F4F4-3DE2-49C6-87D8-BD6F825B9372}.Debug|Any CPU.Build.0 = Debug|Any CPU - {52F2F4F4-3DE2-49C6-87D8-BD6F825B9372}.Release|Any CPU.ActiveCfg = Release|Any CPU - {52F2F4F4-3DE2-49C6-87D8-BD6F825B9372}.Release|Any CPU.Build.0 = Release|Any CPU - {8F62193B-1C44-4E92-96C7-8EBD610F7669}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8F62193B-1C44-4E92-96C7-8EBD610F7669}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8F62193B-1C44-4E92-96C7-8EBD610F7669}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8F62193B-1C44-4E92-96C7-8EBD610F7669}.Release|Any CPU.Build.0 = Release|Any CPU + {12A3D027-7A47-47FD-A166-14ED54833E70}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {12A3D027-7A47-47FD-A166-14ED54833E70}.Debug|Any CPU.Build.0 = Debug|Any CPU + {12A3D027-7A47-47FD-A166-14ED54833E70}.Release|Any CPU.ActiveCfg = Release|Any CPU + {12A3D027-7A47-47FD-A166-14ED54833E70}.Release|Any CPU.Build.0 = Release|Any CPU + {2F33494D-6335-404F-9554-B63549B67001}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2F33494D-6335-404F-9554-B63549B67001}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2F33494D-6335-404F-9554-B63549B67001}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2F33494D-6335-404F-9554-B63549B67001}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/SparkPost/DataMapper.cs b/src/SparkPost/DataMapper.cs index ac3ce89b..f1046a54 100644 --- a/src/SparkPost/DataMapper.cs +++ b/src/SparkPost/DataMapper.cs @@ -223,14 +223,14 @@ public IDictionary CatchAll(object anything) { var converters = ToDictionaryMethods(); if (converters.ContainsKey(anything.GetType())) - return converters[anything.GetType()].Invoke(this, BindingFlags.Default, null, - new[] {anything}, CultureInfo.CurrentCulture) as IDictionary; + return converters[anything.GetType()].Invoke(this, + new[] {anything}) as IDictionary; return WithCommonConventions(anything); } public IDictionary ToDictionaryMethods() { - return this.GetType().GetMethods() + return this.GetType().GetTypeInfo().GetMethods() .Where(x => x.Name == "ToDictionary") .Where(x => x.GetParameters().Length == 1) .Select(x => new @@ -244,6 +244,7 @@ public IDictionary ToDictionaryMethods() private static bool AnyValuesWereSetOn(object target) { return target.GetType() + .GetTypeInfo() .GetProperties() .Any(x => x.GetValue(target) != null); } @@ -259,7 +260,7 @@ private IDictionary WithCommonConventions(object target, IDictio { if (target == null) return null; if (results == null) results = new Dictionary(); - foreach (var property in target.GetType().GetProperties()) + foreach (var property in target.GetType().GetTypeInfo().GetProperties()) { var name = SnakeCase.Convert(property.Name); if (results.ContainsKey(name)) continue; diff --git a/src/SparkPost/File.cs b/src/SparkPost/File.cs index 5b85d0eb..75894b2c 100644 --- a/src/SparkPost/File.cs +++ b/src/SparkPost/File.cs @@ -1,6 +1,6 @@ using System; using System.IO; -using System.Web; +using SparkPost.Utilities; namespace SparkPost { @@ -34,7 +34,7 @@ public abstract class File if (content != null) { result.Data = Convert.ToBase64String(content); - result.Type = MimeMapping.GetMimeMapping(name); + result.Type = MimeTypes.GetMimeType(name); result.Name = name; }; return result; diff --git a/src/SparkPost/LeftRight.cs b/src/SparkPost/LeftRight.cs index 492fb674..b8063fdc 100644 --- a/src/SparkPost/LeftRight.cs +++ b/src/SparkPost/LeftRight.cs @@ -1,4 +1,5 @@ using System.Linq; +using System.Reflection; namespace SparkPost { @@ -6,8 +7,8 @@ public static class LeftRight { public static void SetValuesToMatch(object left, object right) { - var leftProperties = left.GetType().GetProperties(); - var rightProperties = left.GetType().GetProperties(); + var leftProperties = left.GetType().GetTypeInfo().GetProperties(); + var rightProperties = left.GetType().GetTypeInfo().GetProperties(); foreach (var rightProperty in rightProperties) { try diff --git a/src/SparkPost/MessageEvent.cs b/src/SparkPost/MessageEvent.cs index 666e7e7d..ffc49ed5 100644 --- a/src/SparkPost/MessageEvent.cs +++ b/src/SparkPost/MessageEvent.cs @@ -26,7 +26,7 @@ public MessageEventType TypeEnum foreach (var typeName in Enum.GetNames(typeof(MessageEventType))) { var typeNameSnakeCase = SnakeCase.Convert(typeName); - if (string.Equals(Type, typeNameSnakeCase, StringComparison.InvariantCultureIgnoreCase)) + if (string.Equals(Type, typeNameSnakeCase)) // check for an unmapped message event type here return (MessageEventType)Enum.Parse(typeof(MessageEventType), typeName); } diff --git a/src/SparkPost/Properties/AssemblyInfo.cs b/src/SparkPost/Properties/AssemblyInfo.cs deleted file mode 100644 index e754ef39..00000000 --- a/src/SparkPost/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("SparkPost")] -[assembly: AssemblyDescription("SparkPost API")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("SparkPost")] -[assembly: AssemblyProduct("SparkPost")] -[assembly: AssemblyCopyright("Copyright © 2016")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("a5dda3e3-7b3d-46c3-b4bb-c627fba37812")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.14.0.*")] -[assembly: AssemblyFileVersion("1.14.0.0")] diff --git a/src/SparkPost/RequestMethods/Get.cs b/src/SparkPost/RequestMethods/Get.cs index b49220fc..aa4ee3eb 100644 --- a/src/SparkPost/RequestMethods/Get.cs +++ b/src/SparkPost/RequestMethods/Get.cs @@ -2,9 +2,9 @@ using System.Collections.Generic; using System.ComponentModel; using System.Linq; +using System.Net; using System.Net.Http; using System.Threading.Tasks; -using System.Web; using SparkPost.Utilities; namespace SparkPost.RequestMethods @@ -37,7 +37,7 @@ private string ConvertToQueryString(object data) dictionary[thing.Key] = thing.Value.ToString(); var values = dictionary - .Select(x => HttpUtility.UrlEncode(SnakeCase.Convert(x.Key)) + "=" + HttpUtility.UrlEncode(x.Value)); + .Select(x => WebUtility.UrlEncode(SnakeCase.Convert(x.Key)) + "=" + WebUtility.UrlEncode(x.Value)); return string.Join("&", values); } diff --git a/src/SparkPost/SendingDomains.cs b/src/SparkPost/SendingDomains.cs index 64b35f03..68fc87be 100644 --- a/src/SparkPost/SendingDomains.cs +++ b/src/SparkPost/SendingDomains.cs @@ -1,6 +1,5 @@ using System.Net; using System.Threading.Tasks; -using System.Web; using SparkPost.RequestSenders; using SparkPost.Utilities; @@ -114,7 +113,7 @@ public async Task Delete(string domain) if (response.StatusCode == HttpStatusCode.NoContent) { response.StatusCode = HttpStatusCode.OK; - response.ReasonPhrase = HttpWorkerRequest.GetStatusDescription((int)HttpStatusCode.OK); + response.ReasonPhrase = "OK"; } if (response.StatusCode != HttpStatusCode.OK) throw new ResponseException(response); diff --git a/src/SparkPost/SparkPost.csproj b/src/SparkPost/SparkPost.csproj index 06550cd1..b37629bb 100644 --- a/src/SparkPost/SparkPost.csproj +++ b/src/SparkPost/SparkPost.csproj @@ -1,192 +1,15 @@ - - - + + - Debug - AnyCPU - {A5DDA3E3-7B3D-46C3-B4BB-C627FBA37812} - Library - Properties - SparkPost - SparkPost - v4.5 - 512 - + netstandard1.6 - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - bin\Debug\SparkPost.xml - 1591 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - bin\Release\SparkPost.xml - 1591 - - - - ..\packages\Newtonsoft.Json.6.0.1\lib\net45\Newtonsoft.Json.dll - True - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - + - - - + \ No newline at end of file diff --git a/src/SparkPost/Suppressions.cs b/src/SparkPost/Suppressions.cs index ceeb44ba..1153c248 100644 --- a/src/SparkPost/Suppressions.cs +++ b/src/SparkPost/Suppressions.cs @@ -2,7 +2,6 @@ using System.Linq; using System.Net; using System.Threading.Tasks; -using System.Web; using SparkPost.RequestSenders; using SparkPost.Utilities; @@ -54,7 +53,7 @@ public async Task Retrieve(string email) { var request = new Request { - Url = $"/api/{client.Version}/suppression-list/{HttpUtility.UrlEncode(email)}", + Url = $"/api/{client.Version}/suppression-list/{WebUtility.UrlEncode(email)}", Method = "GET" }; @@ -113,7 +112,7 @@ public async Task Delete(string email) { var request = new Request { - Url = $"api/{client.Version}/suppression-list/{HttpUtility.UrlEncode(email)}", + Url = $"api/{client.Version}/suppression-list/{WebUtility.UrlEncode(email)}", Method = "DELETE" }; diff --git a/src/SparkPost/Transmission.cs b/src/SparkPost/Transmission.cs index d01dd3db..670e01d1 100644 --- a/src/SparkPost/Transmission.cs +++ b/src/SparkPost/Transmission.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using System.Net.Mail; using SparkPost.Utilities; namespace SparkPost @@ -32,15 +31,5 @@ public Transmission() public int NumGenerated { get; set; } public int NumFailedGeneration { get; set; } public int NumInvalidRecipients { get; set; } - - public static Transmission Parse(MailMessage message) - { - return MailMessageMapping.ToTransmission(message); - } - - public void LoadFrom(MailMessage message) - { - MailMessageMapping.ToTransmission(message, this); - } } } \ No newline at end of file diff --git a/src/SparkPost/Utilities/MailMessageMapping.cs b/src/SparkPost/Utilities/MailMessageMapping.cs deleted file mode 100644 index 5c466d02..00000000 --- a/src/SparkPost/Utilities/MailMessageMapping.cs +++ /dev/null @@ -1,118 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Net.Mail; -using System.Net.Mime; - -namespace SparkPost.Utilities -{ - public static class MailMessageMapping - { - private static readonly Action[] Actions = - { - (t, m) => t.Content.From = ConvertToAddress(m.From), - (t, m) => t.Content.Subject = m.Subject, - (t, m) => AddRecipients(t, m.To, RecipientType.To), - (t, m) => AddRecipients(t, m.CC, RecipientType.CC), - (t, m) => AddRecipients(t, m.Bcc, RecipientType.BCC), - (t, m) => - { - if (m.ReplyToList.Any()) t.Content.ReplyTo = m.ReplyToList.First().Address; - }, - (t, m) => - { - if (m.IsBodyHtml) t.Content.Html = m.Body; - }, - (t, m) => - { - if (!m.IsBodyHtml) t.Content.Text = m.Body; - }, - (t, m) => - { - foreach (var attachment in m.Attachments) - t.Content.Attachments - .Add(File.Create(attachment.ContentStream, attachment.ContentType.Name)); - }, - (t, m) => - { - var text = GetTheAlternativeView(m.AlternateViews, MediaTypeNames.Text.Plain); - if (text != null) - t.Content.Text = text; - }, - (t, m) => - { - var html = GetTheAlternativeView(m.AlternateViews, MediaTypeNames.Text.Html); - if (html != null) - t.Content.Html = html; - } - }; - - public static Transmission ToTransmission(MailMessage message) - { - var transmission = new Transmission(); - ToTransmission(message, transmission); - return transmission; - } - - public static Transmission ToTransmission(MailMessage message, Transmission transmission) - { - foreach (var action in Actions) - action(transmission, message); - return transmission; - } - - private static string GetTheAlternativeView(AlternateViewCollection views, string type) - { - return AlternativeViewsAreAvailable(views) ? GetViewContent(views, type) : null; - } - - private static bool AlternativeViewsAreAvailable(AlternateViewCollection views) - { - var textTypes = new[] {MediaTypeNames.Text.Plain, MediaTypeNames.Text.Html}; - return views.Any() && (views.Count <= 2) && - !views.Select(av => av.ContentType.MediaType).Except(textTypes).Any(); - } - - private static Address ConvertToAddress(MailAddress address) - { - return new Address(address.Address, address.DisplayName); - } - - private static string GetViewContent(AlternateViewCollection views, string type) - { - var view = views.FirstOrDefault(v => v.ContentType.MediaType == type); - return view == null ? null : GetViewContent(view); - } - - private static string GetViewContent(AttachmentBase view) - { - var reader = new StreamReader(view.ContentStream); - - if (view.ContentStream.CanSeek) - view.ContentStream.Position = 0; - - return reader.ReadToEnd(); - } - - private static void AddRecipients(Transmission transmission, MailAddressCollection addresses, RecipientType type) - { - foreach (var recipient in ConvertToRecipients(addresses, type)) - transmission.Recipients.Add(recipient); - } - - private static IEnumerable ConvertToRecipients(MailAddressCollection addresses, RecipientType type) - { - return addresses.Select(a => ConvertToARecipient(type, a)); - } - - private static Recipient ConvertToARecipient(RecipientType type, MailAddress address) - { - return new Recipient - { - Type = type, - Address = ConvertToAddress(address) - }; - } - } -} \ No newline at end of file diff --git a/src/SparkPost/Utilities/MimeTypes.cs b/src/SparkPost/Utilities/MimeTypes.cs new file mode 100644 index 00000000..ffc3c96c --- /dev/null +++ b/src/SparkPost/Utilities/MimeTypes.cs @@ -0,0 +1,1025 @@ +using System; +using System.Collections.Generic; + +namespace SparkPost.Utilities +{ + public static class MimeTypes + { + /// + /// The fallback MIME-type. Defaults to application/octet-stream. + /// + public static string FallbackMimeType { get; set; } + + private static readonly Dictionary TypeMap; + + static MimeTypes() + { + FallbackMimeType = "application/octet-stream"; + + TypeMap = new Dictionary(StringComparer.OrdinalIgnoreCase) + { + { "123", "application/vnd.lotus-1-2-3" }, + { "3dml", "text/vnd.in3d.3dml" }, + { "3ds", "image/x-3ds" }, + { "3g2", "video/3gpp2" }, + { "3gp", "video/3gpp" }, + { "7z", "application/x-7z-compressed" }, + { "aab", "application/x-authorware-bin" }, + { "aac", "audio/x-aac" }, + { "aam", "application/x-authorware-map" }, + { "aas", "application/x-authorware-seg" }, + { "abw", "application/x-abiword" }, + { "ac", "application/pkix-attr-cert" }, + { "acc", "application/vnd.americandynamics.acc" }, + { "ace", "application/x-ace-compressed" }, + { "acu", "application/vnd.acucobol" }, + { "acutc", "application/vnd.acucorp" }, + { "adp", "audio/adpcm" }, + { "aep", "application/vnd.audiograph" }, + { "afm", "application/x-font-type1" }, + { "afp", "application/vnd.ibm.modcap" }, + { "ahead", "application/vnd.ahead.space" }, + { "ai", "application/postscript" }, + { "aif", "audio/x-aiff" }, + { "aifc", "audio/x-aiff" }, + { "aiff", "audio/x-aiff" }, + { "air", "application/vnd.adobe.air-application-installer-package+zip" }, + { "ait", "application/vnd.dvb.ait" }, + { "ami", "application/vnd.amiga.ami" }, + { "apk", "application/vnd.android.package-archive" }, + { "appcache", "text/cache-manifest" }, + { "application", "application/x-ms-application" }, + { "apr", "application/vnd.lotus-approach" }, + { "arc", "application/x-freearc" }, + { "asc", "application/pgp-signature" }, + { "asf", "video/x-ms-asf" }, + { "asm", "text/x-asm" }, + { "aso", "application/vnd.accpac.simply.aso" }, + { "asx", "video/x-ms-asf" }, + { "atc", "application/vnd.acucorp" }, + { "atom", "application/atom+xml" }, + { "atomcat", "application/atomcat+xml" }, + { "atomsvc", "application/atomsvc+xml" }, + { "atx", "application/vnd.antix.game-component" }, + { "au", "audio/basic" }, + { "avi", "video/x-msvideo" }, + { "aw", "application/applixware" }, + { "azf", "application/vnd.airzip.filesecure.azf" }, + { "azs", "application/vnd.airzip.filesecure.azs" }, + { "azw", "application/vnd.amazon.ebook" }, + { "bat", "application/x-msdownload" }, + { "bcpio", "application/x-bcpio" }, + { "bdf", "application/x-font-bdf" }, + { "bdm", "application/vnd.syncml.dm+wbxml" }, + { "bed", "application/vnd.realvnc.bed" }, + { "bh2", "application/vnd.fujitsu.oasysprs" }, + { "bin", "application/octet-stream" }, + { "blb", "application/x-blorb" }, + { "blorb", "application/x-blorb" }, + { "bmi", "application/vnd.bmi" }, + { "bmp", "image/bmp" }, + { "book", "application/vnd.framemaker" }, + { "box", "application/vnd.previewsystems.box" }, + { "boz", "application/x-bzip2" }, + { "bpk", "application/octet-stream" }, + { "btif", "image/prs.btif" }, + { "bz", "application/x-bzip" }, + { "bz2", "application/x-bzip2" }, + { "c", "text/x-c" }, + { "c11amc", "application/vnd.cluetrust.cartomobile-config" }, + { "c11amz", "application/vnd.cluetrust.cartomobile-config-pkg" }, + { "c4d", "application/vnd.clonk.c4group" }, + { "c4f", "application/vnd.clonk.c4group" }, + { "c4g", "application/vnd.clonk.c4group" }, + { "c4p", "application/vnd.clonk.c4group" }, + { "c4u", "application/vnd.clonk.c4group" }, + { "cab", "application/vnd.ms-cab-compressed" }, + { "caf", "audio/x-caf" }, + { "cap", "application/vnd.tcpdump.pcap" }, + { "car", "application/vnd.curl.car" }, + { "cat", "application/vnd.ms-pki.seccat" }, + { "cb7", "application/x-cbr" }, + { "cba", "application/x-cbr" }, + { "cbr", "application/x-cbr" }, + { "cbt", "application/x-cbr" }, + { "cbz", "application/x-cbr" }, + { "cc", "text/x-c" }, + { "cct", "application/x-director" }, + { "ccxml", "application/ccxml+xml" }, + { "cdbcmsg", "application/vnd.contact.cmsg" }, + { "cdf", "application/x-netcdf" }, + { "cdkey", "application/vnd.mediastation.cdkey" }, + { "cdmia", "application/cdmi-capability" }, + { "cdmic", "application/cdmi-container" }, + { "cdmid", "application/cdmi-domain" }, + { "cdmio", "application/cdmi-object" }, + { "cdmiq", "application/cdmi-queue" }, + { "cdx", "chemical/x-cdx" }, + { "cdxml", "application/vnd.chemdraw+xml" }, + { "cdy", "application/vnd.cinderella" }, + { "cer", "application/pkix-cert" }, + { "cfs", "application/x-cfs-compressed" }, + { "cgm", "image/cgm" }, + { "chat", "application/x-chat" }, + { "chm", "application/vnd.ms-htmlhelp" }, + { "chrt", "application/vnd.kde.kchart" }, + { "cif", "chemical/x-cif" }, + { "cii", "application/vnd.anser-web-certificate-issue-initiation" }, + { "cil", "application/vnd.ms-artgalry" }, + { "cla", "application/vnd.claymore" }, + { "class", "application/java-vm" }, + { "clkk", "application/vnd.crick.clicker.keyboard" }, + { "clkp", "application/vnd.crick.clicker.palette" }, + { "clkt", "application/vnd.crick.clicker.template" }, + { "clkw", "application/vnd.crick.clicker.wordbank" }, + { "clkx", "application/vnd.crick.clicker" }, + { "clp", "application/x-msclip" }, + { "cmc", "application/vnd.cosmocaller" }, + { "cmdf", "chemical/x-cmdf" }, + { "cml", "chemical/x-cml" }, + { "cmp", "application/vnd.yellowriver-custom-menu" }, + { "cmx", "image/x-cmx" }, + { "cod", "application/vnd.rim.cod" }, + { "com", "application/x-msdownload" }, + { "conf", "text/plain" }, + { "cpio", "application/x-cpio" }, + { "cpp", "text/x-c" }, + { "cpt", "application/mac-compactpro" }, + { "crd", "application/x-mscardfile" }, + { "crl", "application/pkix-crl" }, + { "crt", "application/x-x509-ca-cert" }, + { "cryptonote", "application/vnd.rig.cryptonote" }, + { "csh", "application/x-csh" }, + { "csml", "chemical/x-csml" }, + { "csp", "application/vnd.commonspace" }, + { "css", "text/css" }, + { "cst", "application/x-director" }, + { "csv", "text/csv" }, + { "cu", "application/cu-seeme" }, + { "curl", "text/vnd.curl" }, + { "cww", "application/prs.cww" }, + { "cxt", "application/x-director" }, + { "cxx", "text/x-c" }, + { "dae", "model/vnd.collada+xml" }, + { "daf", "application/vnd.mobius.daf" }, + { "dart", "application/vnd.dart" }, + { "dataless", "application/vnd.fdsn.seed" }, + { "davmount", "application/davmount+xml" }, + { "dbk", "application/docbook+xml" }, + { "dcr", "application/x-director" }, + { "dcurl", "text/vnd.curl.dcurl" }, + { "dd2", "application/vnd.oma.dd2+xml" }, + { "ddd", "application/vnd.fujixerox.ddd" }, + { "deb", "application/x-debian-package" }, + { "def", "text/plain" }, + { "deploy", "application/octet-stream" }, + { "der", "application/x-x509-ca-cert" }, + { "dfac", "application/vnd.dreamfactory" }, + { "dgc", "application/x-dgc-compressed" }, + { "dic", "text/x-c" }, + { "dir", "application/x-director" }, + { "dis", "application/vnd.mobius.dis" }, + { "dist", "application/octet-stream" }, + { "distz", "application/octet-stream" }, + { "djv", "image/vnd.djvu" }, + { "djvu", "image/vnd.djvu" }, + { "dll", "application/x-msdownload" }, + { "dmg", "application/x-apple-diskimage" }, + { "dmp", "application/vnd.tcpdump.pcap" }, + { "dms", "application/octet-stream" }, + { "dna", "application/vnd.dna" }, + { "doc", "application/msword" }, + { "docm", "application/vnd.ms-word.document.macroenabled.12" }, + { "docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document" }, + { "dot", "application/msword" }, + { "dotm", "application/vnd.ms-word.template.macroenabled.12" }, + { "dotx", "application/vnd.openxmlformats-officedocument.wordprocessingml.template" }, + { "dp", "application/vnd.osgi.dp" }, + { "dpg", "application/vnd.dpgraph" }, + { "dra", "audio/vnd.dra" }, + { "dsc", "text/prs.lines.tag" }, + { "dssc", "application/dssc+der" }, + { "dtb", "application/x-dtbook+xml" }, + { "dtd", "application/xml-dtd" }, + { "dts", "audio/vnd.dts" }, + { "dtshd", "audio/vnd.dts.hd" }, + { "dump", "application/octet-stream" }, + { "dvb", "video/vnd.dvb.file" }, + { "dvi", "application/x-dvi" }, + { "dwf", "model/vnd.dwf" }, + { "dwg", "image/vnd.dwg" }, + { "dxf", "image/vnd.dxf" }, + { "dxp", "application/vnd.spotfire.dxp" }, + { "dxr", "application/x-director" }, + { "ecelp4800", "audio/vnd.nuera.ecelp4800" }, + { "ecelp7470", "audio/vnd.nuera.ecelp7470" }, + { "ecelp9600", "audio/vnd.nuera.ecelp9600" }, + { "ecma", "application/ecmascript" }, + { "edm", "application/vnd.novadigm.edm" }, + { "edx", "application/vnd.novadigm.edx" }, + { "efif", "application/vnd.picsel" }, + { "ei6", "application/vnd.pg.osasli" }, + { "elc", "application/octet-stream" }, + { "emf", "application/x-msmetafile" }, + { "eml", "message/rfc822" }, + { "emma", "application/emma+xml" }, + { "emz", "application/x-msmetafile" }, + { "eol", "audio/vnd.digital-winds" }, + { "eot", "application/vnd.ms-fontobject" }, + { "eps", "application/postscript" }, + { "epub", "application/epub+zip" }, + { "es3", "application/vnd.eszigno3+xml" }, + { "esa", "application/vnd.osgi.subsystem" }, + { "esf", "application/vnd.epson.esf" }, + { "et3", "application/vnd.eszigno3+xml" }, + { "etx", "text/x-setext" }, + { "eva", "application/x-eva" }, + { "evy", "application/x-envoy" }, + { "exe", "application/x-msdownload" }, + { "exi", "application/exi" }, + { "ext", "application/vnd.novadigm.ext" }, + { "ez", "application/andrew-inset" }, + { "ez2", "application/vnd.ezpix-album" }, + { "ez3", "application/vnd.ezpix-package" }, + { "f", "text/x-fortran" }, + { "f4v", "video/x-f4v" }, + { "f77", "text/x-fortran" }, + { "f90", "text/x-fortran" }, + { "fbs", "image/vnd.fastbidsheet" }, + { "fcdt", "application/vnd.adobe.formscentral.fcdt" }, + { "fcs", "application/vnd.isac.fcs" }, + { "fdf", "application/vnd.fdf" }, + { "fe_launch", "application/vnd.denovo.fcselayout-link" }, + { "fg5", "application/vnd.fujitsu.oasysgp" }, + { "fgd", "application/x-director" }, + { "fh", "image/x-freehand" }, + { "fh4", "image/x-freehand" }, + { "fh5", "image/x-freehand" }, + { "fh7", "image/x-freehand" }, + { "fhc", "image/x-freehand" }, + { "fig", "application/x-xfig" }, + { "flac", "audio/x-flac" }, + { "fli", "video/x-fli" }, + { "flo", "application/vnd.micrografx.flo" }, + { "flv", "video/x-flv" }, + { "flw", "application/vnd.kde.kivio" }, + { "flx", "text/vnd.fmi.flexstor" }, + { "fly", "text/vnd.fly" }, + { "fm", "application/vnd.framemaker" }, + { "fnc", "application/vnd.frogans.fnc" }, + { "for", "text/x-fortran" }, + { "fpx", "image/vnd.fpx" }, + { "frame", "application/vnd.framemaker" }, + { "fsc", "application/vnd.fsc.weblaunch" }, + { "fst", "image/vnd.fst" }, + { "ftc", "application/vnd.fluxtime.clip" }, + { "fti", "application/vnd.anser-web-funds-transfer-initiation" }, + { "fvt", "video/vnd.fvt" }, + { "fxp", "application/vnd.adobe.fxp" }, + { "fxpl", "application/vnd.adobe.fxp" }, + { "fzs", "application/vnd.fuzzysheet" }, + { "g2w", "application/vnd.geoplan" }, + { "g3", "image/g3fax" }, + { "g3w", "application/vnd.geospace" }, + { "gac", "application/vnd.groove-account" }, + { "gam", "application/x-tads" }, + { "gbr", "application/rpki-ghostbusters" }, + { "gca", "application/x-gca-compressed" }, + { "gdl", "model/vnd.gdl" }, + { "geo", "application/vnd.dynageo" }, + { "gex", "application/vnd.geometry-explorer" }, + { "ggb", "application/vnd.geogebra.file" }, + { "ggt", "application/vnd.geogebra.tool" }, + { "ghf", "application/vnd.groove-help" }, + { "gif", "image/gif" }, + { "gim", "application/vnd.groove-identity-message" }, + { "gml", "application/gml+xml" }, + { "gmx", "application/vnd.gmx" }, + { "gnumeric", "application/x-gnumeric" }, + { "gph", "application/vnd.flographit" }, + { "gpx", "application/gpx+xml" }, + { "gqf", "application/vnd.grafeq" }, + { "gqs", "application/vnd.grafeq" }, + { "gram", "application/srgs" }, + { "gramps", "application/x-gramps-xml" }, + { "gre", "application/vnd.geometry-explorer" }, + { "grv", "application/vnd.groove-injector" }, + { "grxml", "application/srgs+xml" }, + { "gsf", "application/x-font-ghostscript" }, + { "gtar", "application/x-gtar" }, + { "gtm", "application/vnd.groove-tool-message" }, + { "gtw", "model/vnd.gtw" }, + { "gv", "text/vnd.graphviz" }, + { "gxf", "application/gxf" }, + { "gxt", "application/vnd.geonext" }, + { "h", "text/x-c" }, + { "h261", "video/h261" }, + { "h263", "video/h263" }, + { "h264", "video/h264" }, + { "hal", "application/vnd.hal+xml" }, + { "hbci", "application/vnd.hbci" }, + { "hdf", "application/x-hdf" }, + { "hh", "text/x-c" }, + { "hlp", "application/winhlp" }, + { "hpgl", "application/vnd.hp-hpgl" }, + { "hpid", "application/vnd.hp-hpid" }, + { "hps", "application/vnd.hp-hps" }, + { "hqx", "application/mac-binhex40" }, + { "htke", "application/vnd.kenameaapp" }, + { "htm", "text/html" }, + { "html", "text/html" }, + { "hvd", "application/vnd.yamaha.hv-dic" }, + { "hvp", "application/vnd.yamaha.hv-voice" }, + { "hvs", "application/vnd.yamaha.hv-script" }, + { "i2g", "application/vnd.intergeo" }, + { "icc", "application/vnd.iccprofile" }, + { "ice", "x-conference/x-cooltalk" }, + { "icm", "application/vnd.iccprofile" }, + { "ico", "image/x-icon" }, + { "ics", "text/calendar" }, + { "ief", "image/ief" }, + { "ifb", "text/calendar" }, + { "ifm", "application/vnd.shana.informed.formdata" }, + { "iges", "model/iges" }, + { "igl", "application/vnd.igloader" }, + { "igm", "application/vnd.insors.igm" }, + { "igs", "model/iges" }, + { "igx", "application/vnd.micrografx.igx" }, + { "iif", "application/vnd.shana.informed.interchange" }, + { "imp", "application/vnd.accpac.simply.imp" }, + { "ims", "application/vnd.ms-ims" }, + { "in", "text/plain" }, + { "ink", "application/inkml+xml" }, + { "inkml", "application/inkml+xml" }, + { "install", "application/x-install-instructions" }, + { "iota", "application/vnd.astraea-software.iota" }, + { "ipfix", "application/ipfix" }, + { "ipk", "application/vnd.shana.informed.package" }, + { "irm", "application/vnd.ibm.rights-management" }, + { "irp", "application/vnd.irepository.package+xml" }, + { "iso", "application/x-iso9660-image" }, + { "itp", "application/vnd.shana.informed.formtemplate" }, + { "ivp", "application/vnd.immervision-ivp" }, + { "ivu", "application/vnd.immervision-ivu" }, + { "jad", "text/vnd.sun.j2me.app-descriptor" }, + { "jam", "application/vnd.jam" }, + { "jar", "application/java-archive" }, + { "java", "text/x-java-source" }, + { "jisp", "application/vnd.jisp" }, + { "jlt", "application/vnd.hp-jlyt" }, + { "jnlp", "application/x-java-jnlp-file" }, + { "joda", "application/vnd.joost.joda-archive" }, + { "jpe", "image/jpeg" }, + { "jpeg", "image/jpeg" }, + { "jpg", "image/jpeg" }, + { "jpgm", "video/jpm" }, + { "jpgv", "video/jpeg" }, + { "jpm", "video/jpm" }, + { "js", "application/javascript" }, + { "json", "application/json" }, + { "jsonml", "application/jsonml+json" }, + { "kar", "audio/midi" }, + { "karbon", "application/vnd.kde.karbon" }, + { "kfo", "application/vnd.kde.kformula" }, + { "kia", "application/vnd.kidspiration" }, + { "kml", "application/vnd.google-earth.kml+xml" }, + { "kmz", "application/vnd.google-earth.kmz" }, + { "kne", "application/vnd.kinar" }, + { "knp", "application/vnd.kinar" }, + { "kon", "application/vnd.kde.kontour" }, + { "kpr", "application/vnd.kde.kpresenter" }, + { "kpt", "application/vnd.kde.kpresenter" }, + { "kpxx", "application/vnd.ds-keypoint" }, + { "ksp", "application/vnd.kde.kspread" }, + { "ktr", "application/vnd.kahootz" }, + { "ktx", "image/ktx" }, + { "ktz", "application/vnd.kahootz" }, + { "kwd", "application/vnd.kde.kword" }, + { "kwt", "application/vnd.kde.kword" }, + { "lasxml", "application/vnd.las.las+xml" }, + { "latex", "application/x-latex" }, + { "lbd", "application/vnd.llamagraphics.life-balance.desktop" }, + { "lbe", "application/vnd.llamagraphics.life-balance.exchange+xml" }, + { "les", "application/vnd.hhe.lesson-player" }, + { "lha", "application/x-lzh-compressed" }, + { "link66", "application/vnd.route66.link66+xml" }, + { "list", "text/plain" }, + { "list3820", "application/vnd.ibm.modcap" }, + { "listafp", "application/vnd.ibm.modcap" }, + { "lnk", "application/x-ms-shortcut" }, + { "log", "text/plain" }, + { "lostxml", "application/lost+xml" }, + { "lrf", "application/octet-stream" }, + { "lrm", "application/vnd.ms-lrm" }, + { "ltf", "application/vnd.frogans.ltf" }, + { "lvp", "audio/vnd.lucent.voice" }, + { "lwp", "application/vnd.lotus-wordpro" }, + { "lzh", "application/x-lzh-compressed" }, + { "m13", "application/x-msmediaview" }, + { "m14", "application/x-msmediaview" }, + { "m1v", "video/mpeg" }, + { "m21", "application/mp21" }, + { "m2a", "audio/mpeg" }, + { "m2v", "video/mpeg" }, + { "m3a", "audio/mpeg" }, + { "m3u", "audio/x-mpegurl" }, + { "m3u8", "application/vnd.apple.mpegurl" }, + { "m4u", "video/vnd.mpegurl" }, + { "m4v", "video/x-m4v" }, + { "ma", "application/mathematica" }, + { "mads", "application/mads+xml" }, + { "mag", "application/vnd.ecowin.chart" }, + { "maker", "application/vnd.framemaker" }, + { "man", "text/troff" }, + { "mar", "application/octet-stream" }, + { "mathml", "application/mathml+xml" }, + { "mb", "application/mathematica" }, + { "mbk", "application/vnd.mobius.mbk" }, + { "mbox", "application/mbox" }, + { "mc1", "application/vnd.medcalcdata" }, + { "mcd", "application/vnd.mcd" }, + { "mcurl", "text/vnd.curl.mcurl" }, + { "mdb", "application/x-msaccess" }, + { "mdi", "image/vnd.ms-modi" }, + { "me", "text/troff" }, + { "mesh", "model/mesh" }, + { "meta4", "application/metalink4+xml" }, + { "metalink", "application/metalink+xml" }, + { "mets", "application/mets+xml" }, + { "mfm", "application/vnd.mfmp" }, + { "mft", "application/rpki-manifest" }, + { "mgp", "application/vnd.osgeo.mapguide.package" }, + { "mgz", "application/vnd.proteus.magazine" }, + { "mid", "audio/midi" }, + { "midi", "audio/midi" }, + { "mie", "application/x-mie" }, + { "mif", "application/vnd.mif" }, + { "mime", "message/rfc822" }, + { "mj2", "video/mj2" }, + { "mjp2", "video/mj2" }, + { "mk3d", "video/x-matroska" }, + { "mka", "audio/x-matroska" }, + { "mks", "video/x-matroska" }, + { "mkv", "video/x-matroska" }, + { "mlp", "application/vnd.dolby.mlp" }, + { "mmd", "application/vnd.chipnuts.karaoke-mmd" }, + { "mmf", "application/vnd.smaf" }, + { "mmr", "image/vnd.fujixerox.edmics-mmr" }, + { "mng", "video/x-mng" }, + { "mny", "application/x-msmoney" }, + { "mobi", "application/x-mobipocket-ebook" }, + { "mods", "application/mods+xml" }, + { "mov", "video/quicktime" }, + { "movie", "video/x-sgi-movie" }, + { "mp2", "audio/mpeg" }, + { "mp21", "application/mp21" }, + { "mp2a", "audio/mpeg" }, + { "mp3", "audio/mpeg" }, + { "mp4", "video/mp4" }, + { "mp4a", "audio/mp4" }, + { "mp4s", "application/mp4" }, + { "mp4v", "video/mp4" }, + { "mpc", "application/vnd.mophun.certificate" }, + { "mpe", "video/mpeg" }, + { "mpeg", "video/mpeg" }, + { "mpg", "video/mpeg" }, + { "mpg4", "video/mp4" }, + { "mpga", "audio/mpeg" }, + { "mpkg", "application/vnd.apple.installer+xml" }, + { "mpm", "application/vnd.blueice.multipass" }, + { "mpn", "application/vnd.mophun.application" }, + { "mpp", "application/vnd.ms-project" }, + { "mpt", "application/vnd.ms-project" }, + { "mpy", "application/vnd.ibm.minipay" }, + { "mqy", "application/vnd.mobius.mqy" }, + { "mrc", "application/marc" }, + { "mrcx", "application/marcxml+xml" }, + { "ms", "text/troff" }, + { "mscml", "application/mediaservercontrol+xml" }, + { "mseed", "application/vnd.fdsn.mseed" }, + { "mseq", "application/vnd.mseq" }, + { "msf", "application/vnd.epson.msf" }, + { "msh", "model/mesh" }, + { "msi", "application/x-msdownload" }, + { "msl", "application/vnd.mobius.msl" }, + { "msty", "application/vnd.muvee.style" }, + { "mts", "model/vnd.mts" }, + { "mus", "application/vnd.musician" }, + { "musicxml", "application/vnd.recordare.musicxml+xml" }, + { "mvb", "application/x-msmediaview" }, + { "mwf", "application/vnd.mfer" }, + { "mxf", "application/mxf" }, + { "mxl", "application/vnd.recordare.musicxml" }, + { "mxml", "application/xv+xml" }, + { "mxs", "application/vnd.triscape.mxs" }, + { "mxu", "video/vnd.mpegurl" }, + { "n3", "text/n3" }, + { "nb", "application/mathematica" }, + { "nbp", "application/vnd.wolfram.player" }, + { "nc", "application/x-netcdf" }, + { "ncx", "application/x-dtbncx+xml" }, + { "nfo", "text/x-nfo" }, + { "n-gage", "application/vnd.nokia.n-gage.symbian.install" }, + { "ngdat", "application/vnd.nokia.n-gage.data" }, + { "nitf", "application/vnd.nitf" }, + { "nlu", "application/vnd.neurolanguage.nlu" }, + { "nml", "application/vnd.enliven" }, + { "nnd", "application/vnd.noblenet-directory" }, + { "nns", "application/vnd.noblenet-sealer" }, + { "nnw", "application/vnd.noblenet-web" }, + { "npx", "image/vnd.net-fpx" }, + { "nsc", "application/x-conference" }, + { "nsf", "application/vnd.lotus-notes" }, + { "ntf", "application/vnd.nitf" }, + { "nzb", "application/x-nzb" }, + { "oa2", "application/vnd.fujitsu.oasys2" }, + { "oa3", "application/vnd.fujitsu.oasys3" }, + { "oas", "application/vnd.fujitsu.oasys" }, + { "obd", "application/x-msbinder" }, + { "obj", "application/x-tgif" }, + { "oda", "application/oda" }, + { "odb", "application/vnd.oasis.opendocument.database" }, + { "odc", "application/vnd.oasis.opendocument.chart" }, + { "odf", "application/vnd.oasis.opendocument.formula" }, + { "odft", "application/vnd.oasis.opendocument.formula-template" }, + { "odg", "application/vnd.oasis.opendocument.graphics" }, + { "odi", "application/vnd.oasis.opendocument.image" }, + { "odm", "application/vnd.oasis.opendocument.text-master" }, + { "odp", "application/vnd.oasis.opendocument.presentation" }, + { "ods", "application/vnd.oasis.opendocument.spreadsheet" }, + { "odt", "application/vnd.oasis.opendocument.text" }, + { "oga", "audio/ogg" }, + { "ogg", "audio/ogg" }, + { "ogv", "video/ogg" }, + { "ogx", "application/ogg" }, + { "omdoc", "application/omdoc+xml" }, + { "onepkg", "application/onenote" }, + { "onetmp", "application/onenote" }, + { "onetoc", "application/onenote" }, + { "onetoc2", "application/onenote" }, + { "opf", "application/oebps-package+xml" }, + { "opml", "text/x-opml" }, + { "oprc", "application/vnd.palm" }, + { "org", "application/vnd.lotus-organizer" }, + { "osf", "application/vnd.yamaha.openscoreformat" }, + { "osfpvg", "application/vnd.yamaha.openscoreformat.osfpvg+xml" }, + { "otc", "application/vnd.oasis.opendocument.chart-template" }, + { "otf", "application/x-font-otf" }, + { "otg", "application/vnd.oasis.opendocument.graphics-template" }, + { "oth", "application/vnd.oasis.opendocument.text-web" }, + { "oti", "application/vnd.oasis.opendocument.image-template" }, + { "otp", "application/vnd.oasis.opendocument.presentation-template" }, + { "ots", "application/vnd.oasis.opendocument.spreadsheet-template" }, + { "ott", "application/vnd.oasis.opendocument.text-template" }, + { "oxps", "application/oxps" }, + { "oxt", "application/vnd.openofficeorg.extension" }, + { "p", "text/x-pascal" }, + { "p10", "application/pkcs10" }, + { "p12", "application/x-pkcs12" }, + { "p7b", "application/x-pkcs7-certificates" }, + { "p7c", "application/pkcs7-mime" }, + { "p7m", "application/pkcs7-mime" }, + { "p7r", "application/x-pkcs7-certreqresp" }, + { "p7s", "application/pkcs7-signature" }, + { "p8", "application/pkcs8" }, + { "pas", "text/x-pascal" }, + { "paw", "application/vnd.pawaafile" }, + { "pbd", "application/vnd.powerbuilder6" }, + { "pbm", "image/x-portable-bitmap" }, + { "pcap", "application/vnd.tcpdump.pcap" }, + { "pcf", "application/x-font-pcf" }, + { "pcl", "application/vnd.hp-pcl" }, + { "pclxl", "application/vnd.hp-pclxl" }, + { "pct", "image/x-pict" }, + { "pcurl", "application/vnd.curl.pcurl" }, + { "pcx", "image/x-pcx" }, + { "pdb", "application/vnd.palm" }, + { "pdf", "application/pdf" }, + { "pfa", "application/x-font-type1" }, + { "pfb", "application/x-font-type1" }, + { "pfm", "application/x-font-type1" }, + { "pfr", "application/font-tdpfr" }, + { "pfx", "application/x-pkcs12" }, + { "pgm", "image/x-portable-graymap" }, + { "pgn", "application/x-chess-pgn" }, + { "pgp", "application/pgp-encrypted" }, + { "pic", "image/x-pict" }, + { "pkg", "application/octet-stream" }, + { "pki", "application/pkixcmp" }, + { "pkipath", "application/pkix-pkipath" }, + { "plb", "application/vnd.3gpp.pic-bw-large" }, + { "plc", "application/vnd.mobius.plc" }, + { "plf", "application/vnd.pocketlearn" }, + { "pls", "application/pls+xml" }, + { "pml", "application/vnd.ctc-posml" }, + { "png", "image/png" }, + { "pnm", "image/x-portable-anymap" }, + { "portpkg", "application/vnd.macports.portpkg" }, + { "pot", "application/vnd.ms-powerpoint" }, + { "potm", "application/vnd.ms-powerpoint.template.macroenabled.12" }, + { "potx", "application/vnd.openxmlformats-officedocument.presentationml.template" }, + { "ppam", "application/vnd.ms-powerpoint.addin.macroenabled.12" }, + { "ppd", "application/vnd.cups-ppd" }, + { "ppm", "image/x-portable-pixmap" }, + { "pps", "application/vnd.ms-powerpoint" }, + { "ppsm", "application/vnd.ms-powerpoint.slideshow.macroenabled.12" }, + { "ppsx", "application/vnd.openxmlformats-officedocument.presentationml.slideshow" }, + { "ppt", "application/vnd.ms-powerpoint" }, + { "pptm", "application/vnd.ms-powerpoint.presentation.macroenabled.12" }, + { "pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation" }, + { "pqa", "application/vnd.palm" }, + { "prc", "application/x-mobipocket-ebook" }, + { "pre", "application/vnd.lotus-freelance" }, + { "prf", "application/pics-rules" }, + { "ps", "application/postscript" }, + { "psb", "application/vnd.3gpp.pic-bw-small" }, + { "psd", "image/vnd.adobe.photoshop" }, + { "psf", "application/x-font-linux-psf" }, + { "pskcxml", "application/pskc+xml" }, + { "ptid", "application/vnd.pvi.ptid1" }, + { "pub", "application/x-mspublisher" }, + { "pvb", "application/vnd.3gpp.pic-bw-var" }, + { "pwn", "application/vnd.3m.post-it-notes" }, + { "pya", "audio/vnd.ms-playready.media.pya" }, + { "pyv", "video/vnd.ms-playready.media.pyv" }, + { "qam", "application/vnd.epson.quickanime" }, + { "qbo", "application/vnd.intu.qbo" }, + { "qfx", "application/vnd.intu.qfx" }, + { "qps", "application/vnd.publishare-delta-tree" }, + { "qt", "video/quicktime" }, + { "qwd", "application/vnd.quark.quarkxpress" }, + { "qwt", "application/vnd.quark.quarkxpress" }, + { "qxb", "application/vnd.quark.quarkxpress" }, + { "qxd", "application/vnd.quark.quarkxpress" }, + { "qxl", "application/vnd.quark.quarkxpress" }, + { "qxt", "application/vnd.quark.quarkxpress" }, + { "ra", "audio/x-pn-realaudio" }, + { "ram", "audio/x-pn-realaudio" }, + { "rar", "application/x-rar-compressed" }, + { "ras", "image/x-cmu-raster" }, + { "rcprofile", "application/vnd.ipunplugged.rcprofile" }, + { "rdf", "application/rdf+xml" }, + { "rdz", "application/vnd.data-vision.rdz" }, + { "rep", "application/vnd.businessobjects" }, + { "res", "application/x-dtbresource+xml" }, + { "rgb", "image/x-rgb" }, + { "rif", "application/reginfo+xml" }, + { "rip", "audio/vnd.rip" }, + { "ris", "application/x-research-info-systems" }, + { "rl", "application/resource-lists+xml" }, + { "rlc", "image/vnd.fujixerox.edmics-rlc" }, + { "rld", "application/resource-lists-diff+xml" }, + { "rm", "application/vnd.rn-realmedia" }, + { "rmi", "audio/midi" }, + { "rmp", "audio/x-pn-realaudio-plugin" }, + { "rms", "application/vnd.jcp.javame.midlet-rms" }, + { "rmvb", "application/vnd.rn-realmedia-vbr" }, + { "rnc", "application/relax-ng-compact-syntax" }, + { "roa", "application/rpki-roa" }, + { "roff", "text/troff" }, + { "rp9", "application/vnd.cloanto.rp9" }, + { "rpss", "application/vnd.nokia.radio-presets" }, + { "rpst", "application/vnd.nokia.radio-preset" }, + { "rq", "application/sparql-query" }, + { "rs", "application/rls-services+xml" }, + { "rsd", "application/rsd+xml" }, + { "rss", "application/rss+xml" }, + { "rtf", "application/rtf" }, + { "rtx", "text/richtext" }, + { "s", "text/x-asm" }, + { "s3m", "audio/s3m" }, + { "saf", "application/vnd.yamaha.smaf-audio" }, + { "sbml", "application/sbml+xml" }, + { "sc", "application/vnd.ibm.secure-container" }, + { "scd", "application/x-msschedule" }, + { "scm", "application/vnd.lotus-screencam" }, + { "scq", "application/scvp-cv-request" }, + { "scs", "application/scvp-cv-response" }, + { "scurl", "text/vnd.curl.scurl" }, + { "sda", "application/vnd.stardivision.draw" }, + { "sdc", "application/vnd.stardivision.calc" }, + { "sdd", "application/vnd.stardivision.impress" }, + { "sdkd", "application/vnd.solent.sdkm+xml" }, + { "sdkm", "application/vnd.solent.sdkm+xml" }, + { "sdp", "application/sdp" }, + { "sdw", "application/vnd.stardivision.writer" }, + { "see", "application/vnd.seemail" }, + { "seed", "application/vnd.fdsn.seed" }, + { "sema", "application/vnd.sema" }, + { "semd", "application/vnd.semd" }, + { "semf", "application/vnd.semf" }, + { "ser", "application/java-serialized-object" }, + { "setpay", "application/set-payment-initiation" }, + { "setreg", "application/set-registration-initiation" }, + { "sfd-hdstx", "application/vnd.hydrostatix.sof-data" }, + { "sfs", "application/vnd.spotfire.sfs" }, + { "sfv", "text/x-sfv" }, + { "sgi", "image/sgi" }, + { "sgl", "application/vnd.stardivision.writer-global" }, + { "sgm", "text/sgml" }, + { "sgml", "text/sgml" }, + { "sh", "application/x-sh" }, + { "shar", "application/x-shar" }, + { "shf", "application/shf+xml" }, + { "sid", "image/x-mrsid-image" }, + { "sig", "application/pgp-signature" }, + { "sil", "audio/silk" }, + { "silo", "model/mesh" }, + { "sis", "application/vnd.symbian.install" }, + { "sisx", "application/vnd.symbian.install" }, + { "sit", "application/x-stuffit" }, + { "sitx", "application/x-stuffitx" }, + { "skd", "application/vnd.koan" }, + { "skm", "application/vnd.koan" }, + { "skp", "application/vnd.koan" }, + { "skt", "application/vnd.koan" }, + { "sldm", "application/vnd.ms-powerpoint.slide.macroenabled.12" }, + { "sldx", "application/vnd.openxmlformats-officedocument.presentationml.slide" }, + { "slt", "application/vnd.epson.salt" }, + { "sm", "application/vnd.stepmania.stepchart" }, + { "smf", "application/vnd.stardivision.math" }, + { "smi", "application/smil+xml" }, + { "smil", "application/smil+xml" }, + { "smv", "video/x-smv" }, + { "smzip", "application/vnd.stepmania.package" }, + { "snd", "audio/basic" }, + { "snf", "application/x-font-snf" }, + { "so", "application/octet-stream" }, + { "spc", "application/x-pkcs7-certificates" }, + { "spf", "application/vnd.yamaha.smaf-phrase" }, + { "spl", "application/x-futuresplash" }, + { "spot", "text/vnd.in3d.spot" }, + { "spp", "application/scvp-vp-response" }, + { "spq", "application/scvp-vp-request" }, + { "spx", "audio/ogg" }, + { "sql", "application/x-sql" }, + { "src", "application/x-wais-source" }, + { "srt", "application/x-subrip" }, + { "sru", "application/sru+xml" }, + { "srx", "application/sparql-results+xml" }, + { "ssdl", "application/ssdl+xml" }, + { "sse", "application/vnd.kodak-descriptor" }, + { "ssf", "application/vnd.epson.ssf" }, + { "ssml", "application/ssml+xml" }, + { "st", "application/vnd.sailingtracker.track" }, + { "stc", "application/vnd.sun.xml.calc.template" }, + { "std", "application/vnd.sun.xml.draw.template" }, + { "stf", "application/vnd.wt.stf" }, + { "sti", "application/vnd.sun.xml.impress.template" }, + { "stk", "application/hyperstudio" }, + { "stl", "application/vnd.ms-pki.stl" }, + { "str", "application/vnd.pg.format" }, + { "stw", "application/vnd.sun.xml.writer.template" }, + { "sus", "application/vnd.sus-calendar" }, + { "susp", "application/vnd.sus-calendar" }, + { "sv4cpio", "application/x-sv4cpio" }, + { "sv4crc", "application/x-sv4crc" }, + { "svc", "application/vnd.dvb.service" }, + { "svd", "application/vnd.svd" }, + { "svg", "image/svg+xml" }, + { "svgz", "image/svg+xml" }, + { "swa", "application/x-director" }, + { "swf", "application/x-shockwave-flash" }, + { "swi", "application/vnd.aristanetworks.swi" }, + { "sxc", "application/vnd.sun.xml.calc" }, + { "sxd", "application/vnd.sun.xml.draw" }, + { "sxg", "application/vnd.sun.xml.writer.global" }, + { "sxi", "application/vnd.sun.xml.impress" }, + { "sxm", "application/vnd.sun.xml.math" }, + { "sxw", "application/vnd.sun.xml.writer" }, + { "t", "text/troff" }, + { "t3", "application/x-t3vm-image" }, + { "taglet", "application/vnd.mynfc" }, + { "tao", "application/vnd.tao.intent-module-archive" }, + { "tar", "application/x-tar" }, + { "tcap", "application/vnd.3gpp2.tcap" }, + { "tcl", "application/x-tcl" }, + { "teacher", "application/vnd.smart.teacher" }, + { "tei", "application/tei+xml" }, + { "teicorpus", "application/tei+xml" }, + { "tex", "application/x-tex" }, + { "texi", "application/x-texinfo" }, + { "texinfo", "application/x-texinfo" }, + { "text", "text/plain" }, + { "tfi", "application/thraud+xml" }, + { "tfm", "application/x-tex-tfm" }, + { "tga", "image/x-tga" }, + { "thmx", "application/vnd.ms-officetheme" }, + { "tif", "image/tiff" }, + { "tiff", "image/tiff" }, + { "tmo", "application/vnd.tmobile-livetv" }, + { "torrent", "application/x-bittorrent" }, + { "tpl", "application/vnd.groove-tool-template" }, + { "tpt", "application/vnd.trid.tpt" }, + { "tr", "text/troff" }, + { "tra", "application/vnd.trueapp" }, + { "trm", "application/x-msterminal" }, + { "tsd", "application/timestamped-data" }, + { "tsv", "text/tab-separated-values" }, + { "ttc", "application/x-font-ttf" }, + { "ttf", "application/x-font-ttf" }, + { "ttl", "text/turtle" }, + { "twd", "application/vnd.simtech-mindmapper" }, + { "twds", "application/vnd.simtech-mindmapper" }, + { "txd", "application/vnd.genomatix.tuxedo" }, + { "txf", "application/vnd.mobius.txf" }, + { "txt", "text/plain" }, + { "u32", "application/x-authorware-bin" }, + { "udeb", "application/x-debian-package" }, + { "ufd", "application/vnd.ufdl" }, + { "ufdl", "application/vnd.ufdl" }, + { "ulx", "application/x-glulx" }, + { "umj", "application/vnd.umajin" }, + { "unityweb", "application/vnd.unity" }, + { "uoml", "application/vnd.uoml+xml" }, + { "uri", "text/uri-list" }, + { "uris", "text/uri-list" }, + { "urls", "text/uri-list" }, + { "ustar", "application/x-ustar" }, + { "utz", "application/vnd.uiq.theme" }, + { "uu", "text/x-uuencode" }, + { "uva", "audio/vnd.dece.audio" }, + { "uvd", "application/vnd.dece.data" }, + { "uvf", "application/vnd.dece.data" }, + { "uvg", "image/vnd.dece.graphic" }, + { "uvh", "video/vnd.dece.hd" }, + { "uvi", "image/vnd.dece.graphic" }, + { "uvm", "video/vnd.dece.mobile" }, + { "uvp", "video/vnd.dece.pd" }, + { "uvs", "video/vnd.dece.sd" }, + { "uvt", "application/vnd.dece.ttml+xml" }, + { "uvu", "video/vnd.uvvu.mp4" }, + { "uvv", "video/vnd.dece.video" }, + { "uvva", "audio/vnd.dece.audio" }, + { "uvvd", "application/vnd.dece.data" }, + { "uvvf", "application/vnd.dece.data" }, + { "uvvg", "image/vnd.dece.graphic" }, + { "uvvh", "video/vnd.dece.hd" }, + { "uvvi", "image/vnd.dece.graphic" }, + { "uvvm", "video/vnd.dece.mobile" }, + { "uvvp", "video/vnd.dece.pd" }, + { "uvvs", "video/vnd.dece.sd" }, + { "uvvt", "application/vnd.dece.ttml+xml" }, + { "uvvu", "video/vnd.uvvu.mp4" }, + { "uvvv", "video/vnd.dece.video" }, + { "uvvx", "application/vnd.dece.unspecified" }, + { "uvvz", "application/vnd.dece.zip" }, + { "uvx", "application/vnd.dece.unspecified" }, + { "uvz", "application/vnd.dece.zip" }, + { "vcard", "text/vcard" }, + { "vcd", "application/x-cdlink" }, + { "vcf", "text/x-vcard" }, + { "vcg", "application/vnd.groove-vcard" }, + { "vcs", "text/x-vcalendar" }, + { "vcx", "application/vnd.vcx" }, + { "vis", "application/vnd.visionary" }, + { "viv", "video/vnd.vivo" }, + { "vob", "video/x-ms-vob" }, + { "vor", "application/vnd.stardivision.writer" }, + { "vox", "application/x-authorware-bin" }, + { "vrml", "model/vrml" }, + { "vsd", "application/vnd.visio" }, + { "vsf", "application/vnd.vsf" }, + { "vss", "application/vnd.visio" }, + { "vst", "application/vnd.visio" }, + { "vsw", "application/vnd.visio" }, + { "vtu", "model/vnd.vtu" }, + { "vxml", "application/voicexml+xml" }, + { "w3d", "application/x-director" }, + { "wad", "application/x-doom" }, + { "wav", "audio/x-wav" }, + { "wax", "audio/x-ms-wax" }, + { "wbmp", "image/vnd.wap.wbmp" }, + { "wbs", "application/vnd.criticaltools.wbs+xml" }, + { "wbxml", "application/vnd.wap.wbxml" }, + { "wcm", "application/vnd.ms-works" }, + { "wdb", "application/vnd.ms-works" }, + { "wdp", "image/vnd.ms-photo" }, + { "weba", "audio/webm" }, + { "webm", "video/webm" }, + { "webp", "image/webp" }, + { "wg", "application/vnd.pmi.widget" }, + { "wgt", "application/widget" }, + { "wks", "application/vnd.ms-works" }, + { "wm", "video/x-ms-wm" }, + { "wma", "audio/x-ms-wma" }, + { "wmd", "application/x-ms-wmd" }, + { "wmf", "application/x-msmetafile" }, + { "wml", "text/vnd.wap.wml" }, + { "wmlc", "application/vnd.wap.wmlc" }, + { "wmls", "text/vnd.wap.wmlscript" }, + { "wmlsc", "application/vnd.wap.wmlscriptc" }, + { "wmv", "video/x-ms-wmv" }, + { "wmx", "video/x-ms-wmx" }, + { "woff", "application/font-woff" }, + { "wpd", "application/vnd.wordperfect" }, + { "wpl", "application/vnd.ms-wpl" }, + { "wps", "application/vnd.ms-works" }, + { "wqd", "application/vnd.wqd" }, + { "wri", "application/x-mswrite" }, + { "wrl", "model/vrml" }, + { "wsdl", "application/wsdl+xml" }, + { "wspolicy", "application/wspolicy+xml" }, + { "wtb", "application/vnd.webturbo" }, + { "wvx", "video/x-ms-wvx" }, + { "x32", "application/x-authorware-bin" }, + { "x3d", "model/x3d+xml" }, + { "x3db", "model/x3d+binary" }, + { "x3dbz", "model/x3d+binary" }, + { "x3dv", "model/x3d+vrml" }, + { "x3dvz", "model/x3d+vrml" }, + { "x3dz", "model/x3d+xml" }, + { "xaml", "application/xaml+xml" }, + { "xap", "application/x-silverlight-app" }, + { "xar", "application/vnd.xara" }, + { "xbap", "application/x-ms-xbap" }, + { "xbd", "application/vnd.fujixerox.docuworks.binder" }, + { "xbm", "image/x-xbitmap" }, + { "xdf", "application/xcap-diff+xml" }, + { "xdm", "application/vnd.syncml.dm+xml" }, + { "xdp", "application/vnd.adobe.xdp+xml" }, + { "xdssc", "application/dssc+xml" }, + { "xdw", "application/vnd.fujixerox.docuworks" }, + { "xenc", "application/xenc+xml" }, + { "xer", "application/patch-ops-error+xml" }, + { "xfdf", "application/vnd.adobe.xfdf" }, + { "xfdl", "application/vnd.xfdl" }, + { "xht", "application/xhtml+xml" }, + { "xhtml", "application/xhtml+xml" }, + { "xhvml", "application/xv+xml" }, + { "xif", "image/vnd.xiff" }, + { "xla", "application/vnd.ms-excel" }, + { "xlam", "application/vnd.ms-excel.addin.macroenabled.12" }, + { "xlc", "application/vnd.ms-excel" }, + { "xlf", "application/x-xliff+xml" }, + { "xlm", "application/vnd.ms-excel" }, + { "xls", "application/vnd.ms-excel" }, + { "xlsb", "application/vnd.ms-excel.sheet.binary.macroenabled.12" }, + { "xlsm", "application/vnd.ms-excel.sheet.macroenabled.12" }, + { "xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" }, + { "xlt", "application/vnd.ms-excel" }, + { "xltm", "application/vnd.ms-excel.template.macroenabled.12" }, + { "xltx", "application/vnd.openxmlformats-officedocument.spreadsheetml.template" }, + { "xlw", "application/vnd.ms-excel" }, + { "xm", "audio/xm" }, + { "xml", "application/xml" }, + { "xo", "application/vnd.olpc-sugar" }, + { "xop", "application/xop+xml" }, + { "xpi", "application/x-xpinstall" }, + { "xpl", "application/xproc+xml" }, + { "xpm", "image/x-xpixmap" }, + { "xpr", "application/vnd.is-xpr" }, + { "xps", "application/vnd.ms-xpsdocument" }, + { "xpw", "application/vnd.intercon.formnet" }, + { "xpx", "application/vnd.intercon.formnet" }, + { "xsl", "application/xml" }, + { "xslt", "application/xslt+xml" }, + { "xsm", "application/vnd.syncml+xml" }, + { "xspf", "application/xspf+xml" }, + { "xul", "application/vnd.mozilla.xul+xml" }, + { "xvm", "application/xv+xml" }, + { "xvml", "application/xv+xml" }, + { "xwd", "image/x-xwindowdump" }, + { "xyz", "chemical/x-xyz" }, + { "xz", "application/x-xz" }, + { "yang", "application/yang" }, + { "yin", "application/yin+xml" }, + { "z1", "application/x-zmachine" }, + { "z2", "application/x-zmachine" }, + { "z3", "application/x-zmachine" }, + { "z4", "application/x-zmachine" }, + { "z5", "application/x-zmachine" }, + { "z6", "application/x-zmachine" }, + { "z7", "application/x-zmachine" }, + { "z8", "application/x-zmachine" }, + { "zaz", "application/vnd.zzazz.deck+xml" }, + { "zip", "application/zip" }, + { "zir", "application/vnd.zul" }, + { "zirz", "application/vnd.zul" }, + { "zmm", "application/vnd.handheld-entertainment+xml" }, + }; + } + + /// + /// Gets the MIME-type for the given file name, + /// or if a mapping doesn't exist. + /// + /// The name of the file. + /// The MIME-type for the given file name. + public static string GetMimeType(string fileName) + { + var dotIndex = fileName.LastIndexOf('.'); + + if (dotIndex != -1 && fileName.Length > dotIndex + 1) + { + string result; + if (TypeMap.TryGetValue(fileName.Substring(dotIndex + 1), out result)) + { + return result; + } + } + + return FallbackMimeType; + } + } +} \ No newline at end of file diff --git a/src/SparkPost/ValueMappers/AnonymousValueMapper.cs b/src/SparkPost/ValueMappers/AnonymousValueMapper.cs index a89cf3ea..de8e6ac0 100644 --- a/src/SparkPost/ValueMappers/AnonymousValueMapper.cs +++ b/src/SparkPost/ValueMappers/AnonymousValueMapper.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Reflection; namespace SparkPost.ValueMappers { @@ -20,7 +21,7 @@ public bool CanMap(Type propertyType, object value) public object Map(Type propertyType, object value) { var newValue = new Dictionary(); - foreach (var property in value.GetType().GetProperties()) + foreach (var property in value.GetType().GetTypeInfo().GetProperties()) newValue[property.Name] = property.GetValue(value); return dataMapper.GetTheValue(newValue.GetType(), newValue); } diff --git a/src/SparkPost/ValueMappers/EnumValueMapper.cs b/src/SparkPost/ValueMappers/EnumValueMapper.cs index 072d757d..ab79b0bd 100644 --- a/src/SparkPost/ValueMappers/EnumValueMapper.cs +++ b/src/SparkPost/ValueMappers/EnumValueMapper.cs @@ -1,4 +1,5 @@ using System; +using System.Reflection; namespace SparkPost.ValueMappers { @@ -6,7 +7,7 @@ public class EnumValueMapper : IValueMapper { public bool CanMap(Type propertyType, object value) { - return propertyType.IsEnum; + return propertyType.GetTypeInfo().IsEnum; } public object Map(Type propertyType, object value) diff --git a/src/SparkPost/ValueMappers/MapASetOfItemsUsingToDictionary.cs b/src/SparkPost/ValueMappers/MapASetOfItemsUsingToDictionary.cs index daab9d03..54535b0e 100644 --- a/src/SparkPost/ValueMappers/MapASetOfItemsUsingToDictionary.cs +++ b/src/SparkPost/ValueMappers/MapASetOfItemsUsingToDictionary.cs @@ -21,19 +21,18 @@ public MapASetOfItemsUsingToDictionary(IDataMapper dataMapper) public bool CanMap(Type propertyType, object value) { return value != null && propertyType.Name.EndsWith("List`1") && - propertyType.GetGenericArguments().Count() == 1 && - converters.ContainsKey(propertyType.GetGenericArguments().First()); + propertyType.GetTypeInfo().GetGenericArguments().Count() == 1 && + converters.ContainsKey(propertyType.GetTypeInfo().GetGenericArguments().First()); } public object Map(Type propertyType, object value) { - var converter = converters[propertyType.GetGenericArguments().First()]; + var converter = converters[propertyType.GetTypeInfo().GetGenericArguments().First()]; var list = (value as IEnumerable).ToList(); if (list.Any()) - value = list.Select(x => converter.Invoke(dataMapper, BindingFlags.Default, null, - new[] {x}, CultureInfo.CurrentCulture)).ToList(); + value = list.Select(x => converter.Invoke(dataMapper, new[] {x})).ToList(); else value = null; diff --git a/src/SparkPost/ValueMappers/MapASingleItemUsingToDictionary.cs b/src/SparkPost/ValueMappers/MapASingleItemUsingToDictionary.cs index d5f0a5c1..b27ad123 100644 --- a/src/SparkPost/ValueMappers/MapASingleItemUsingToDictionary.cs +++ b/src/SparkPost/ValueMappers/MapASingleItemUsingToDictionary.cs @@ -25,8 +25,7 @@ public bool CanMap(Type propertyType, object value) public object Map(Type propertyType, object value) { - return converters[propertyType].Invoke(dataMapper, BindingFlags.Default, null, - new[] {value}, CultureInfo.CurrentCulture); + return converters[propertyType].Invoke(dataMapper, new[] {value}); } } } \ No newline at end of file