1

私は、実行時にコンパイルされるコードにxmlを変換するルールエンジンに取り組んでいます。このために、文字列ではなく式として利用できるオブジェクト/コレクション内のプロパティにアクセスしたいと考えています。

簡単な例 - プロパティ Age を持つ Student クラス

Expression stud = Expression.Variable(typeof(Student), "student");
Expression.Property(stud, Expression.Constant("Age"));
4

1 に答える 1

0

次のようなものではないでしょうか。

// represents a variable student
var studentExpression = Expression.Variable(typeof(Student), "student");

// represents student.Age
var studenDotAgeExpression = Expression.Property(studentExpression, typeof(Student).GetProperty("Age"));
于 2012-09-21T03:58:09.810 に答える