Exemplo n.º 1
0
 public ViewScanner(DataModel model)
 {
     Model = model;
 }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            var dataModel = new DataModel();

            dataModel.Build <SchoolContext>();
            for (int index = 0; index < dataModel.Entities.Count; index++)
            {
                string fill;
                if (dataModel.Entities[index].Name.Length < 8)
                {
                    fill = "\t";
                }
                else
                {
                    fill = "";
                }
                Console.Write($"{dataModel.Entities[index].Name}{fill}\t " + " { ");
                dataModel.NavigationRelations[index].ForEach(x => Console.Write($"{x.Name}, "));
                Console.WriteLine(" }");
            }
            var matrix = new List <List <string> >
            {
                new List <string> {
                    "one", "two", "three"
                },
                new List <string> {
                    "five", "six", "seven"
                },
                new List <string> {
                    "seven", "six", "five"
                },
                new List <string> {
                    "two", "three"
                },
                new List <string> {
                    "three", "four", "five"
                },
                new List <string> {
                    "two", "three", "four", "five"
                },
                new List <string> {
                    "three", "two"
                },
                new List <string> {
                    "four", "three", "two"
                },
                new List <string> {
                    "four", "three", "one"
                },
                new List <string> {
                    "five", "four", "three"
                },
                new List <string> {
                    "five", "four", "three", "one"
                },
                new List <string> {
                    "five", "four", "three", "two", "one", "zero"
                },
                new List <string> {
                    "six", "five", "four", "three", "two", "one"
                },
            };
            var List = new List <string> {
                "two", "three", "four", "five", "six"
            };

            int counter = -1;

            foreach (var row in matrix)
            {
                counter++;
                if (row.Count <= List.Count)
                {
                    if (row.IsSubsetOf(List))
                    {
                        continue;
                    }
                    FindMatch(row, List);
                }
                else
                {
                    if (List.IsSubsetOf(row))
                    {
                        Console.WriteLine("List = row");
                        continue;
                    }
                    FindMatch(List, row);
                }
                Console.WriteLine("--------------------------------------");
            }

            void FindMatch(List <string> row, List <string> List)
            {
                row.Print();
                int  matchIndex   = 0;
                bool PartialMatch = false;

                for (int i = 1; i < row.Count; i++)
                {
                    if (List.StartsOrEndsWith(row.GetRange(i, row.Count - i)))
                    {
                        matchIndex = i;     //TODO make function that deals with match & partial match
                        row.Print();        //      match -> largest list survives, partial -> concat
                        PartialMatch = true;
                        break;
                    }
                    row.Reverse();
                    if (List.StartsOrEndsWith(row.GetRange(i, row.Count - i)))
                    {
                        matchIndex = i;
                        row.Print();
                        PartialMatch = true;
                        break;
                    }
                }
                if (PartialMatch)
                {
                    Console.WriteLine($"row {counter} has partial match at index {matchIndex}");
                }
            }
        }