いいね。
成果物
対象環境
- Raspbierry pi 3 Model B+
- Raspbian stretch(9.0) 2018-06-27
- Mono 5.16.0
- MonoDevelop 7.6 build 711
- Eto.Forms 2.4.1 拡張機能, NuGetパッケージ
前回
手順
- プロジェクト作成
- NuGetでOctokitを追加
- ソースコード作成
- 実行
1. プロジェクト作成
- MonoDevelopを起動する
- メニュー→
ファイル
→新しいソリューション
マルチプラットフォーム
→アプリ
→Eto Application
- 名前などを適当に入力し、
Code
を選択する
場所
を入力する
- プロジェクトが作成される
2. NuGetでOctokitを追加
- メニュー→
プロジェクト
→NuGet パッケージの追加
パッケージを追加
ダイアログから欲しいパッケージを探す
- 検索窓に
octokit
と入力して絞り込む
Octokit
とOctokit.Reactive
を選択する
パッケージを追加
ボタンをクリックする同意する
4. ソースコード作成
MainForm.cs
using System; using System.IO; using System.Collections; using Eto.Forms; using Eto.Drawing; using Octokit; using Octokit.Internal; // InMemoryCredentialStore using Octokit.Reactive; // ObservableRepositoriesClient namespace HelloOctokit { public partial class MainForm : Form { public MainForm() { GetRepos(); } public void GetRepos() { //var github = new GitHubClient(new ProductHeaderValue("GitHubClient")); var credential = new Credentials("username", "password"); // GitHubユーザ名とパスワード var github = new GitHubClient( new ProductHeaderValue("GitHubClient_ytyaru"), new InMemoryCredentialStore(credential)); var reposObserver = new ObservableRepositoriesClient(github); using (FileStream fs = new FileStream("/tmp/work/repos.tsv", System.IO.FileMode.OpenOrCreate)) { using (StreamWriter writer = new StreamWriter(fs)) { writer.WriteLine(String.Join("\t", new string[] { "Id","Name","Size","Description","Homepage","CreatedAt","UpdatedAt" })); reposObserver.GetAllForUser("ytyaru").Subscribe( i => { writer.WriteLine(String.Join("\t", new string[] { i.Id.ToString(),i.Name.ToString(),i.Size.ToString(),i.Description,i.Homepage,i.CreatedAt.ToString("yyyy-MM-dd HH:mm:ss"),i.UpdatedAt.ToString("yyyy-MM-dd HH:mm:ss") })); //writer.WriteLine(i.Id + "\t" + i.Name + "\t" + i.Size + "\t" + i.Description + "\t" + i.Homepage + "\t" + i.CreatedAt + "\t" + i.PushedAt + "\t" + i.UpdatedAt); } ); writer.Flush(); } } ; } } }
3. 実行
- Ctrl+F5で実行
- 怒られた
- ファイルパスを辿ってexeファイルを直接叩くと実行できた
/tmp/work/repos.tsv
ファイルが作成される。
なお、ソースコード内のユーザ名とパスワードを入力し、再コンパイルしないと動作しない。