Skip to content

Commit 9105837

Browse files
committed
Merge remote-tracking branch 'upstream/master'
Conflicts: RestSharp/Http.Async.cs
2 parents daa71ce + 821153d commit 9105837

File tree

107 files changed

+8059
-3773
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+8059
-3773
lines changed

.gitattributes

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto
3+
4+
# Custom for Visual Studio
5+
*.cs diff=csharp
6+
*.sln merge=union
7+
*.csproj merge=union
8+
*.vbproj merge=union
9+
*.fsproj merge=union
10+
*.dbproj merge=union
11+
12+
# Standard to msysgit
13+
*.doc diff=astextplain
14+
*.DOC diff=astextplain
15+
*.docx diff=astextplain
16+
*.DOCX diff=astextplain
17+
*.dot diff=astextplain
18+
*.DOT diff=astextplain
19+
*.pdf diff=astextplain
20+
*.PDF diff=astextplain
21+
*.rtf diff=astextplain
22+
*.RTF diff=astextplain

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,4 @@ Download/
3636
#Ignore files from MonoDevelop
3737
*.pidb
3838
*.userprefs
39+
restsharp-computed.nuspec

.nuget/RestSharp.Build.dll

7 KB
Binary file not shown.

README.markdown

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
### Features
88

9-
* Supports .NET 3.5+, Silverlight 4, Windows Phone 7, Mono, MonoTouch, Mono for Android
9+
* Supports .NET 3.5+, Silverlight 4, Windows Phone 7, Mono, MonoTouch, Mono for Android, Compact Framework 3.5
1010
* Easy installation using [NuGet](http://nuget.org/packages/RestSharp) for most .NET flavors
1111
* Automatic XML and JSON deserialization
1212
* Supports custom serialization and deserialization via ISerializer and IDeserializer
@@ -25,7 +25,7 @@ var client = new RestClient("http://example.com");
2525
2626
var request = new RestRequest("resource/{id}", Method.POST);
2727
request.AddParameter("name", "value"); // adds to POST or URL querystring based on Method
28-
request.AddUrlSegment("id", 123); // replaces matching token in request.Resource
28+
request.AddUrlSegment("id", "123"); // replaces matching token in request.Resource
2929
3030
// add parameters for all properties on an object
3131
request.AddObject(object);
@@ -40,12 +40,12 @@ request.AddHeader("header", "value");
4040
request.AddFile(path);
4141

4242
// execute the request
43-
RestResponse response = client.Execute(request);
43+
IRestResponse response = client.Execute(request);
4444
var content = response.Content; // raw content as string
4545
4646
// or automatically deserialize result
4747
// return content type is sniffed but can be explicitly set via RestClient.AddHandler();
48-
RestResponse<Person> response2 = client.Execute<Person>(request);
48+
IRestResponse<Person> response2 = client.Execute<Person>(request);
4949
var name = response2.Data.Name;
5050

5151
// or download and save file to disk
@@ -67,4 +67,4 @@ asyncHandle.Abort();
6767

6868
[1]: http://restsharp.org
6969
[2]: http://twitter.com/RestSharp
70-
[3]: http://groups.google.com/group/RestSharp
70+
[3]: http://groups.google.com/group/RestSharp

RestSharp.Build/NuSpecUpdateTask.cs

+122
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using Microsoft.Build.Utilities;
6+
using System.Reflection;
7+
using System.Xml.Linq;
8+
using System.IO;
9+
10+
namespace RestSharp.Build
11+
{
12+
public class NuSpecUpdateTask : Task
13+
{
14+
private Assembly _assembly;
15+
16+
public string Id { get; private set; }
17+
18+
public string Authors { get; private set; }
19+
20+
public string Description { get; private set; }
21+
22+
public string Version { get; private set; }
23+
24+
public string SpecFile { get; set; }
25+
26+
public string SourceAssemblyFile { get; set; }
27+
28+
public NuSpecUpdateTask()
29+
: this(null)
30+
{
31+
}
32+
33+
public NuSpecUpdateTask(Assembly assembly)
34+
{
35+
this._assembly = assembly;
36+
}
37+
38+
public override bool Execute()
39+
{
40+
if (string.IsNullOrEmpty(this.SpecFile)) return false;
41+
42+
var path = Path.GetFullPath(this.SourceAssemblyFile);
43+
this._assembly = this._assembly ?? Assembly.LoadFile(path);
44+
45+
var name = this._assembly.GetName();
46+
47+
this.Id = name.Name;
48+
this.Authors = this.GetAuthors(this._assembly);
49+
this.Description = this.GetDescription(this._assembly);
50+
this.Version = this.GetVersion(this._assembly);
51+
52+
this.GenerateComputedSpecFile();
53+
54+
return true;
55+
}
56+
57+
private void GenerateComputedSpecFile()
58+
{
59+
var doc = XDocument.Load(this.SpecFile);
60+
61+
var metaNode = doc.Descendants("metadata").First();
62+
63+
this.ReplaceToken(metaNode, "id", this.Id);
64+
this.ReplaceToken(metaNode, "authors", this.Authors);
65+
this.ReplaceToken(metaNode, "owners", this.Authors);
66+
this.ReplaceToken(metaNode, "description", this.Description);
67+
this.ReplaceToken(metaNode, "version", this.Version);
68+
69+
doc.Save(this.SpecFile.Replace(".nuspec", "-computed.nuspec"));
70+
}
71+
72+
private void ReplaceToken(XElement metaNode, XName name, string value)
73+
{
74+
var node = metaNode.Element(name);
75+
var token = string.Format("${0}$", name.ToString().TrimEnd('s'));
76+
77+
if (name.ToString().Equals("owners"))
78+
{
79+
token = "$author$";
80+
}
81+
82+
if (node.Value.Equals(token, StringComparison.OrdinalIgnoreCase))
83+
{
84+
node.SetValue(value);
85+
}
86+
}
87+
88+
private string GetDescription(Assembly asm)
89+
{
90+
return this.GetAttribute<AssemblyDescriptionAttribute>(asm).Description;
91+
}
92+
93+
private string GetAuthors(Assembly asm)
94+
{
95+
return this.GetAttribute<AssemblyCompanyAttribute>(asm).Company;
96+
}
97+
98+
private string GetVersion(Assembly asm)
99+
{
100+
var version = asm.GetName().Version.ToString();
101+
var attr = this.GetAttribute<AssemblyInformationalVersionAttribute>(asm);
102+
103+
if (attr != null)
104+
{
105+
version = attr.InformationalVersion;
106+
}
107+
108+
return version;
109+
}
110+
111+
private TAttr GetAttribute<TAttr>(Assembly asm) where TAttr : Attribute
112+
{
113+
var attrs = asm.GetCustomAttributes(typeof(TAttr), false);
114+
if (attrs.Length > 0)
115+
{
116+
return attrs[0] as TAttr;
117+
}
118+
119+
return null;
120+
}
121+
}
122+
}
+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("RestSharp.Build")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("RestSharp.Build")]
13+
[assembly: AssemblyCopyright("Copyright © 2013")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("1cf9b3e7-67bb-4dca-9094-5f8c94ef9587")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]
+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<ProductVersion>8.0.30703</ProductVersion>
7+
<SchemaVersion>2.0</SchemaVersion>
8+
<ProjectGuid>{CCC30138-3D68-44D8-AF1A-D22F769EE8DC}</ProjectGuid>
9+
<OutputType>Library</OutputType>
10+
<AppDesignerFolder>Properties</AppDesignerFolder>
11+
<RootNamespace>RestSharp.Build</RootNamespace>
12+
<AssemblyName>RestSharp.Build</AssemblyName>
13+
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
14+
<FileAlignment>512</FileAlignment>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<DebugSymbols>true</DebugSymbols>
18+
<DebugType>full</DebugType>
19+
<Optimize>false</Optimize>
20+
<OutputPath>bin\Debug\</OutputPath>
21+
<DefineConstants>DEBUG;TRACE</DefineConstants>
22+
<ErrorReport>prompt</ErrorReport>
23+
<WarningLevel>4</WarningLevel>
24+
</PropertyGroup>
25+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26+
<DebugType>pdbonly</DebugType>
27+
<Optimize>true</Optimize>
28+
<OutputPath>bin\Release\</OutputPath>
29+
<DefineConstants>TRACE</DefineConstants>
30+
<ErrorReport>prompt</ErrorReport>
31+
<WarningLevel>4</WarningLevel>
32+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
33+
</PropertyGroup>
34+
<ItemGroup>
35+
<Reference Include="Microsoft.Build.Framework" />
36+
<Reference Include="Microsoft.Build.Utilities.v3.5" />
37+
<Reference Include="System" />
38+
<Reference Include="System.Core" />
39+
<Reference Include="System.Xml.Linq" />
40+
<Reference Include="System.Data.DataSetExtensions" />
41+
<Reference Include="System.Data" />
42+
<Reference Include="System.Xml" />
43+
</ItemGroup>
44+
<ItemGroup>
45+
<Compile Include="NuSpecUpdateTask.cs" />
46+
<Compile Include="Properties\AssemblyInfo.cs" />
47+
</ItemGroup>
48+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
49+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
50+
Other similar extension points exist, see Microsoft.Common.targets.
51+
<Target Name="BeforeBuild">
52+
</Target>
53+
<Target Name="AfterBuild">
54+
</Target>
55+
-->
56+
</Project>

RestSharp.Compact.sln

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 10.00
3+
# Visual Studio 2008
4+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RestSharp.Compact", "RestSharp\RestSharp.Compact.csproj", "{A29E330B-F854-4287-BEB2-C4CBE9D9C637}"
5+
EndProject
6+
Global
7+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
8+
Debug|Any CPU = Debug|Any CPU
9+
Release|Any CPU = Release|Any CPU
10+
EndGlobalSection
11+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
12+
{A29E330B-F854-4287-BEB2-C4CBE9D9C637}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
13+
{A29E330B-F854-4287-BEB2-C4CBE9D9C637}.Debug|Any CPU.Build.0 = Debug|Any CPU
14+
{A29E330B-F854-4287-BEB2-C4CBE9D9C637}.Release|Any CPU.ActiveCfg = Release|Any CPU
15+
{A29E330B-F854-4287-BEB2-C4CBE9D9C637}.Release|Any CPU.Build.0 = Release|Any CPU
16+
EndGlobalSection
17+
GlobalSection(SolutionProperties) = preSolution
18+
HideSolutionNode = FALSE
19+
EndGlobalSection
20+
EndGlobal

0 commit comments

Comments
 (0)