简体   繁体   English

System.Linq.Expressions.LogicalBinaryExpression类有什么问题?

[英]What's wrong with System.Linq.Expressions.LogicalBinaryExpression class?

I'm trying to parse Expression and at some point I have to parse expressions with type System.Linq.Expressions.LogicalBinaryExpression . 我正在尝试解析Expression,在某些时候我必须解析类型为System.Linq.Expressions.LogicalBinaryExpression表达式。 This class name I take from debug watch. 我从调试手表中获取此类名。 expression.GetType().ToString() equals "System.Linq.Expressions.LogicalBinaryExpression" . expression.GetType().ToString()等于"System.Linq.Expressions.LogicalBinaryExpression" But I cant see this class in System.Linq.Expressions namespace. 但是我无法在System.Linq.Expressions命名空间中看到这个类。 Nowhere at all. 无处可去。 The same thing with MethodBinaryExpression class. MethodBinaryExpression类相同的东西。

In order to check type I really prefer to write 为了检查类型我真的更喜欢写

  • expression is LogicalBinaryExpression or expression is LogicalBinaryExpression
  • expression.GetType() = typeof(LogicalBinaryExpression ) but definitely not expression.GetType() = typeof(LogicalBinaryExpression )但绝对不是
  • expression.GetType().ToString() == "System.Linq.Expressions.LogicalBinaryExpression"

So now I just have error 所以现在我只是有错误

The type or namespace name 'LogicalBinaryExpression' does not exist in the namespace 'System.Linq.Expressions' (are you missing an assembly reference?) 名称空间'System.Linq.Expressions'中不存在类型或命名空间名称'LogicalBinaryExpression'(您是否缺少程序集引用?)

How this possible? 这怎么可能?

LogicalBinaryExpression is internal , so: LogicalBinaryExpressioninternal ,因此:

  1. It's more difficult to get is as a Type , you can't simply use typeof(LogicalBinaryExpression) or x is LogicalBinaryExpression . 获取更难以作为Type ,您不能简单地使用typeof(LogicalBinaryExpression)x is LogicalBinaryExpression
  2. You won't find any documentation about it. 您将找不到任何有关它的文档。
  3. You shouldn't use it at all. 你根本不应该使用它。 It's an implementation detail that can change any time. 这是一个可以随时更改的实现细节。

You should either check for BinaryExpression , or check the NodeType of the expression. 您应该检查BinaryExpression ,或检查表达式的NodeType

The same applies to MethodBinaryExpression . 这同样适用于MethodBinaryExpression

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM