예제 #1
0
        static void Main(string[] args)
        {
            int sizeOfArr = SnailMatrix.setValidLength();

            int[,] arr = new int[sizeOfArr, sizeOfArr];

            arr = SnailMatrix.snailAlgorithm(arr, SnailMatrix.fillMatrix);
            Console.WriteLine("\nMatrix: ");
            SnailMatrix.printMatrix(arr);

            Console.WriteLine("\n\nReading a matrix in <snail> way: ");
            arr = SnailMatrix.snailAlgorithm(arr, SnailMatrix.printSnailedMatrix);

            Console.WriteLine("\n\nPress any key to exit.");
            Console.ReadKey(true);
            return;
        }
예제 #2
0
        static void Main(string[] args)
        {
            SnailMatrix.readFromDB();

            SnailMatrix sm = new SnailMatrix(SnailMatrix.setValidSize());

            sm.fillInSnailWay();
            Console.WriteLine("\nMatrix: ");
            sm.printMatrix();

            Console.WriteLine("\nReading a matrix in <snail> way: ");
            sm.printInSnailWay();

            sm.writeToDB();

            Console.WriteLine("\n\nPress any key to exit.");
            Console.ReadKey(true);
            return;
        }
예제 #3
0
        public static List <SnailMatrix> readFromDB()
        {
            Console.WriteLine("Reading from database...");
            using (var db = new SnailContext())
            {
                var prevSnails = db.Snails.OrderByDescending(c => c.Id).ToList();
                int counter    = 0;

                if (prevSnails.Any(o => o.Id != null))
                {
                    foreach (var elem in prevSnails)
                    {
                        if (counter++ >= 5)
                        {
                            break;
                        }
                        Console.WriteLine("result #" + elem.Id + ": " + elem.snailedArrayString);
                    }
                }
                else
                {
                    SnailMatrix[] sm = new SnailMatrix[3];
                    for (int i = 0; i < sm.Length; i++)
                    {
                        sm[i] = new SnailMatrix();
                        sm[i].snailedArrayString = "test string for first load";
                    }
                    db.Snails.AddRange(sm);
                    db.SaveChanges();

                    Console.WriteLine("Database is empty!");
                }
                Console.WriteLine();
                return(prevSnails);
            }
            //return false;//for future
        }
예제 #4
0
 public void printMatrix()
 {
     SnailMatrix.printMatrix(this.arr);
 }
예제 #5
0
 public void printInSnailWay()
 {
     SnailMatrix.snailAlgorithm(this.arr, SnailMatrix.printInSnailWay);
 }
예제 #6
0
 public void fillInSnailWay()
 {
     this.arr = SnailMatrix.snailAlgorithm(this.arr, SnailMatrix.fillMatrix);
 }