We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dynamicの内部実装のCallSite.Target 内での動的コード生成の説明で、
その結果、Target が以下のような状態に更新されます。 (中略) ここで、((Point)x).X の部分を生成するのが CallSiteBinder の役目です。
とありますが、実際にBindメソッドが生成を担うのはif (x is Point) return ((Point)x).X;の部分ではないでしょうか?
Bind
if (x is Point) return ((Point)x).X;
雑実装ですが、以下のようにif、is、returnも書く感じになるかと思います。
public class PropertyXBinder : CallSiteBinder { public override Expression Bind(object[] args, ReadOnlyCollection<ParameterExpression> parameters, LabelTarget returnLabel) { var arg = args[0]; var argType = arg.GetType(); var property = argType.GetProperty("X"); var parameter = parameters[0]; return Expression.IfThen( Expression.TypeIs( parameter, argType ), Expression.Return( returnLabel, Expression.Property( Expression.Convert( parameter, argType ), property ) ) ); } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
dynamicの内部実装のCallSite.Target 内での動的コード生成の説明で、
とありますが、実際に
Bind
メソッドが生成を担うのはif (x is Point) return ((Point)x).X;
の部分ではないでしょうか?雑実装ですが、以下のようにif、is、returnも書く感じになるかと思います。
The text was updated successfully, but these errors were encountered: