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; }
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; }
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 }
public void printMatrix() { SnailMatrix.printMatrix(this.arr); }
public void printInSnailWay() { SnailMatrix.snailAlgorithm(this.arr, SnailMatrix.printInSnailWay); }
public void fillInSnailWay() { this.arr = SnailMatrix.snailAlgorithm(this.arr, SnailMatrix.fillMatrix); }