Skip to content

Commit

Permalink
函数返回值中的IEnumerable改为IReadOnlyCollection或IReadOnlyList。
Browse files Browse the repository at this point in the history
  • Loading branch information
sanjusss committed Feb 18, 2019
1 parent a491b6a commit db36b17
Showing 11 changed files with 25 additions and 24 deletions.
6 changes: 3 additions & 3 deletions 1fichier.SDK.Test/ClientTest.cs
Original file line number Diff line number Diff line change
@@ -72,7 +72,7 @@ private async Task<string> UploadATestFile()
Dictionary<string, Stream> files2Upload = new Dictionary<string, Stream>();
MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(_testContent));
files2Upload[_testFileName] = ms;
var results = new List<UploadResult>(await _client.UploadFiles(files2Upload, _testPathId));
var results = await _client.UploadFiles(files2Upload, _testPathId);
return results[0].downloadLink;
}

@@ -115,7 +115,7 @@ public async Task GetTempDownloadLinkTest()
public async Task ListFilesTest()
{
await UploadATestFile();
List<FileSimpleInfo> files = new List<FileSimpleInfo>(await _client.ListFiles(_testPathId));
var files = await _client.ListFiles(_testPathId);
Assert.AreEqual(1, files.Count);
Assert.AreEqual(_testFileName, files[0].filename);
}
@@ -195,7 +195,7 @@ public async Task MoveFilesTest()
int folder = await _client.MakeFolder("des", _testPathId);
var result = await _client.MoveFiles(new string[] { url }, folder);
Assert.AreEqual(1, result.moved);
string newUrl = (new List<string>(result.urls))[0];
string newUrl = result.urls[0];
var info = await _client.GetFileFullInfo(url);
Assert.AreEqual(_testFileName, info.filename);
}
13 changes: 7 additions & 6 deletions 1fichier.SDK/1fichier.SDK.csproj
Original file line number Diff line number Diff line change
@@ -4,24 +4,25 @@
<TargetFramework>netstandard2.0</TargetFramework>
<RootNamespace>_1fichier.SDK</RootNamespace>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>0.1.3</Version>
<Version>0.1.4</Version>
<Authors>sanjusss</Authors>
<Company />
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<PackageProjectUrl>https://github.com/sanjusss/1fichier.SDK</PackageProjectUrl>
<RepositoryUrl>https://github.com/sanjusss/1fichier.SDK</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<Copyright>©sanjusss, 2019</Copyright>
<AssemblyVersion>0.1.3.0</AssemblyVersion>
<AssemblyVersion>0.1.4.0</AssemblyVersion>
<PackageLicenseExpression>GPL-3.0-only</PackageLicenseExpression>
<Description>Dotnet SDK for 1fichier.com.</Description>
<PackageReleaseNotes>增加功能:
获取文件简要信息
获取文件详细信息
修改文件属性
移动文件
重命名文件
复制文件

修改:
修改GetFolderId函数,在文件夹不存在时将抛出异常。</PackageReleaseNotes>
函数返回值中的IEnumerable改为IReadOnlyCollection或IReadOnlyList。
修复注释中描述不正确的内容。</PackageReleaseNotes>
</PropertyGroup>

<ItemGroup>
4 changes: 2 additions & 2 deletions 1fichier.SDK/Client.cs
Original file line number Diff line number Diff line change
@@ -274,7 +274,7 @@ protected async Task<Node> GetUploadNode()
/// <returns>上传结果的集合。</returns>
/// <exception cref="NoIdException">获取操作ID时发生异常。</exception>
/// <exception cref="UploadFailedException">上传失败。</exception>
public async Task<IReadOnlyCollection<UploadResult>> UploadFiles(IReadOnlyDictionary<string, Stream> files, int did = 0, int domain = 0)
public async Task<IReadOnlyList<UploadResult>> UploadFiles(IReadOnlyDictionary<string, Stream> files, int did = 0, int domain = 0)
{
List<Dictionary<string, Stream>> nextFiles = new List<Dictionary<string, Stream>>();
List<UploadResult> uploadResults = new List<UploadResult>();
@@ -663,7 +663,7 @@ public async Task<int> MakePath(string path)
/// <exception cref="InvalidApiKeyException">非法的API Key。</exception>
/// <exception cref="CommonException">服务器返回的错误。</exception>
/// <exception cref="AbuseException">显示所有文件的频率超过了10分钟1次。。</exception>
public async Task<IEnumerable<FileSimpleInfo>> ListFiles(int folder, string sharingUser = null, DateTime? start = null, DateTime? end = null)
public async Task<IReadOnlyList<FileSimpleInfo>> ListFiles(int folder, string sharingUser = null, DateTime? start = null, DateTime? end = null)
{
if (folder == -1)
{
6 changes: 3 additions & 3 deletions 1fichier.SDK/Request/AccessControlRequest.cs
Original file line number Diff line number Diff line change
@@ -12,15 +12,15 @@ public struct AccessControlRequest
/// <summary>
/// 允许访问的ip范围,用IP或CIDR表示。
/// </summary>
public IEnumerable<string> ip;
public IReadOnlyCollection<string> ip;
/// <summary>
/// 允许访问的国家代码。
/// </summary>
public IEnumerable<string> country;
public IReadOnlyCollection<string> country;
/// <summary>
/// 允许访问的用户的邮箱。
/// </summary>
public IEnumerable<string> email;
public IReadOnlyCollection<string> email;
/// <summary>
/// 是否只允许premium或access用户。
/// </summary>
2 changes: 1 addition & 1 deletion 1fichier.SDK/Request/FilesAttributesRequest.cs
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ public struct FilesAttributesRequest
/// <summary>
/// 文件的下载链接。作为文件唯一标识符,必须填写。
/// </summary>
public IEnumerable<string> urls;
public IReadOnlyCollection<string> urls;
/// <summary>
/// 文件名,只在urls数量为1时有效。
/// </summary>
6 changes: 3 additions & 3 deletions 1fichier.SDK/Result/AccessControlInfo.cs
Original file line number Diff line number Diff line change
@@ -12,15 +12,15 @@ public struct AccessControlInfo
/// <summary>
/// 允许访问的ip范围,用IP或CIDR表示。
/// </summary>
public IEnumerable<string> ip;
public IReadOnlyList<string> ip;
/// <summary>
/// 允许访问的国家代码。
/// </summary>
public IEnumerable<string> country;
public IReadOnlyList<string> country;
/// <summary>
/// 允许访问的用户的邮箱。
/// </summary>
public IEnumerable<string> email;
public IReadOnlyList<string> email;
/// <summary>
/// 是否只允许premium或access用户。
/// </summary>
2 changes: 1 addition & 1 deletion 1fichier.SDK/Result/FileListResult.cs
Original file line number Diff line number Diff line change
@@ -17,6 +17,6 @@ public struct FileListResult
/// <summary>
/// 文件集合
/// </summary>
public IEnumerable<FileSimpleInfo> items;
public IReadOnlyList<FileSimpleInfo> items;
}
}
4 changes: 2 additions & 2 deletions 1fichier.SDK/Result/FolderInfo.cs
Original file line number Diff line number Diff line change
@@ -47,14 +47,14 @@ public struct FolderInfo
/// 子文件夹的集合
/// </summary>
[JsonProperty("sub_folders")]
public IEnumerable<SubFolderInfo> subFolders;
public IReadOnlyList<SubFolderInfo> subFolders;
/// <summary>
/// 当前目录下的文件数量
/// </summary>
public int files;
/// <summary>
/// 当前目录下的文件的集合
/// </summary>
public IEnumerable<FileSimpleInfo> items;
public IReadOnlyList<FileSimpleInfo> items;
}
}
2 changes: 1 addition & 1 deletion 1fichier.SDK/Result/MoveFilesResult.cs
Original file line number Diff line number Diff line change
@@ -16,6 +16,6 @@ public struct MoveFilesResult
/// <summary>
/// 移动后文件的下载链接。
/// </summary>
public IEnumerable<string> urls;
public IReadOnlyList<string> urls;
}
}
2 changes: 1 addition & 1 deletion 1fichier.SDK/Result/UploadResult.cs
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@ public struct UploadResult
/// <param name="html">服务器返回的html内容</param>
/// <returns>上传结果的集合。</returns>
/// <exception cref="UploadFailedException">不能解析返回的html。</exception>
public static IEnumerable<UploadResult> Parse(string html)
public static IReadOnlyList<UploadResult> Parse(string html)
{
Selectable selectable = new Selectable(html);
var tables = selectable.SelectList(Selectors.XPath("//table[@class='premium']")).Nodes();
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

version: 0.1.3.{build}
version: 0.1.4.{build}
image: Visual Studio 2017
clone_depth: 1
environment:

0 comments on commit db36b17

Please sign in to comment.