當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。