こちらで公開しております。
- GitHub [GistsApi] (https://github.com/pierre3/GistsApi)
Gist API が返してくるJSONの変換にはDynamicJsonを使用させていただきました。
| // 複数のファイルをまとめて非同期に読む | |
| // Observable.Create がいいらしい | |
| // IObservable<T> Create<T>(Func<IObserver<T>,CancellationToken, Task> subscribe) | |
| // このオーバーロードがない(Rx2.0?)ので自作してみる | |
| private IObservable<Tuple<string, string>> OpenFiles(string[] fileNames) | |
| { | |
| return ObservableEx.Create<Tuple<string, string>>(async (observer, ct) => | |
| { | |
| try |
| using System.Collections.Generic; | |
| using System.Collections.ObjectModel; | |
| namespace GistsApi | |
| { | |
| public class GistObject | |
| { | |
| public string url { set; get; } | |
| public string id { set; get; } | |
| public string description { set; get; } |
こちらで公開しております。
Gist API が返してくるJSONの変換にはDynamicJsonを使用させていただきました。
前回 とは逆のパターン、Gistを生成したりする場合にPOSTするJSONの生成方法に関するメモ。
"files"の下に、 " ファイル名 " : { "content": " ファイルの内容 " }
を1つ以上含むオブジェクトを設定します。
やはり、" ファイル名 "の部分が不定となります。
Gistの作成、編集、閲覧が可能なWindows用デスクトップアプリケーションです。
| | |
| using System; | |
| using System.Linq; | |
| using System.Text; | |
| using System.Globalization; | |
| namespace TextDataUtility | |
| { | |
| public static partial class StringExtensions | |
| { |
こちらの記事から
bool dat = (bool:TextToBoolConverter)file[0];
こんな構文ないけど、型変換演算子のオーバーロードで、ほぼ同等ことができるのでは?ということで作ってみました。
他の主要な組み込み型についてもT4を使ってさくっと作れます。
(個人的にはToBoolean()みたいな拡張メソッドの方が使いやすいと思いますが。(インテリセンス使えますし))
| public static class SecureStringEx | |
| { | |
| public static bool Equals(this SecureString a, SecureString b) | |
| { | |
| if (a == null && b == null) | |
| { return true; } | |
| if (a == null || b == null) | |
| { return false; } |
| public static IEnumerable<string> Parse(string line, | |
| ICollection<string> delimiters, Func<string> followingLineSelector) | |
| { | |
| //読み取った文字の種類に応じて処理を振り分けるために使用するTokenState 列挙型 | |
| var state = TokenState.Empty; | |
| string token = ""; | |
| // -フィールドを1文字ずつ読み取り、token へ格納する | |
| // -1フィールド分を読み取ったら yield return token; で出力 | |
| foreach (var c in line) | |
| { |