Esempio n. 1
0
        public SelectOutput(string selectParam, DeclarationsArray declarationsArray)
        {
            SuchThat suchThat = new SuchThat(declarationsArray);

            SelectParam = selectParam;

            queryResults = new List <MethodResultList>();
            //validation completed
            foreach (var methodToDo in SuchThatValidator.GetMethodsToDo())
            {
                queryResults.Add(suchThat.DoSuchThatMethod(methodToDo.MethodName, methodToDo.Param1, methodToDo.Param2));
            }

            //foreach (var qr in queryResults)
            //{
            //    Console.WriteLine($"\n{qr.ListType1}\t{qr.ListType2}");
            //    for (int i = 0; i < qr.List1.Count; i++)
            //    {
            //        Console.WriteLine($"{((AbstractAuxiliaryGrammar) qr.List1[i]).entry}\t{((AbstractAuxiliaryGrammar) qr.List2[i]).entry}");
            //    }
            //}


            ResultTableRelations resultTableRelations = new ResultTableRelations();

            for (int i = 0; i < queryResults.Count; i++)
            {
                MethodResultList qr = queryResults[i];

                if (qr.ListType1 == typeof(Ident))
                {
                    if (qr.ListType2 == typeof(Ident))
                    {
                        resultTableRelations.AddRelation(qr.QueryParam1, qr.QueryParam2, i);
                    }
                    else //qr.ListType2 == typeof(Ident)
                    {
                        resultTableRelations.AddRelation(qr.QueryParam1, i);
                    }
                }
                else //qr.ListType1 != typeof(Ident)
                {
                    if (qr.ListType2 == typeof(Ident))
                    {
                        resultTableRelations.AddRelation(qr.QueryParam2, i);
                    }
                    else //qr.ListType2 != typeof(Ident)
                    {
                        resultTableRelations.AddRelation(qr.QueryParam2, qr.QueryParam1, i);
                    }
                }
            }

            MergedResultTableRelations mergedResultTableRelations = new MergedResultTableRelations(resultTableRelations);

            StackList = mergedResultTableRelations.ExecuteAllMerges(selectParam);
        }
Esempio n. 2
0
 private void ProductOfSets(MethodResultList set, MethodResultList restrictingSet)
 {
     if (set.QueryParam1 == restrictingSet.QueryParam1)
     {
         for (int i = 0; i < set.List1.Count; i++)
         {
             bool exist = false;
             foreach (AbstractAuxiliaryGrammar tmp in restrictingSet.List1)
             {
                 if (tmp.entry == ((AbstractAuxiliaryGrammar)set.List1[i]).entry)
                 {
                     exist = true;
                     break;
                 }
             }
             if (!exist)
             {
                 set.List1.RemoveAt(i);
                 set.List2.RemoveAt(i);
                 i--;
             }
         }
     }
     else if (set.QueryParam1 == restrictingSet.QueryParam2)
     {
         for (int i = 0; i < set.List1.Count; i++)
         {
             bool exist = false;
             foreach (AbstractAuxiliaryGrammar tmp in restrictingSet.List2)
             {
                 if (tmp.entry == ((AbstractAuxiliaryGrammar)set.List1[i]).entry)
                 {
                     exist = true;
                     break;
                 }
             }
             if (!exist)
             {
                 set.List1.RemoveAt(i);
                 set.List2.RemoveAt(i);
                 i--;
             }
         }
     }
     else if (set.QueryParam2 == restrictingSet.QueryParam1)
     {
         for (int i = 0; i < set.List2.Count; i++)
         {
             bool exist = false;
             foreach (AbstractAuxiliaryGrammar tmp in restrictingSet.List1)
             {
                 if (tmp.entry == ((AbstractAuxiliaryGrammar)set.List2[i]).entry)
                 {
                     exist = true;
                     break;
                 }
             }
             if (!exist)
             {
                 set.List1.RemoveAt(i);
                 set.List2.RemoveAt(i);
                 i--;
             }
         }
     }
     else if (set.QueryParam2 == restrictingSet.QueryParam2)
     {
         for (int i = 0; i < set.List2.Count; i++)
         {
             bool exist = false;
             foreach (AbstractAuxiliaryGrammar tmp in restrictingSet.List2)
             {
                 if (tmp.entry == ((AbstractAuxiliaryGrammar)set.List2[i]).entry)
                 {
                     exist = true;
                     break;
                 }
             }
             if (!exist)
             {
                 set.List1.RemoveAt(i);
                 set.List2.RemoveAt(i);
                 i--;
             }
         }
     }
 }