Skip to content

Commit ae5a0a9

Browse files
committed
support NET2.0,NET3.5,NET4.0
1 parent 27a9d99 commit ae5a0a9

25 files changed

+440
-410
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
2014-01-06 #issue[40](https://github.com/qiniu/csharp-sdk/pull/40)
66

77
- 添加pfop请求(DO)及状态查询接口(QueryPfopStatus)
8+
- 添加NET2.0、NET3.5、NET4.0支持
89

910
### v6.0.2
1011

Docs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ title: C# SDK 使用指南
55

66
# C# SDK 使用指南
77

8-
此 C# SDK 适用于.net framework>4.0版本,基于 [七牛云存储官方API](http://docs.qiniu.com/) 构建。使用此 SDK 构建您的网络应用程序,能让您以非常便捷地方式将数据安全地存储到七牛云存储上。无论您的网络应用是一个网站程序,还是包括从云端(服务端程序)到终端(手持设备应用)的架构的服务或应用,通过七牛云存储及其 SDK,都能让您应用程序的终端用户高速上传和下载,同时也让您的服务端更加轻盈。
8+
此 C# SDK 适用于.net framework>2.0版本,基于 [七牛云存储官方API](http://docs.qiniu.com/) 构建。使用此 SDK 构建您的网络应用程序,能让您以非常便捷地方式将数据安全地存储到七牛云存储上。无论您的网络应用是一个网站程序,还是包括从云端(服务端程序)到终端(手持设备应用)的架构的服务或应用,通过七牛云存储及其 SDK,都能让您应用程序的终端用户高速上传和下载,同时也让您的服务端更加轻盈。
99

1010
- [安装](#install)
1111
- [初始化](#setup)

Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ test:
77
#mono --debug /Library/Frameworks/Mono.framework/Versions/3.2.0/lib/mono/4.5/nunit-console.exe bin/Qiniu.Test.dll
88

99
#for Linux
10-
#3.5
11-
xbuild csharp-sdk.3.5.sln;
12-
cp Qiniu/bin/Debug/3.5/Qiniu.3.5.dll bin/
13-
cp Qiniu.Test/bin/Debug/3.5/Qiniu.Test.dll bin/Qiniu.3.5.Test.dll
14-
nunit-console bin/Qiniu.3.5.Test.dll
10+
#2.0||3.5
11+
xbuild csharp-sdk.2.0.sln;
12+
cp Qiniu/bin/Debug/2.0/Qiniu.2.0.dll bin/
13+
cp Qiniu.Test/bin/Debug/2.0/Qiniu.Test.dll bin/Qiniu.2.0.Test.dll
14+
nunit-console bin/Qiniu.2.0.Test.dll
1515

1616
#4.0
1717
xbuild csharp-sdk.4.0.sln;

Qiniu.Test/Auth/PutPolicy.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class GetPolicyTest:QiniuTestBase
2222
public void MakeRequestTest()
2323
{
2424
string actual;
25-
FileOpUrl = "http://icattlecoder-private.qiniudn.com/img.jpg?download/avialkjdf" + "橛苛要工苛".ToUrlEncode() ;
25+
FileOpUrl = "http://icattlecoder-private.qiniudn.com/img.jpg?download/avialkjdf" + StringEx.ToUrlEncode("橛苛要工苛") ;
2626

2727
actual = GetPolicy.MakeRequest(FileOpUrl);
2828
//System.Diagnostics.Process.Start(actual);

Qiniu.Test/IO/IOClientTest.cs

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -119,30 +119,32 @@ public void PutFileWithoutKeyTest()
119119
//target.PutFile("error", "error", "error", null);
120120
Assert.IsTrue (ret.OK, "PutFileTest Failure");
121121

122-
}
123-
[Test]
124-
public void PutTest()
125-
{
126-
IOClient target = new IOClient();
127-
string key = NewKey;
128-
PrintLn(key);
129-
PutExtra extra = new PutExtra(); // TODO: 初始化为适当的值
130-
extra.MimeType = "text/plain";
131-
extra.Crc32 = 123;
132-
extra.CheckCrc = CheckCrcType.CHECK;
133-
extra.Params = new System.Collections.Generic.Dictionary<string, string>();
134-
PutPolicy put = new PutPolicy(Bucket);
135-
target.PutFinished += new EventHandler<PutRet> ((o,e) => {
136-
if (e.OK) {
137-
RSHelper.RSDel (Bucket, key);
138-
}
139-
});
140-
string token = put.Token ();
141-
PutRet ret = target.Put(put.Token(), key, "Hello, Qiniu Cloud!".ToStream(), extra);
142-
143-
Assert.IsTrue(ret.OK, "PutFileTest Failure");
144-
145-
}
122+
}
123+
[Test]
124+
public void PutTest()
125+
{
126+
IOClient target = new IOClient();
127+
string key = NewKey;
128+
PrintLn(key);
129+
PutExtra extra = new PutExtra(); // TODO: 初始化为适当的值
130+
extra.MimeType = "text/plain";
131+
extra.Crc32 = 123;
132+
extra.CheckCrc = CheckCrcType.CHECK;
133+
extra.Params = new System.Collections.Generic.Dictionary<string, string>();
134+
PutPolicy put = new PutPolicy(Bucket);
135+
target.PutFinished += new EventHandler<PutRet>((o, e) =>
136+
{
137+
if (e.OK)
138+
{
139+
RSHelper.RSDel(Bucket, key);
140+
}
141+
});
142+
string token = put.Token();
143+
PutRet ret = target.Put(put.Token(), key, StreamEx.ToStream("Hello, Qiniu Cloud!"), extra);
144+
145+
Assert.IsTrue(ret.OK, "PutFileTest Failure");
146+
147+
}
146148
[Test]
147149
public void PutWithoutKeyTest()
148150
{

Qiniu.Test/Qiniu.3.5.Test.csproj renamed to Qiniu.Test/Qiniu.2.0.Test.csproj

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,23 @@
99
<OutputType>Library</OutputType>
1010
<RootNamespace>Qiniu.Test</RootNamespace>
1111
<AssemblyName>Qiniu.Test</AssemblyName>
12-
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
12+
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
13+
<TargetFrameworkProfile />
1314
</PropertyGroup>
1415
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1516
<DebugSymbols>true</DebugSymbols>
1617
<DebugType>full</DebugType>
1718
<Optimize>false</Optimize>
18-
<OutputPath>bin\Debug\3.5\</OutputPath>
19-
<DefineConstants>DEBUG;</DefineConstants>
19+
<OutputPath>bin\Debug\2.0\</OutputPath>
20+
<DefineConstants>DEBUG;NET20</DefineConstants>
2021
<ErrorReport>prompt</ErrorReport>
2122
<WarningLevel>4</WarningLevel>
2223
<ConsolePause>false</ConsolePause>
2324
</PropertyGroup>
2425
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
2526
<DebugType>full</DebugType>
2627
<Optimize>true</Optimize>
27-
<OutputPath>bin\Release\3.5\</OutputPath>
28+
<OutputPath>bin\Release\4.0\</OutputPath>
2829
<ErrorReport>prompt</ErrorReport>
2930
<WarningLevel>4</WarningLevel>
3031
<ConsolePause>false</ConsolePause>
@@ -55,10 +56,9 @@
5556
</ItemGroup>
5657
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
5758
<ItemGroup>
58-
<ProjectReference Include="..\Qiniu\Qiniu.3.5.csproj">
59+
<ProjectReference Include="..\Qiniu\Qiniu.2.0.csproj">
5960
<Project>{AD4EA9D1-11C2-4BF6-8A06-72A966BC1B80}</Project>
60-
<Name>Qiniu.3.5</Name>
61+
<Name>Qiniu.2.0</Name>
6162
</ProjectReference>
6263
</ItemGroup>
63-
<ItemGroup />
64-
</Project>
64+
</Project>

Qiniu.Test/TestHelper/RSHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public static List<string> RSPut(string bucket,int num)
3131
List<string> newKeys=new List<string>();
3232
for (int i=0; i<num; i++) {
3333
key = "csharp" + Guid.NewGuid ().ToString ();
34-
PutRet ret = target.Put (put.Token (), key, "Hello, Qiniu Cloud!".ToStream (), extra);
34+
PutRet ret = target.Put (put.Token (), key,StreamEx.ToStream("Hello, Qiniu Cloud!"), extra);
3535
if (ret.OK) {
3636
newKeys.Add (key);
3737
}

Qiniu/FileOp/ImageWaterMarker.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public override string MakeRequest (string url)
2121
if (string.IsNullOrEmpty (imageUrl)) {
2222
throw new Exception ("Water Marker Image Url Error");
2323
}
24-
sb.Append ("/image/" + imageUrl.ToBase64URLSafe ());
24+
sb.Append ("/image/" + Base64URLSafe.ToBase64URLSafe(imageUrl));
2525
sb.Append ("/dissolve/" + dissolve);
2626
sb.Append ("/gravity/" + Gravitys [(int)gravity]);
2727
sb.Append ("/dx/" + dx);

Qiniu/FileOp/TextWaterMarker.cs

Lines changed: 52 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,55 @@
11
using System;
22
using System.Text;
3-
using Qiniu.Util;
4-
5-
namespace Qiniu.FileOp
6-
{
7-
public class TextWaterMarker:WaterMarker
8-
{
9-
public string text;
10-
private string fontName;
11-
private int fontSize;
12-
private string color;
13-
14-
public TextWaterMarker (string text, string fontname = "", string color = "", int fontsize = 0, int dissolve = 50, MarkerGravity gravity = MarkerGravity.SouthEast, int dx = 10, int dy = 10)
15-
: base(dissolve,gravity, dx, dy)
16-
{
17-
this.text = text;
18-
this.fontName = fontname;
19-
this.fontSize = fontsize;
20-
this.color = color;
21-
}
22-
23-
public override string MakeRequest (string url)
24-
{
25-
StringBuilder sb = new StringBuilder ();
26-
sb.Append (string.Format ("{0}?watermark/{1}", url, 2));
27-
if (string.IsNullOrEmpty (text)) {
28-
throw new Exception ("No Text To Draw");
29-
}
30-
sb.Append ("/text/" + text.ToBase64URLSafe ());
31-
32-
if (!string.IsNullOrEmpty (fontName)) {
33-
sb.Append ("/font/" + fontName.ToBase64URLSafe ());
34-
}
35-
if (fontSize > 0) {
36-
sb.Append ("/fontsize/" + fontSize);
37-
}
38-
if (!string.IsNullOrEmpty (color)) {
39-
sb.Append ("/fill/" + color.ToBase64URLSafe ());
40-
}
41-
sb.Append ("/dissolve/" + dissolve);
42-
sb.Append ("/gravity/" + Gravitys [(int)gravity]);
43-
sb.Append ("/dx/" + dx);
44-
sb.Append ("/dy/" + dy);
45-
return sb.ToString ();
46-
}
47-
}
3+
using Qiniu.Util;
4+
5+
namespace Qiniu.FileOp
6+
{
7+
/// <summary>
8+
///
9+
/// </summary>
10+
public class TextWaterMarker : WaterMarker
11+
{
12+
private string text;
13+
private string fontName;
14+
private int fontSize;
15+
private string color;
16+
17+
public TextWaterMarker(string text, string fontname = "", string color = "", int fontsize = 0, int dissolve = 50, MarkerGravity gravity = MarkerGravity.SouthEast, int dx = 10, int dy = 10)
18+
: base(dissolve, gravity, dx, dy)
19+
{
20+
this.text = text;
21+
this.fontName = fontname;
22+
this.fontSize = fontsize;
23+
this.color = color;
24+
}
25+
26+
public override string MakeRequest(string url)
27+
{
28+
StringBuilder sb = new StringBuilder();
29+
sb.Append(string.Format("{0}?watermark/{1}", url, 2));
30+
if (string.IsNullOrEmpty(text))
31+
{
32+
throw new Exception("No Text To Draw");
33+
}
34+
sb.Append("/text/" + Base64URLSafe.ToBase64URLSafe(text));
35+
36+
if (!string.IsNullOrEmpty(fontName))
37+
{
38+
sb.Append("/font/" + Base64URLSafe.ToBase64URLSafe(fontName));
39+
}
40+
if (fontSize > 0)
41+
{
42+
sb.Append("/fontsize/" + fontSize);
43+
}
44+
if (!string.IsNullOrEmpty(color))
45+
{
46+
sb.Append("/fill/" + Base64URLSafe.ToBase64URLSafe(color));
47+
}
48+
sb.Append("/dissolve/" + dissolve);
49+
sb.Append("/gravity/" + Gravitys[(int)gravity]);
50+
sb.Append("/dx/" + dx);
51+
sb.Append("/dy/" + dy);
52+
return sb.ToString();
53+
}
54+
}
4855
}

0 commit comments

Comments
 (0)