Beispiel #1
0
        /// <summary>
        /// Evaluate the specified number, returns msgstr index.
        /// </summary>
        /// <param name='n'>
        /// Number to evaluate
        /// </param>
        /// <param name='traceToFile'>
        /// Debug purposes only. Trace to file an evaluation tree.
        /// </param>
        public long Evaluate(long n, bool traceToFile)
        {
            if (plural == null)
            {
                return(0);
            }
#if DEBUG
            RecursiveTracer tracer = new RecursiveTracer();
            tracer.Text.AppendFormat("Expression: {0}", expression);
            tracer.Text.AppendLine();
            tracer.Text.AppendFormat("Evaluate: {0}", n);
            tracer.Text.AppendLine();
            tracer.Text.AppendLine();
#endif
            long number = plural.Evaluate(n);
#if DEBUG
            PluralFormsNode.IterateNodes(
                plural,
                delegate(PluralFormsNode node)
            {
                tracer.Text.AppendFormat("{0}: ", tracer.Level++);
                tracer.Indent();
                if (node.Tracer != null)
                {
                    tracer.Text.AppendLine(node.Tracer.Text.ToString());
                }
            },
                delegate(PluralFormsNode node)
            {
                tracer.Level--;
            }
                );
            if (traceToFile)
            {
                tracer.SaveToFile("Evaluations.txt");
            }
#endif
            if (number < 0 || number > nplurals)
            {
                return(0);
            }
            return(number);
        }
Beispiel #2
0
        public void DumpNodes(string fileName)
        {
            if (plural != null)
            {
                RecursiveTracer tracer = new RecursiveTracer();
                tracer.Text.Append(expression);
                tracer.Text.AppendLine();

                PluralFormsNode.IterateNodes(
                    plural,
                    delegate(PluralFormsNode node)
                {
                    tracer.Text.AppendFormat("{0}: ", tracer.Level++);
                    tracer.Indent();
                    tracer.Text.AppendLine(node.ToString());
                },
                    delegate(PluralFormsNode node)
                {
                    tracer.Level--;
                }
                    );
                tracer.SaveToFile(fileName);
            }
        }
Beispiel #3
0
 /// <summary>
 /// Evaluate the specified number, returns msgstr index.
 /// </summary>
 /// <param name='n'>
 /// Number to evaluate
 /// </param>
 /// <param name='traceToFile'>
 /// Debug purposes only. Trace to file an evaluation tree.
 /// </param>
 public long Evaluate(long n, bool traceToFile)
 {
     if (plural == null) {
         return 0;
     }
     #if DEBUG
     RecursiveTracer tracer = new RecursiveTracer();
     tracer.Text.AppendFormat("Expression: {0}", expression);
     tracer.Text.AppendLine();
     tracer.Text.AppendFormat("Evaluate: {0}", n);
     tracer.Text.AppendLine();
     tracer.Text.AppendLine();
     #endif
     long number = plural.Evaluate(n);
     #if DEBUG
     PluralFormsNode.IterateNodes(
         plural,
         delegate(PluralFormsNode node)
         {
             tracer.Text.AppendFormat("{0}: ", tracer.Level++);
             tracer.Indent();
             if (node.Tracer != null)
                 tracer.Text.AppendLine(node.Tracer.Text.ToString());
         },
         delegate(PluralFormsNode node)
         {
             tracer.Level--;
         }
     );
     if (traceToFile)
         tracer.SaveToFile("Evaluations.txt");
     #endif
     if (number < 0 || number > nplurals) {
         return 0;
     }
     return number;
 }
Beispiel #4
0
        public void DumpNodes(string fileName)
        {
            if (plural != null)
            {
                RecursiveTracer tracer = new RecursiveTracer();
                tracer.Text.Append(expression);
                tracer.Text.AppendLine();

                PluralFormsNode.IterateNodes(
                    plural,
                    delegate(PluralFormsNode node)
                    {
                        tracer.Text.AppendFormat("{0}: ", tracer.Level++);
                        tracer.Indent();
                        tracer.Text.AppendLine(node.ToString());
                    },
                    delegate(PluralFormsNode node)
                    {
                        tracer.Level--;
                    }
                );
                tracer.SaveToFile(fileName);
            }
        }