/// <summary>
 /// Finds out a category of an expression
 /// To be precise, finds out whether expr belongs to cat
 /// </summary>
 /// <param name="expr"></param>
 /// <param name="cat"></param>
 /// <returns></returns>
 private static bool Contains(Entity expr, FunctionCategory cat)
 {
     if (cat.Contains(expr.Name))
     {
         return(true);
     }
     foreach (var child in expr.Children)
     {
         if (Contains(child, cat))
         {
             return(true);
         }
     }
     return(false);
 }
Beispiel #2
0
        public bool SupportCategory(FunctionScenarioType type, FunctionCategory category)
        {
            if (type == FunctionScenarioType.Unspecified)
            {
                return(true);
            }
            FunctionCategory[] categories = null;
            switch (type)
            {
            case FunctionScenarioType.Unspecified:
                categories = new FunctionCategory[] {
                };
                break;

            case FunctionScenarioType.Router:
                categories = new FunctionCategory[] {
                    FunctionCategory.Math,
                    FunctionCategory.Text,
                    FunctionCategory.Time,
                    FunctionCategory.Logic,
                    FunctionCategory.Organization,
                    FunctionCategory.Other
                };
                break;

            case FunctionScenarioType.Computation:
                categories = new FunctionCategory[] {
                    FunctionCategory.Math,
                    FunctionCategory.Text,
                    FunctionCategory.Time,
                    FunctionCategory.Logic,
                    FunctionCategory.Other
                };
                break;

            case FunctionScenarioType.Submit:
                categories = new FunctionCategory[] {
                    FunctionCategory.Math,
                    FunctionCategory.Text,
                    FunctionCategory.Time,
                    FunctionCategory.Logic,
                    FunctionCategory.Organization,
                    FunctionCategory.Other
                };
                break;

            case FunctionScenarioType.Business:
                categories = new FunctionCategory[] {
                    FunctionCategory.Math,
                    FunctionCategory.Time,
                    FunctionCategory.Logic,
                    FunctionCategory.BackMethod,
                    FunctionCategory.Other
                };
                break;

            case FunctionScenarioType.AssociationFilter:
                categories = new FunctionCategory[] {
                    FunctionCategory.Math,
                    FunctionCategory.Text,
                    FunctionCategory.Time,
                    FunctionCategory.Logic,
                    FunctionCategory.Other
                };
                break;

            case FunctionScenarioType.ReportSource:
                categories = new FunctionCategory[] {
                    FunctionCategory.Time,
                    FunctionCategory.Logic
                };
                break;

            default:
                categories = new FunctionCategory[] { };
                break;
            }
            return(categories.Contains(category));
        }