Reactive.Bindingsでバインドできるプロパティを持った独自クラスを作ったのですが、インスタンス化したあとの列挙の仕方が分かりません。
C#
1using System.Reactive; 2public class hoge 3{ 4 public ReactiveProperty<string> one { get; } = new ReactiveProperty<string>(); 5 public ReactiveProperty<string> two { get; } = new ReactiveProperty<string>(); 6 public ReactiveProperty<string> three { get; } = new ReactiveProperty<string>(); 7} 8 9public hoge h = new hoge(); 10//h.one.Valueで値にアクセスできるところまでは分かりました。
このhの中にあるプロパティをループして値にアクセスする方法が知りたいです。
調べて以下のような方法を試しましたが上手くいきませんでした。
C#
1var infoArray = h.GetType().GetProperties(); 2foreach (PropertyInfo info in infoArray) 3{ 4 //info.Nameでプロパティ名は取得できましたが 5 //info.SetValue(h, "");と 6 //info.GetValue(h);ではアクセスできませんでした。 7}
よろしくお願いします。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/04/21 19:47