Skip to content

Instantly share code, notes, and snippets.

@Kogarasi
Last active December 12, 2015 07:28
Show Gist options
  • Save Kogarasi/4736316 to your computer and use it in GitHub Desktop.
Save Kogarasi/4736316 to your computer and use it in GitHub Desktop.
JsonFxのデコード時のクラス定義を楽にしたい。
using JsonFx.Json;
public class SimpleGeneric {
// 呼び出し側
public void hoge(){
var decodeObject = simpleDecode( "{ a:1; }", new { a=1 } ); // 第二引数は型の指定
}
public T simpleDecode<T>( string jsonString, T _type ){
return JsonReader.Deserialize<T>( jsonString );
}
}
// できるかなと思ったら、匿名クラスにはコンストラクタがないのでJsonFx内で例外が投げられて詰む
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment