本文整理汇总了C#中System.Xml.Xsl.Qil.QilLiteral类的典型用法代码示例。如果您正苦于以下问题:C# QilLiteral类的具体用法?C# QilLiteral怎么用?C# QilLiteral使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
QilLiteral类属于System.Xml.Xsl.Qil命名空间,在下文中一共展示了QilLiteral类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FoldArithmetic
/// <summary>
/// Compute the arithmetic operation "opType" over two literal operands and return the result as a QilLiteral.
/// Arithmetic operations are always checked; in the case of an overflow or divide by zero exception, return
/// the unfolded result.
/// </summary>
private QilNode FoldArithmetic(QilNodeType opType, QilLiteral left, QilLiteral right) {
Debug.Assert(left.NodeType == right.NodeType);
// Catch any overflow or divide by zero exceptions
try {
checked {
switch (left.NodeType) {
case QilNodeType.LiteralInt32: {
int intLeft = left;
int intRight = right;
switch (opType) {
case QilNodeType.Add: return f.LiteralInt32(intLeft + intRight);
case QilNodeType.Subtract: return f.LiteralInt32(intLeft - intRight);
case QilNodeType.Multiply: return f.LiteralInt32(intLeft * intRight);
case QilNodeType.Divide: return f.LiteralInt32(intLeft / intRight);
case QilNodeType.Modulo: return f.LiteralInt32(intLeft % intRight);
}
break;
}
case QilNodeType.LiteralInt64: {
long lngLeft = left;
long lngRight = right;
switch (opType) {
case QilNodeType.Add: return f.LiteralInt64(lngLeft + lngRight);
case QilNodeType.Subtract: return f.LiteralInt64(lngLeft - lngRight);
case QilNodeType.Multiply: return f.LiteralInt64(lngLeft * lngRight);
case QilNodeType.Divide: return f.LiteralInt64(lngLeft / lngRight);
case QilNodeType.Modulo: return f.LiteralInt64(lngLeft % lngRight);
}
break;
}
case QilNodeType.LiteralDecimal: {
decimal lngLeft = left;
decimal lngRight = right;
switch (opType) {
case QilNodeType.Add: return f.LiteralDecimal(lngLeft + lngRight);
case QilNodeType.Subtract: return f.LiteralDecimal(lngLeft - lngRight);
case QilNodeType.Multiply: return f.LiteralDecimal(lngLeft * lngRight);
case QilNodeType.Divide: return f.LiteralDecimal(lngLeft / lngRight);
case QilNodeType.Modulo: return f.LiteralDecimal(lngLeft % lngRight);
}
break;
}
case QilNodeType.LiteralDouble: {
double lngLeft = left;
double lngRight = right;
switch (opType) {
case QilNodeType.Add: return f.LiteralDouble(lngLeft + lngRight);
case QilNodeType.Subtract: return f.LiteralDouble(lngLeft - lngRight);
case QilNodeType.Multiply: return f.LiteralDouble(lngLeft * lngRight);
case QilNodeType.Divide: return f.LiteralDouble(lngLeft / lngRight);
case QilNodeType.Modulo: return f.LiteralDouble(lngLeft % lngRight);
}
break;
}
}
}
}
catch (OverflowException) {
}
catch (DivideByZeroException) {
}
// An error occurred, so don't fold operationo
switch (opType) {
case QilNodeType.Add: return f.Add(left, right);
case QilNodeType.Subtract: return f.Subtract(left, right);
case QilNodeType.Multiply: return f.Multiply(left, right);
case QilNodeType.Divide: return f.Divide(left, right);
case QilNodeType.Modulo: return f.Modulo(left, right);
}
Debug.Assert(false, "Cannot fold this arithmetic operation: " + opType);
return null;
}
示例2: VisitLiteralDecimal
protected override QilNode VisitLiteralDecimal(QilLiteral n) { return NoReplace(n); }
示例3: CheckLiteralType
public XmlQueryType CheckLiteralType(QilLiteral node) {
CheckLiteralValue(node, typeof(XmlQueryType));
return (XmlQueryType) node;
}
示例4: VisitLiteralString
/// <summary>
/// Generate code for QilNodeType.LiteralString.
/// </summary>
protected override QilNode VisitLiteralString(QilLiteral ndStr)
{
_helper.Emit(OpCodes.Ldstr, (string)ndStr);
_iterCurr.Storage = StorageDescriptor.Stack(typeof(string), false);
return ndStr;
}
示例5: CheckLiteralInt32
public XmlQueryType CheckLiteralInt32(QilLiteral node) {
CheckLiteralValue(node, typeof(int));
return XmlQueryTypeFactory.IntX;
}
示例6: CheckLiteralDouble
public XmlQueryType CheckLiteralDouble(QilLiteral node) {
CheckLiteralValue(node, typeof(double));
return XmlQueryTypeFactory.DoubleX;
}
示例7: LiteralInt64
public QilLiteral LiteralInt64(long value) {
QilLiteral n = new QilLiteral(QilNodeType.LiteralInt64, value);
n.XmlType = this.typeCheck.CheckLiteralInt64(n);
TraceNode(n);
return n;
}
示例8: VisitLiteralObject
protected virtual QilNode VisitLiteralObject(QilLiteral n) { return VisitChildren(n); }
示例9: VisitLiteralDecimal
/// <summary>
/// Generate code for QilNodeType.LiteralDecimal.
/// </summary>
protected override QilNode VisitLiteralDecimal(QilLiteral ndDec)
{
_helper.ConstructLiteralDecimal((decimal)ndDec);
_iterCurr.Storage = StorageDescriptor.Stack(typeof(decimal), false);
return ndDec;
}
示例10: LiteralString
public QilLiteral LiteralString(string value) {
QilLiteral n = new QilLiteral(QilNodeType.LiteralString, value);
n.XmlType = this.typeCheck.CheckLiteralString(n);
TraceNode(n);
return n;
}
示例11: VisitLiteralDouble
/// <summary>
/// Generate code for QilNodeType.LiteralDouble.
/// </summary>
protected override QilNode VisitLiteralDouble(QilLiteral ndDbl)
{
_helper.Emit(OpCodes.Ldc_R8, (double)ndDbl);
_iterCurr.Storage = StorageDescriptor.Stack(typeof(double), false);
return ndDbl;
}
示例12: VisitLiteralInt64
/// <summary>
/// Generate code for QilNodeType.LiteralInt64.
/// </summary>
protected override QilNode VisitLiteralInt64(QilLiteral ndLong)
{
_helper.Emit(OpCodes.Ldc_I8, (long)ndLong);
_iterCurr.Storage = StorageDescriptor.Stack(typeof(long), false);
return ndLong;
}
示例13: VisitLiteralInt32
/// <summary>
/// Generate code for QilNodeType.LiteralInt32.
/// </summary>
protected override QilNode VisitLiteralInt32(QilLiteral ndInt)
{
_helper.LoadInteger((int)ndInt);
_iterCurr.Storage = StorageDescriptor.Stack(typeof(int), false);
return ndInt;
}
示例14: VisitLiteralObject
protected override QilNode VisitLiteralObject(QilLiteral n) { return NoReplace(n); }
示例15: LiteralDouble
public QilLiteral LiteralDouble(double value) {
QilLiteral n = new QilLiteral(QilNodeType.LiteralDouble, value);
n.XmlType = this.typeCheck.CheckLiteralDouble(n);
TraceNode(n);
return n;
}