static void Main(string[] args) { MyLibrary myLibrary = new MyLibrary(); myLibrary.myArray = new int[6, 6]; Random rd = new Random(); for (int i = 0; i < 6; i++) { for (int j = 0; j < 6; j++) { myLibrary.myArray[i, j] = rd.Next(0, 9); Console.Write(myLibrary.myArray[i, j]); } Console.WriteLine(); } Console.WriteLine(); int[,] arr = new int[2, 2]; for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { arr[i, j] = rd.Next(0, 9); Console.Write(arr[i, j]); } Console.WriteLine(); } Console.WriteLine(myLibrary.isLocatedIn(arr)); Console.ReadLine(); }
public Book ChangeLibrary(Book book) { using (IDbConnection dbConnection = conn) { dbConnection.Open(); MyLibrary library = dbConnection.Query <MyLibrary>("SELECT * From librarydatabases where libraryid=" + book.myLibrary.libraryid).FirstOrDefault(); Book temp = new Book(); if (library == null) { temp.bookid = -1; temp.myLibrary.libraryid = book.myLibrary.libraryid; return(temp); } if (library.libraryid == book.myLibrary.libraryid) { temp.bookid = -2; return(temp); } dbConnection.Query("UPDATE books SET libraryid=" + book.myLibrary.libraryid + " WHERE books.bookid = @bookid", book); dbConnection.Close(); } return(FindByID(book.bookid)); }
// Constructor requires a source to be parsed. // All objects declared above are created. public Parser(TextReader source) { if (source == null) { throw new ArgumentNullException("source"); } fLexicalAnalyser = new LexicalAnalyser(source); fPortmap = new PortClause(null, null); lib = new MyLibrary(); ConstantList = new List <ConstantDeclaration> (); SubtypeList = new List <SubtypeDeclaration> (); ArrayTypeList = new List <ArrayTypeDeclaration> (); EnumerationTypeList = new List <EnumerationTypeDeclaration> (); RecordTypeList = new List <RecordTypeDeclaration> (); ConstantRecordTypeList = new List <RecordTypeDeclaration> (); // First token is read to commence the parsing processs. ReadNextToken(); }
public async Task <IActionResult> Index() { var httpClient = new HttpClient(); var res = await httpClient.GetAsync("http://dbservice:5001/api/values"); var strRes = await res.Content.ReadAsStringAsync(); var longVal = long.Parse(strRes); if (!CurrencyRates.HasValue) { var startStr = DateTime.Now.AddDays(-30).ToString("yyyy-MM-dd"); var endStr = DateTime.Now.ToString("yyyy-MM-dd"); var currencyConv = await httpClient.GetAsync( $"https://api.exchangeratesapi.io/history?start_at={startStr}&end_at={endStr}&symbols=USD"); var strCurrencyRes = await currencyConv.Content.ReadAsStringAsync(); var historicalData = ParseHistoricalValues(strCurrencyRes); var averageRate = new MyLibrary().CalculateAverage(historicalData); ViewData["retVal"] = $"{longVal} EUR is {averageRate * longVal} USD"; CurrencyRates = averageRate; } else { Agent.Tracer.CurrentTransaction.CaptureSpan("ReadCurrencyRateFromCache", "SuuperDuuperCache", () => { ViewData["retVal"] = $"{longVal} EUR is {CurrencyRates.Value * longVal} USD"; }); } return(View()); }
public Book modify(Book book) { IEnumerable <BookAuthor> bookAuthorsMapping = conn.Query <BookAuthor>("select * from bookauthors where bookauthors.bookid=" + book.bookid); List <long> authorIDList = new List <long>(); foreach (BookAuthor bookAuthor in bookAuthorsMapping) { authorIDList.Add(bookAuthor.authorid); } IEnumerable <Author> authorObjects = null; List <Author> tempList = new List <Author>(); foreach (long id in authorIDList) { List <Author> bObjects = conn.Query <Author>("select * from authors where authorid=" + id).ToList(); tempList.AddRange(bObjects); } authorObjects = tempList; List <BookAuthor> modifiedBookAuthors = new List <BookAuthor>(); foreach (Author eachAuthor in authorObjects) { BookAuthor temp = new BookAuthor(); temp.author = eachAuthor; //temp.authorid = eachAuthor.authorid; //temp.bookid = book.bookid; modifiedBookAuthors.Add(temp); } IEnumerable <BookAuthor> bookAuthorObjects = modifiedBookAuthors; book.bookauthor = bookAuthorObjects; List <Book> targetLibraryIdList = conn.Query <Book>("select libraryid from books where books.bookid = " + book.bookid + " and libraryid IS NOT NULL").ToList(); MyLibrary existingLibrary = null; if (targetLibraryIdList.Count() != 0) { long targetLibraryId = conn.Query <long>("select libraryid from books where books.bookid=" + book.bookid).FirstOrDefault(); existingLibrary = conn.Query <MyLibrary>("select * from librarydatabases where libraryid=" + targetLibraryId).FirstOrDefault(); } book.myLibrary = existingLibrary; Book myBook = conn.Query <Book>("select * from books where books.bookid = " + book.bookid).FirstOrDefault(); Console.WriteLine(" myBook.checkedoutstatus = " + myBook.checkedoutstatus); book.patron = null; if (myBook.checkedoutstatus.Equals("true")) { long targetPatronId = conn.Query <long>("select patronid from books where books.bookid = " + book.bookid).FirstOrDefault(); Patron existingPatron = conn.Query <Patron>("select * from patrons where patronid=" + targetPatronId).FirstOrDefault(); book.patron = existingPatron; } return(book); }
public IActionResult Update(long idLibrary, [FromBody] MyLibrary item) { if (item == null || item.libraryid != idLibrary) { return(BadRequest()); } var libraryToUpdate = libraryRepository.FindByID(idLibrary); if (libraryToUpdate == null) { return(NotFound("Could not find library with id : " + idLibrary + ". Please try again with valid id.")); } libraryToUpdate.libraryname = item.libraryname; libraryToUpdate.libraryaddress = item.libraryaddress; libraryToUpdate.libraryphone = item.libraryphone; var libraryUpdated = libraryRepository.Update(libraryToUpdate); if (libraryUpdated == null) { return(StatusCode(500, "Could not update author with id : " + idLibrary + " successfully. Please try again.")); } return(Ok("Library id : " + libraryUpdated.libraryid + " updated successfully")); }
public IActionResult RemoveAuthorFromBook(long idLibrary, [FromBody] MyLibrary item) { if (item == null || item.libraryid != idLibrary) { return(BadRequest()); } var library = libraryRepository.FindByID(idLibrary); if (library == null) { return(NotFound("Could not find book with id : " + idLibrary + ". Please try again with valid id.")); } library.myBooks = item.myBooks; MyLibrary updatedLibrary = libraryRepository.RemoveBookFromLibrary(library); if (updatedLibrary.libraryid == -1) { return(NotFound("Invalid author id : " + updatedLibrary.libraryname + ". Please try again")); } if (updatedLibrary.libraryid == -2) { return(NotFound("Book id : " + updatedLibrary.libraryname + " is not present in mentioned library. Please try again by removing that id")); } if (updatedLibrary.libraryid == -3) { return(NotFound("Book id : " + updatedLibrary.libraryname + " is present in another library. \nPlease try again with correct id")); } return(CreatedAtRoute("RemoveBookFromLibrary", new { idLibrary = idLibrary }, updatedLibrary)); }
public IActionResult AddBookToLibrary(long idLibrary, [FromBody] MyLibrary item) { if (item == null || item.libraryid != idLibrary) { return(BadRequest()); } var library = libraryRepository.FindByID(idLibrary); if (library == null) { return(NotFound("Could not find library with id : " + idLibrary + ". Please try again with valid id.")); } library.myBooks = item.myBooks; MyLibrary updatedLibrary = libraryRepository.AddBookToLibrary(library); if (updatedLibrary.libraryid == -1) { return(NotFound("Invalid book id : " + updatedLibrary.libraryname + ". Please try again")); } if (updatedLibrary.libraryid == -2) { return(NotFound("Book id : " + updatedLibrary.libraryname + " already present in same library. Please try again by removing that id")); } if (updatedLibrary.libraryid == -3) { return(NotFound("Book id : " + updatedLibrary.libraryname + " is present in another library. \nPlease use ChangeLibrary endpoint if you want to move book to another library")); } return(CreatedAtRoute("AddBookToLibrary", new { idLibrary = idLibrary }, updatedLibrary)); }
private void MoveWalls(Direction direction) { var move = Vector3.zero; float gameSpeedExp = MyLibrary.LinearToExponential(0, 1f, 10, PMWrapper.speedMultiplier); if (direction == Direction.Up) { move = Vector3.up * Time.deltaTime * gameSpeedExp * WallSpeed; } else if (direction == Direction.Down) { move = Vector3.down * Time.deltaTime * gameSpeedExp * WallSpeed; } Walls.transform.Translate(move); if (direction == Direction.Up && Walls.transform.localPosition.z > 0.2f) { isRasingWalls = false; isCharging = true; } else if (direction == Direction.Down && Walls.transform.localPosition.z < -0.3f) { isLoweringWalls = false; PMWrapper.UnpauseWalker(); } }
public async Task <IActionResult> Index() { var httpClient = new HttpClient(); var res = await httpClient.GetAsync("http://localhost:5001/api/values"); var strRes = await res.Content.ReadAsStringAsync(); var longVal = long.Parse(strRes); var startStr = DateTime.Now.AddDays(-30).ToString("yyyy-MM-dd"); var endStr = DateTime.Now.ToString("yyyy-MM-dd"); var currencyConv = await httpClient.GetAsync( $"https://api.exchangeratesapi.io/history?start_at={startStr}&end_at={endStr}&symbols=USD"); var strCurrencyRes = await currencyConv.Content.ReadAsStringAsync(); var historicalData = ParseHistoricalValues(strCurrencyRes); var averageRate = new MyLibrary().CalculateAverage(historicalData); ViewData["retVal"] = $"{longVal} EUR is {averageRate * longVal} USD"; CurrencyRate = averageRate; return(View()); }
private void btnconferma_Click(object sender, EventArgs e) { if (MyLibrary.Posizione(farmaci, num, txbcodice.Text) == -1) { farmaci[num] = new Farmaco { categoria = txbtipologia.Text, codice = txbcodice.Text, descrizione = txbdescrizione.Text, età = int.Parse(txbanni.Text), nome = txbnome.Text, prezzo = decimal.Parse(txbprezzo.Text), quantità = int.Parse(txbquantita.Text), scadenza = DateTime.Parse(txbdata.Text) }; num++; } else { farmaci[MyLibrary.Posizione(farmaci, num, txbcodice.Text)] = new Farmaco { categoria = txbtipologia.Text, codice = txbcodice.Text, descrizione = txbdescrizione.Text, età = int.Parse(txbanni.Text) * int.Parse(txbmesi.Text), nome = txbnome.Text, prezzo = decimal.Parse(txbprezzo.Text), quantità = int.Parse(txbquantita.Text), scadenza = DateTime.Parse(txbdata.Text) }; } Clean(this); }
private void cmdAnalysis_Click(object sender, EventArgs e) { this.lstAnalysis.Items.Clear(); var N = MyLibrary.NumScores(scores); var Min = MyLibrary.FindMin(scores); var Max = MyLibrary.FindMax(scores); var Avg = MyLibrary.Average(scores); var Median = MyLibrary.Median(scores); var StdDev = MyLibrary.StdDev(scores); this.lstAnalysis.Items.Add("N: " + N); this.lstAnalysis.Items.Add("Min: " + Min); this.lstAnalysis.Items.Add("Max: " + Max); this.lstAnalysis.Items.Add("Avg: " + Avg); this.lstAnalysis.Items.Add("Median: " + Median); this.lstAnalysis.Items.Add("StdDev: " + StdDev); var Histogram = MyLibrary.Histogram(scores); this.lstAnalysis.Items.Add("Histogram:"); this.lstAnalysis.Items.Add(" 90-100: " + Histogram.ElementAt(0)); this.lstAnalysis.Items.Add(" 80-89: " + Histogram.ElementAt(1)); this.lstAnalysis.Items.Add(" 70-79: " + Histogram.ElementAt(2)); this.lstAnalysis.Items.Add(" 60-69: " + Histogram.ElementAt(3)); this.lstAnalysis.Items.Add(" 0-59: " + Histogram.ElementAt(4)); }
private void MakeSelection() { Console.WriteLine("Please choose between the following: (C)heckout, (R)eturn a book, or (Q)uit"); string input = Console.ReadLine(); switch (input.ToLower()) { case "c": MyLibrary.CheckoutBook(); break; case "r": MyLibrary.ReturnBook(); break; case "q": Running = false; Console.WriteLine("Thanks for visiting!"); Console.ReadLine(); break; default: Console.WriteLine("Invalid Selection"); break; } }
private void cmdTrend_Click(object sender, EventArgs e) { this.lstTrend.Items.Clear(); string folder = this.txtFolderPath.Text; string filepath1 = System.IO.Path.Combine(folder, "Exam01.txt"); string filepath2 = System.IO.Path.Combine(folder, "Exam02.txt"); string filepath3 = System.IO.Path.Combine(folder, "Exam03.txt"); var L1 = MyLibrary.InputScores(filepath1); var L2 = MyLibrary.InputScores(filepath2); var L3 = MyLibrary.InputScores(filepath3); var R = MyLibrary.Trend(L1, L2, L3); int i = 0; foreach (var trend in R) { var s = string.Format("{0},{1},{2}: {3}", L1.ElementAt(i), L2.ElementAt(i), L3.ElementAt(i), trend); this.lstTrend.Items.Add(s); i++; } }
public Game1() { myLibrary = new MyLibrary(); graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; this.IsFixedTimeStep = true; game = new GameManager(); }
// Sorting protected void gvAdmin_Sorting(object sender, GridViewSortEventArgs e) { string sortExpression = e.SortExpression; //Tên cột string direction = MyLibrary.GetSortDirection(); //Chiều (lấy theo viewstate) var rs = mstr.Get_Admin_Info().OrderBy(sortExpression + direction).ToList(); gvAdmin.DataSource = rs.ToList(); gvAdmin.DataBind(); }
private void mnuClientIP_Click(object sender, EventArgs e) { string str = MyLibrary.GetInput("Client IP Address"); if (str != "") { cAddress = str; } }
/// <summary> /// Instancie et ouvre une AddSongWindow /// Un fois AddSongWindow fermée ajoute une musique à la librairie si son nom a été renseigné dans AddSongWindow /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAdd_Click(object sender, RoutedEventArgs e) { AddSongWindow = new AddSongWindow(); AddSongWindow.ShowDialog(); if (AddSongWindow.Name != null) { MyLibrary.AddSong(AddSongWindow.SaveSong); } }
public void Area_Circle_10() { double x = 10; double expected = 314; MyLibrary c = new MyLibrary(); double actual = c.Area(x); Assert.AreEqual(expected, actual); }
private void radioButton3_CheckedChanged(object sender, EventArgs e) { if (radioButton3.Checked) { radioButton5.Checked = false; radioButton2.Checked = false; radioButton1.Checked = false; } MyLibrary.OrdinaQC(farmaci, num); MyLibrary.Aggiorna(farmaci, num, listView1); }
public void Area_Triangle_9_4_5() { double x = 9; double y = 4; double z = 5; double expected = 0; MyLibrary a = new MyLibrary(); double actual = a.Area(x, y, z); Assert.AreEqual(expected, actual); }
static unsafe void Main(string[] args) { int x, y; x = 5; y = 6; MyLibrary.Swap(&x, &y); MyLibrary.Inc(&x); Console.WriteLine("x = {0}, y = {1}", x, y); }
private void btncancella_Click(object sender, EventArgs e) { try { MyLibrary.Cancella(farmaci, ref num, listView1.SelectedItems[0].SubItems[0].Text); } catch { MessageBox.Show("Seleziona un prodotto"); } MyLibrary.Aggiorna(farmaci, num, listView1); }
public Author Modify(Author author) { IEnumerable <BookAuthor> bookAuthorsMapping = conn.Query <BookAuthor>("select * from bookauthors where bookauthors.authorid=" + author.authorid); List <long> bookIDList = new List <long>(); foreach (BookAuthor bookAuthor in bookAuthorsMapping) { bookIDList.Add(bookAuthor.bookid); } IEnumerable <Book> bookObjects = null; List <Book> tempList = new List <Book>(); foreach (long id in bookIDList) { List <Book> bObjects = conn.Query <Book>("select * from books where bookid=" + id).ToList(); tempList.AddRange(bObjects); } bookObjects = tempList; List <BookAuthor> modifiedBookAuthors = new List <BookAuthor>(); foreach (Book eachBook in bookObjects) { BookAuthor temp = new BookAuthor(); List <Book> targetLibraryIdList = conn.Query <Book>("select libraryid from books where books.bookid = " + eachBook.bookid + " and libraryid IS NOT NULL").ToList(); MyLibrary existingLibrary = null; if (targetLibraryIdList.Count() != 0) { long targetLibraryId = conn.Query <long>("select libraryid from books where books.bookid=" + eachBook.bookid).FirstOrDefault(); existingLibrary = conn.Query <MyLibrary>("select * from librarydatabases where libraryid=" + targetLibraryId).FirstOrDefault(); } eachBook.myLibrary = existingLibrary; if (eachBook.checkedoutstatus.Equals("true")) { long patronID = conn.Query <long>("select patronid from books where books.bookid=" + eachBook.bookid).FirstOrDefault(); Patron myPatron = conn.Query <Patron>("select * from patrons where patronid=" + patronID).FirstOrDefault(); eachBook.patron = myPatron; } temp.book = eachBook; //temp.bookid = eachBook.bookid; //temp.authorid = author.authorid; modifiedBookAuthors.Add(temp); } IEnumerable <BookAuthor> bookAuthorObjects = modifiedBookAuthors; author.bookauthor = bookAuthorObjects; return(author); }
private void Srl_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e) { string myquery = srlPort.srl.ReadExisting(); txtQuery.Text = myquery; prg1.Visible = true; string response = MyLibrary.Decode(myquery, srlPort.srl.PortName); prg1.Visible = false; txtQueryElaborata.Text = response; srlPort.Write(response); }
static void Main(string[] args) { // Create a library object and use its methods. MyLibrary ml = new MyLibrary(); ml.LibraryFunction1(); // Call its static functions through the class. int result = MyLibrary.LibraryFunction2(27); Console.WriteLine(result.ToString()); // Wait for user to acknowledge the results. Console.WriteLine("Press Enter to terminate..."); Console.Read(); }
internal void Reset() { PriorityPlayer = 0; MyLibrary.ResetCards(); OpponentCardsSeen.ResetCards(); MySideboard.ResetCards(); //FullDeck.ResetCards(); TimerMe.Reset(); TimerOpponent.Reset(); // notify that everything changed RaisePropertyChangedEvent(string.Empty); }
public void Reflection() { // Create a library of helper function var lib = new MyLibrary(); lib.r = 10; // Create a context that uses the library var ctx = new ReflectionContext(lib); // Test Assert.AreEqual(Parser.Parse("rectArea(10,20)").Eval(ctx), 200); Assert.AreEqual(Parser.Parse("rectPerimeter(10,20)").Eval(ctx), 60); Assert.AreEqual(Parser.Parse("2 * pi * r").Eval(ctx), 2 * Math.PI * 10); }
void Update() { float gameSpeedExp = MyLibrary.LinearToExponential(0, 0.5f, 5, PMWrapper.speedMultiplier); if (IsUnloading && !PMWrapper.IsCompilerUserPaused) { transform.Translate(-transform.up * UnloadingSpeed * gameSpeedExp); } if (transform.position.y > 7) { PMWrapper.UnpauseWalker(); Destroy(gameObject); } }
private void btncerca_Click(object sender, EventArgs e) { int newNum = 0; Farmaco[] newFarmaci = new Farmaco[arraySize]; for (int i = 0; i < num; i++) { if (farmaci[i].codice.Contains(txbcerca.Text)) { newFarmaci[newNum] = farmaci[i]; newNum++; } } MyLibrary.Aggiorna(newFarmaci, newNum, listView1); }