本文整理汇总了C#中Attribute.add方法的典型用法代码示例。如果您正苦于以下问题:C# Attribute.add方法的具体用法?C# Attribute.add怎么用?C# Attribute.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Attribute
的用法示例。
在下文中一共展示了Attribute.add方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: handleFunction
/**
* Handles the case when parsing a string when a token is a function
*
* @param sf the string function
* @param i the token iterator
* @param stack the parse tree stack
* @exception FormulaException if an error occurs
*/
private void handleFunction(StringFunction sf,IEnumerator<ParseItem> i,Stack<ParseItem> stack)
{
ParseItem pi2 = parseCurrent(i);
// If the function is unknown, then throw an error
if (sf.getFunction(settings) == Function.UNKNOWN)
throw new FormulaException(FormulaException.UNRECOGNIZED_FUNCTION);
// First check for possible optimized functions and possible
// use of the Attribute token
if (sf.getFunction(settings) == Function.SUM && arguments == null)
{
// this is handled by an attribute
Attribute a = new Attribute(sf,settings);
a.add(pi2);
stack.Push(a);
return;
}
if (sf.getFunction(settings) == Function.IF)
{
// this is handled by an attribute
Attribute a = new Attribute(sf,settings);
// Add in the if conditions as a var arg function in
// the correct order
VariableArgFunction vaf = new VariableArgFunction(settings);
object [] items = arguments.ToArray();
for (int j = 0; j < items.Length; j++)
{
ParseItem pi3 = (ParseItem)items[j];
vaf.add(pi3);
}
a.setIfConditions(vaf);
stack.Push(a);
return;
}
int newNumArgs;
// Function cannot be optimized. See if it is a variable argument
// function or not
if (sf.getFunction(settings).getNumArgs() == 0xff)
{
// If the arg stack has not been initialized, it means
// that there was only one argument, which is the
// returned parse item
if (arguments == null)
{
int numArgs = pi2 != null ? 1 : 0;
VariableArgFunction vaf = new VariableArgFunction(sf.getFunction(settings),numArgs,settings);
if (pi2 != null)
vaf.add(pi2);
stack.Push(vaf);
}
else
{
// Add the args to the function in the correct order
newNumArgs = arguments.Count;
VariableArgFunction vaf = new VariableArgFunction(sf.getFunction(settings),newNumArgs,settings);
ParseItem[] args = new ParseItem[newNumArgs];
for (int j = 0; j < newNumArgs; j++)
{
ParseItem pi3 = (ParseItem)arguments.Pop();
args[newNumArgs - j - 1] = pi3;
}
for (int j = 0; j < args.Length; j++)
vaf.add(args[j]);
stack.Push(vaf);
arguments.Clear();
arguments = null;
}
return;
}
// Function is a standard built in function
BuiltInFunction bif = new BuiltInFunction(sf.getFunction(settings),settings);
newNumArgs = sf.getFunction(settings).getNumArgs();
if (newNumArgs == 1)
{
// only one item which is the returned ParseItem
bif.add(pi2);
}
else
{
//.........这里部分代码省略.........