本文整理汇总了C#中IExpression.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# IExpression.ToString方法的具体用法?C# IExpression.ToString怎么用?C# IExpression.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IExpression
的用法示例。
在下文中一共展示了IExpression.ToString方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsEqual
public static bool IsEqual(IExpression ex, IExpression ex2, AbstractSymbolValueProvider vp)
{
var val_x1 = Evaluation.EvaluateValue(ex, vp);
var val_x2 = Evaluation.EvaluateValue(ex2, vp);
//TEMPORARILY: Remove the string comparison
if (val_x1 == null && val_x2 == null)
return ex.ToString() == ex2.ToString();
return IsEqual(val_x1, val_x2);
}
示例2: CheckExp
private static bool CheckExp(IExpression o, IExpression n)
{
if (o == null && n == null)
return true;
try
{
return (o.ToString() == n.ToString());
}
catch (NullReferenceException)
{
return false;
}
}
示例3: ToString
public static string ToString(IExpression expr)
{
return expr == null ? string.Empty : expr.ToString();
}
示例4: GetExpressionDispatch
//public string GetCollectionPredicateExpression(RequestContext requestContext, ref List<OleDbParameter> parameters)
//{
// string resourceKey = requestContext.ResourceKey;
// if (null == resourceKey)
// throw new InvalidOperationException();
// string scrmIdentifierName = _entityQueryWrapper.GetSageCrmIdentifier();
// string dbIdentifierName = _entityQueryWrapper.GetDbFieldName(scrmIdentifierName);
// parameters.Add(_entityQueryWrapper.GetOleDbParameter(dbf
// Type dbType = _entityQueryWrapper.GetDbFieldType(dbIdentifierName);
// if (dbType == typeof(string))
// return " ([" + dbIdentifierName + "] = '" + requestContext.ResourceKey + "') ";
// else
// return " ([" + dbIdentifierName + "] = " + requestContext.ResourceKey + ") ";
//}
public string GetExpressionDispatch(IExpression expression, ref List<OleDbParameter> parameters)
{
if (expression is ShortcutConditionalOperatorExpression)
{
return GetExpression(expression as ShortcutConditionalOperatorExpression, ref parameters);
}
if (expression is ComparisonOperatorExpression)
{
return GetExpression(expression as ComparisonOperatorExpression, ref parameters);
}
if (expression is LikeExpression)
{
return GetExpression(expression as LikeExpression, ref parameters);
}
if (expression is DivideExpression)
{
return GetExpression(expression as DivideExpression, ref parameters);
}
if (expression is MultiplyExpression)
{
return GetExpression(expression as MultiplyExpression, ref parameters);
}
if (expression is MinusExpression)
{
return GetExpression(expression as MinusExpression, ref parameters);
}
if (expression is PlusExpression)
{
return GetExpression(expression as PlusExpression, ref parameters);
}
if (expression is LiteralExpression) // 'alfki' 1 ....
{
return GetExpression(expression as LiteralExpression, ref parameters);
}
if (expression is FieldExpression) // customerid ....
{
return GetExpression(expression as FieldExpression, ref parameters);
}
if (expression is BetweenExpression) // between
{
return GetExpression(expression as BetweenExpression, ref parameters);
}
if (expression is UnaryOperatorExpression) //Not
{
return GetExpression(expression as UnaryOperatorExpression, ref parameters);
}
else
return expression.ToString();
}
示例5: Unify
/// <summary>
/// Unify the given Expressions
/// </summary>
/// <param name="ex1">first expression</param>
/// <param name="ex2">second expression</param>
/// <returns>most general unifier</returns>
public static IExpression Unify(IExpression ex1, IExpression ex2)
{
if (ex1.IsVariable)
{
if (ex2.IsVariable)
{
if (ex1.Value == ex2.Value) return ex1;
throw new NotUnifiableException(ex1.Value, ex2.Value, "both are variables");
}
if (ex2.IsFunction)
{
VariableRegistry.Instance[(VariableExpression)ex1] = ex2;
return ex2;
}
VariableRegistry.Instance[(VariableExpression)ex1] = ex2;
return ex2;
}
if (ex1.IsFunction)
{
if (ex2.IsVariable)
{
VariableRegistry.Instance[(VariableExpression)ex2] = ex1;
return ex2;
}
if (ex2.IsFunction)
{
if (ex1.Value != ex2.Value) throw new NotUnifiableException(ex1.Value, ex2.Value, "argument missmatch");
var exp1 = (FunctionExpression) ex1;
var exp2 = (FunctionExpression) ex2;
if (exp1.Expressions.Length != exp2.Expressions.Length)
throw new NotUnifiableException(ex1.ToString(), ex2.ToString(), "argument length missmatch");
var exp = new IExpression[exp1.Expressions.Length];
for (int i = 0; i < exp1.Expressions.Length; i++)
{
exp[i] = Unify(exp1.Expressions[i], exp2.Expressions[i]);
}
return new FunctionExpression(exp1.Value, exp);
}
throw new NotUnifiableException(ex1.Value, ex2.Value, "no variable preseent");
}
if (ex2.IsVariable)
{
VariableRegistry.Instance[(VariableExpression)ex2] = ex1;
return ex1;
}
if (ex2.IsFunction)
{
throw new NotUnifiableException(ex1.Value, ex2.Value, "no variable preseent");
}
if (ex1.Value == ex2.Value)
return ex1;
throw new NotUnifiableException(ex1.Value, ex2.Value, "no variable preseent");
}
示例6: TryConvertToInteger
public bool TryConvertToInteger(IExpression value, out int result)
{
if (value == null) {
result = 0;
return true;
}
var asValue = value as IValueExpression;
if (asValue != null) {
int intVal;
if (TryConvert(asValue.Value, out intVal)) {
result = intVal;
return true;
}
}
var str = value.ToString().Trim();
bool b;
if (bool.TryParse(str, out b)) {
result = b ? 1 : 0;
return true;
}
if (int.TryParse(str, out result))
return true;
result = 0;
return false;
}
示例7: ToBoolean
public bool ToBoolean(IExpression value)
{
if (value == null)
return false;
var asValue = value as IValueExpression;
if (asValue != null) {
bool boolVal;
if (TryConvert(asValue.Value, out boolVal))
return boolVal;
}
var str = value.ToString().Trim();
bool b;
if (bool.TryParse(str, out b))
return b;
int i;
if (int.TryParse(str, out i))
return i != 0;
return str.Length > 0;
}
示例8: Push
public void Push(IExpression expr)
{
Text = expr.ToString();
}