本文整理汇总了C#中ParsingContext类的典型用法代码示例。如果您正苦于以下问题:C# ParsingContext类的具体用法?C# ParsingContext怎么用?C# ParsingContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ParsingContext类属于命名空间,在下文中一共展示了ParsingContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
public override CompileResult Execute(IEnumerable<FunctionArgument> arguments, ParsingContext context)
{
ValidateArguments(arguments, 2);
var row = ArgToInt(arguments, 0);
var col = ArgToInt(arguments, 1);
ThrowExcelErrorValueExceptionIf(() => row < 0 && col < 0, eErrorType.Value);
var referenceType = ExcelReferenceType.AbsoluteRowAndColumn;
var worksheetSpec = string.Empty;
if (arguments.Count() > 2)
{
var arg3 = ArgToInt(arguments, 2);
ThrowExcelErrorValueExceptionIf(() => arg3 < 1 || arg3 > 4, eErrorType.Value);
referenceType = (ExcelReferenceType)ArgToInt(arguments, 2);
}
if (arguments.Count() > 3)
{
var fourthArg = arguments.ElementAt(3).Value;
if(fourthArg.GetType().Equals(typeof(bool)) && !(bool)fourthArg)
{
throw new InvalidOperationException("Excelformulaparser does not support the R1C1 format!");
}
if (fourthArg.GetType().Equals(typeof(string)))
{
worksheetSpec = fourthArg.ToString() + "!";
}
}
var translator = new IndexToAddressTranslator(context.ExcelDataProvider, referenceType);
return CreateResult(worksheetSpec + translator.ToAddress(col, row), DataType.ExcelAddress);
}
示例2: Execute
public override CompileResult Execute(IEnumerable<FunctionArgument> arguments, ParsingContext context)
{
ValidateArguments(arguments, 1);
var nItems = 0d;
Calculate(arguments, ref nItems, context, ItemContext.SingleArg);
return CreateResult(nItems, DataType.Integer);
}
示例3: Execute
public override CompileResult Execute(IEnumerable<FunctionArgument> arguments, ParsingContext context)
{
ValidateArguments(arguments, 2);
var n1 = ArgToDecimal(arguments, 0);
var n2 = ArgToDecimal(arguments, 1);
return new CompileResult(n1 % n2, DataType.Decimal);
}
示例4: Execute
public override CompileResult Execute(IEnumerable<FunctionArgument> arguments, ParsingContext context)
{
ValidateArguments(arguments, 2);
var firstArg = arguments.ElementAt(0);
var args = firstArg.Value as IEnumerable<FunctionArgument>;
if (args == null && firstArg.IsExcelRange)
{
args = new List<FunctionArgument>(){ firstArg };
}
var criteria = arguments.ElementAt(1).Value;
ThrowExcelErrorValueExceptionIf(() => criteria == null || criteria.ToString().Length > 255, eErrorType.Value);
var retVal = 0d;
if (arguments.Count() > 2)
{
var secondArg = arguments.ElementAt(2);
var lookupRange = secondArg.Value as IEnumerable<FunctionArgument>;
if (lookupRange == null && secondArg.IsExcelRange)
{
lookupRange = new List<FunctionArgument>() {secondArg};
}
retVal = CalculateWithLookupRange(args, criteria.ToString(), lookupRange, context);
}
else
{
retVal = CalculateSingleRange(args, criteria.ToString(), context);
}
return CreateResult(retVal, DataType.Decimal);
}
示例5: Execute
public override CompileResult Execute(IEnumerable<FunctionArgument> arguments, ParsingContext context)
{
ValidateArguments(arguments, 1);
var val = arguments.ElementAt(0).ValueFirst;
if (val is string) return CreateResult(val, DataType.String);
return CreateResult(string.Empty, DataType.String);
}
示例6: Calculate
private double Calculate(FunctionArgument arg, ParsingContext context)
{
var retVal = 0d;
if (ShouldIgnore(arg))
{
return retVal;
}
if (arg.Value is IEnumerable<FunctionArgument>)
{
foreach (var item in (IEnumerable<FunctionArgument>)arg.Value)
{
retVal += Calculate(item, context);
}
}
else if (arg.Value is ExcelDataProvider.IRangeInfo)
{
foreach (var c in (ExcelDataProvider.IRangeInfo)arg.Value)
{
if (ShouldIgnore(c, context) == false)
{
CheckForAndHandleExcelError(c);
retVal += c.ValueDouble;
}
}
}
else
{
CheckForAndHandleExcelError(arg);
retVal += ConvertUtil.GetValueDouble(arg.Value, true);
}
return retVal;
}
示例7: Execute
public override CompileResult Execute(IEnumerable<FunctionArgument> arguments, ParsingContext context)
{
ValidateArguments(arguments, 1);
var arg = GetFirstValue(arguments);
if (arg is bool)
{
var val = (bool) arg ? 1d : 0d;
return CreateResult(val, DataType.Decimal);
}
else if (IsNumeric(arg))
{
var val = ConvertUtil.GetValueDouble(arg);
return CreateResult(val, DataType.Decimal);
}
else if (arg is string)
{
return CreateResult(0d, DataType.Decimal);
}
else if (arg is ExcelErrorValue)
{
return CreateResult(arg, DataType.ExcelError);
}
throw new ExcelErrorValueException(eErrorType.Value);
}
示例8: Calculate
private void Calculate(IEnumerable<FunctionArgument> items, ParsingContext context, ref double nItems)
{
foreach (var item in items)
{
var cs = item.Value as ExcelDataProvider.IRangeInfo;
if (cs != null)
{
foreach (var c in cs)
{
_CheckForAndHandleExcelError(c, context);
if (!ShouldIgnore(c, context) && ShouldCount(c.Value))
{
nItems++;
}
}
}
else if (item.Value is IEnumerable<FunctionArgument>)
{
Calculate((IEnumerable<FunctionArgument>)item.Value, context, ref nItems);
}
else
{
_CheckForAndHandleExcelError(item, context);
if (!ShouldIgnore(item) && ShouldCount(item.Value))
{
nItems++;
}
}
}
}
示例9: _CheckForAndHandleExcelError
private void _CheckForAndHandleExcelError(FunctionArgument arg, ParsingContext context)
{
if (context.Scopes.Current.IsSubtotal)
{
CheckForAndHandleExcelError(arg);
}
}
示例10: Execute
public override CompileResult Execute(IEnumerable<FunctionArgument> arguments, ParsingContext context)
{
if (arguments == null || arguments.Count() == 0)
{
return CreateResult(true, DataType.Boolean);
}
var result = true;
foreach (var arg in arguments)
{
if (arg.Value is ExcelDataProvider.IRangeInfo)
{
var r=(ExcelDataProvider.IRangeInfo)arg.Value;
if (r.GetValue(r.Address._fromRow, r.Address._fromCol) != null)
{
result = false;
}
}
else
{
if (arg.Value != null && (arg.Value.ToString() != string.Empty))
{
result = false;
break;
}
}
}
return CreateResult(result, DataType.Boolean);
}
示例11: Execute
public override void Execute(ParsingContext context)
{
var savedParserInput = context.CurrentParserInput;
context.CurrentParserInput = GetResultNode(context);
CompleteReduce(context);
context.CurrentParserInput = savedParserInput;
}
示例12: Execute
public override CompileResult Execute(IEnumerable<FunctionArgument> arguments, ParsingContext context)
{
ValidateArguments(arguments, 1);
var firstArg = arguments.ElementAt(0);
if (firstArg.Value == null || firstArg.ValueIsExcelError) return CreateResult(false, DataType.Boolean);
return CreateResult(!(firstArg.Value is string), DataType.Boolean);
}
示例13: Parse
public override LinkedList<IWikiElement> Parse(ParsingContext parsingContext, ElementContent containerContent)
{
var elements = new LinkedList<IWikiElement>();
foreach (Match match in _linkExpression.Matches(containerContent.ToString()))
{
var elementContent = new ElementContent(containerContent, match);
var innerContent = new ElementContent(containerContent, match.Groups["content"]);
string originalAddress, normalizedAddress;
if (match.Groups["url"].Success)
{
originalAddress = match.Groups["url"].Value;
normalizedAddress = FormatUrl(originalAddress);
}
else if (match.Groups["email"].Success)
{
originalAddress = match.Groups["email"].Value;
normalizedAddress = FormatEmail(originalAddress);
}
else
continue;
string text = match.Groups["text"].Success ? match.Groups["text"].Value : originalAddress;
bool noFollow = match.Groups["nofollow"].Success;
var element = new LinkElement(parsingContext, elementContent, innerContent, normalizedAddress, text, noFollow);
elements.AddLast(element);
}
return elements;
}
示例14: Execute
public override CompileResult Execute(IEnumerable<FunctionArgument> arguments, ParsingContext context)
{
ValidateArguments(arguments, 1);
var error = arguments.ElementAt(0);
var isErrorFunc = context.Configuration.FunctionRepository.GetFunction("iserror");
var isErrorResult = isErrorFunc.Execute(arguments, context);
if (!(bool) isErrorResult.Result)
{
return CreateResult(ExcelErrorValue.Create(eErrorType.NA), DataType.ExcelError);
}
var errorType = error.ValueAsExcelErrorValue;
int retValue;
switch (errorType.Type)
{
case eErrorType.Null:
return CreateResult(1, DataType.Integer);
case eErrorType.Div0:
return CreateResult(2, DataType.Integer);
case eErrorType.Value:
return CreateResult(3, DataType.Integer);
case eErrorType.Ref:
return CreateResult(4, DataType.Integer);
case eErrorType.Name:
return CreateResult(5, DataType.Integer);
case eErrorType.Num:
return CreateResult(6, DataType.Integer);
case eErrorType.NA:
return CreateResult(7, DataType.Integer);
}
return CreateResult(ExcelErrorValue.Create(eErrorType.NA), DataType.ExcelError);
}
示例15: Execute
public override CompileResult Execute(IEnumerable<FunctionArgument> arguments, ParsingContext context)
{
if (arguments == null || arguments.Count() == 0)
{
return CreateResult(false, DataType.Boolean);
}
foreach (var argument in arguments)
{
if (argument.Value is ExcelDataProvider.IRangeInfo)
{
var r = (ExcelDataProvider.IRangeInfo)argument.Value;
if (ExcelErrorValue.Values.IsErrorValue(r.GetValue(r.Address._fromRow, r.Address._fromCol)))
{
return CreateResult(true, DataType.Boolean);
}
}
else
{
if (ExcelErrorValue.Values.IsErrorValue(argument.Value))
{
return CreateResult(true, DataType.Boolean);
}
}
}
return CreateResult(false, DataType.Boolean);
}