-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: add get song pic feature #116
- Loading branch information
Showing
9 changed files
with
203 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace MusicLyricApp.Bean | ||
{ | ||
public class CsvBean | ||
{ | ||
private readonly List<string> title; | ||
|
||
private readonly List<List<string>> lines; | ||
|
||
private int curLine; | ||
|
||
public CsvBean() | ||
{ | ||
title = new List<string>(); | ||
lines = new List<List<string>>(); | ||
} | ||
|
||
public void AddColumn(string name) | ||
{ | ||
title.Add(name); | ||
} | ||
|
||
public void AddData(string data) | ||
{ | ||
while (lines.Count <= curLine) | ||
{ | ||
lines.Add(new List<string>()); | ||
} | ||
|
||
lines[curLine].Add(data); | ||
} | ||
|
||
public void NextLine() | ||
{ | ||
curLine++; | ||
} | ||
|
||
public override string ToString() | ||
{ | ||
var sb = new StringBuilder(); | ||
|
||
sb | ||
.Append(string.Join(",", title)) | ||
.Append(Environment.NewLine); | ||
|
||
foreach (var line in lines) | ||
{ | ||
sb | ||
.Append(string.Join(",", line)) | ||
.Append(Environment.NewLine); | ||
} | ||
|
||
return sb.ToString(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using MusicLyricApp.Bean; | ||
using NUnit.Framework; | ||
|
||
namespace MusicLyricAppTest.Bean | ||
{ | ||
[TestFixture] | ||
public class CsvUtils | ||
{ | ||
[Test] | ||
public void TestNewInstance() | ||
{ | ||
var songVos = new List<SongVo>(); | ||
|
||
for (var i = 0; i < 10; i++) | ||
{ | ||
var vo = new SongVo | ||
{ | ||
Album = i.ToString(), | ||
Name = (i * 100).ToString() | ||
}; | ||
|
||
songVos.Add(vo); | ||
} | ||
|
||
var bean = new CsvBean(); | ||
|
||
bean.AddColumn("name"); | ||
bean.AddColumn("album"); | ||
|
||
foreach (var songVo in songVos) | ||
{ | ||
bean.AddData(songVo.Name); | ||
bean.AddData(songVo.Album); | ||
bean.NextLine(); | ||
} | ||
Console.WriteLine(bean); | ||
} | ||
} | ||
} |
Oops, something went wrong.