当前位置: 首页>>代码示例>>C#>>正文


C# Attribute.add方法代码示例

本文整理汇总了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
                {
//.........这里部分代码省略.........
开发者ID:advdig,项目名称:advgp2_administracion,代码行数:101,代码来源:StringFormulaParser.cs


注:本文中的Attribute.add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。