private static bool ValidSchema(Schema schema, Couple couple) { List <Couple> metCouples = new List <Couple>(); for (int i = 0; i < schema.Courses.Length; i++) { Meal meal = schema.Courses[i].GetMealForCouple(couple); if (meal == null) { throw new Exception("Cannot locate couple in a course."); } foreach (Couple otherCouple in meal.Couples) { if (otherCouple == null) { continue; } if (couple == otherCouple) { continue; } if (metCouples.Any(o => o == otherCouple)) { return(false); } metCouples.Add(otherCouple); } } return(true); }
public static Couple Make(string raw) { Couple result = new Couple(); if (string.IsNullOrEmpty(raw)) { return(result); } // 移除头尾的[] raw = raw.Remove(0, 1); raw = raw.Remove(raw.Length - 1, 1); string[] rawResults = raw.Split(','); if (rawResults.Length >= 1) { result.RawA = rawResults[0]; uint.TryParse(rawResults[0], out result.ParameterA); } if (rawResults.Length >= 2) { result.RawB = rawResults[1]; uint.TryParse(rawResults[1], out result.ParameterB); } return(result); }
public Packet(string Left, object Right, Sign sign, Couple couple = Couple.None) { this.Left = Left; this.Right = Right; this.Sign = sign; this.Couple = couple; }
public void Remove(T point) { Couple <int, T> cPoint = GetCouple(point); adjencyList.RemoveAt(cPoint.Key); data.Remove(cPoint); }
private void CreerOuiNonBoutons() { Couple position = new Couple( ClientSize.Width / 4 - _tailleBouton.Xi / 2, ClientSize.Height - _tailleBouton.Yi - 15 ); FlatButton bouton = CreerBouton(position, @"Oui"); bouton.Click += (sender, args) => { _resultat = DialogResult.Yes; Action_Fermeture(sender, args); }; position = new Couple( ClientSize.Width * 3 / 4 - _tailleBouton.Xi / 2, ClientSize.Height - _tailleBouton.Yi - 15 ); bouton = CreerBouton(position, @"Non"); bouton.Click += (sender, args) => { _resultat = DialogResult.No; Action_Fermeture(sender, args); }; }
protected override async Task <AuthenticateResult> HandleAuthenticateAsync() { string adminCode = TryGetAdminCode(); int? coupleId = TryGetCoupleId(); if (adminCode == null || coupleId == null) { return(await Task.FromResult(AuthenticateResult.NoResult())); } Couple couple = await Db.Couples.FindAsync(coupleId.Value); if (couple == null) { return(await Task.FromResult(AuthenticateResult.Fail("Not found"))); } if (couple.AdminCode != adminCode) { return(await Task.FromResult(AuthenticateResult.Fail("Admincode is incorrect."))); } var claims = new[] { new Claim(ClaimTypes.NameIdentifier, coupleId.ToString()), new Claim(ClaimTypes.Role, couple.IsAdmin ? "Admin" : "User"), }; var identity = new ClaimsIdentity(claims, Scheme.Name); var principal = new ClaimsPrincipal(identity); var ticket = new AuthenticationTicket(principal, Scheme.Name); return(await Task.FromResult(AuthenticateResult.Success(ticket))); }
public void UnLink(T from, T to) { Couple <int, T> cFrom = GetCouple(from); Couple <int, T> cTo = GetCouple(to); adjencyList[cFrom.Key].Remove(cTo.Key); }
public async Task <IActionResult> OnGetAsync(int?IdToRemove) { if (IdToRemove == null) { return(NotFound()); } if (IdToRemove == AuthorizedID) { // Cannot remove self return(BadRequest()); } Couple adminCouple = await GetAuthorizedCouple(); if (adminCouple == null) { return(NotFound()); } Couple = await Database.GetCoupleAsync(IdToRemove.Value); if (Couple == null) { return(NotFound()); } if (Couple.Dinner.ID != adminCouple.Dinner.ID) { return(BadRequest()); } return(Page()); }
public async Task <IActionResult> OnPostAsync() { var coupleData = Couple; // Reload database Couple = await GetAuthorizedCouple(); if (!ModelState.IsValid) { return(Page()); } if (Couple.Dinner.HasPrice && string.IsNullOrEmpty(coupleData.IBAN)) { ModelState.AddModelError("IBAN", "Bankrekening is verplicht!"); return(Page()); } if (await Database.UpdateCoupleAsync(AuthorizedID, coupleData) == null) { ModelState.AddModelError("Couple", "Kan nu niet opslaan, probeer het later opnieuw."); return(Page()); } ViewData["status"] = "Wijzigingen opgeslagen!"; return(Page()); }
public async Task <IActionResult> OnGetAsync() { Couple = await GetAuthorizedCouple(); if (Couple == null) { return(NotFound()); } if (!Couple.Dinner.HasPrice) { return(Redirect(ModelPath.Get <Couples.EditCoupleModel>())); } var status = await Couple.UpdatePaymentStatus(); if (status.Changed) { await Database.SaveChangesAsync(); } PaymentStatus = status.NewStatus; return(Page()); }
/// <summary> /// Converts specified IGE challenges to DFE files /// </summary> /// <param name="igeFiles"></param> private static Couple <int> _ConvertIGEtoDFE(IGE[] igeFiles) { Couple <int> returnedCount = new Couple <int>(0, 0); if (igeFiles != null) { int totalCount = igeFiles.Length; int successCount = 0; foreach (IGE anotherIGE in igeFiles) { try { DFE convertedTrack = anotherIGE; // New file name string tracksFolder = AppConstants.FOLDER_TRACKS; //string newFileName = new FileInfo(convertedTrack.FileName).Name; string targetFileName = string.Concat(tracksFolder, @"\", DFE.FILE_DATA_DFE, File2.GetValidFileName(convertedTrack.TrackName, false) /*File2.GetNameFromFilename(newFileName)*/); convertedTrack.SaveAs(targetFileName); successCount++; } catch (Exception ex) { Log.Error("Unable to convert IGE track to DFE.", ex); } } returnedCount = new Couple <int>(successCount, totalCount); } return(returnedCount); }
private void fromTDUGenuineEditorToolStripMenuItem_Click(object sender, EventArgs e) { // Click on Import > from TDU Editor button try { Cursor = Cursors.WaitCursor; EditorTracksDialog dlg = new EditorTracksDialog(true); DialogResult dr = dlg.ShowDialog(this); if (dr == DialogResult.OK) { Couple <int> convertedCount = _ConvertIGEtoDFE(dlg.SelectedTracks); // Refresh custom tracks _RefreshCustomList(); string message = string.Format(_FORMAT_IMPORT_IGE_OK, convertedCount.FirstValue, convertedCount.SecondValue); StatusBarLogManager.ShowEvent(this, message); } } catch (Exception ex) { MessageBoxes.ShowError(this, ex); } finally { Cursor = Cursors.Default; } }
public static void Load() { ObjTemplateByMount.Clear(); StatsByMount.Clear(); var reader = DatabaseManager.Provider.ExecuteReader("SELECT * FROM static_mounts"); while (reader.Read()) { ObjTemplateByMount.Add(reader.GetInt32("id"), ItemTemplateTable.GetTemplate(reader.GetInt32("scrollID"))); try { List <Couple <int, Double> > _stats = new List <Couple <int, Double> >(); foreach (String stat in Regex.Split(reader.GetString("stats"), "\\|")) { String[] infos = stat.Split('='); Couple <int, Double> c = new Couple <int, Double>(int.Parse(infos[0]), (infos.Length > 1 ? double.Parse(infos[1], CultureInfo.InvariantCulture) : 0)); _stats.Add(c); } StatsByMount.Add(reader.GetInt32("id"), _stats); } catch (Exception e) { Logger.Error(e); } } reader.Close(); Logger.Info("Loaded @'" + ObjTemplateByMount.Count + "'@ Mount"); }
public void NothingInteresting(List <Couple> couples, string s) { Couple some = new Couple(); if (s == "П") { some.CoupleName = "Практика..."; } else if (s == "К") { some.CoupleName = "Каникулы!"; } else if (s == "Д") { some.CoupleName = "Диплом..."; } else if (s == "Н") { some.CoupleName = "Научно-исследовательская работа..."; } else if (s == "Э") { some.CoupleName = "Экзамены да зачеты..."; } else if (s == "Р") { some.CoupleName = "Рейтинги..."; } else { some.CoupleName = "Ничего интересного..."; } couples.Add(some); }
public static string SerializeAsStartFightCells(Couple <List <FightCell>, List <FightCell> > cells) { StringBuilder s_cells = new StringBuilder(); try { foreach (var cell in cells.first) { int cellID = cell.Id; int c1 = (cellID >> 6) << 6; int c2 = cellID - c1; s_cells.Append(StringHelper.IntToHash(c1 >> 6)).Append(StringHelper.IntToHash(c2)); } s_cells.Append('|'); foreach (var cell in cells.second) { int cellID = cell.Id; int c1 = (cellID >> 6) << 6; int c2 = cellID - c1; s_cells.Append(StringHelper.IntToHash(c1 >> 6)).Append(StringHelper.IntToHash(c2)); } return(s_cells.ToString()); } catch (Exception e) { return("|"); } }
public async Task <IActionResult> PutCouple([FromRoute] int id, [FromBody] Couple couple) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != couple.CoupleId) { return(BadRequest()); } _context.Entry(couple).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CoupleExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
protected override void Run() { Console.WriteLine("Matrix:"); foreach (bool[] row in wallPositions) { Console.WriteLine(row.Print()); } Console.WriteLine(); Console.WriteLine("Starting position: {0}", startPosition); Console.WriteLine("Ending position: {0}\n", endPosition); Couple <int> resultsTree = AStarTreeSearch(); int minSteps = resultsTree.First; int examinedNodes = resultsTree.Second; Console.WriteLine("Minimum number of required steps: {0}", minSteps); Console.WriteLine("Examined nodes: {0}", examinedNodes); Couple <int> resultsGraph = AStarGraphSearch(); minSteps = resultsGraph.First; examinedNodes = resultsGraph.Second; Console.WriteLine("Minimum number of required steps: {0}", minSteps); Console.WriteLine("Examined nodes: {0}", examinedNodes); }
private void créerToolStripMenuItem_Click(object sender, EventArgs e) { if (stripCopyListAnim.SelectedIndex == -1) { Program.AddAnimation(); } else { var baseAnim = Program.DynamicObject.Animations.FirstOrDefault((a) => a.Name == stripCopyListAnim.SelectedItem.ToString()); var anim = Program.DynamicObject.CreateAnimation(); foreach (var bone in baseAnim.Bones) { var couple = new Couple <Bone, List <Animation.Key> >(); couple.Key = bone.Key; couple.Value = new List <Animation.Key>(); foreach (var key in bone.Value) { var copyKey = new Animation.Key(); copyKey.Transform = new Transformable(key.Transform); copyKey.Position = key.Position; couple.Value.Add(copyKey); } anim.Bones.Add(couple); } anim.Name = "Copie de " + baseAnim.Name; anim.Duration = baseAnim.Duration; Program.selection = anim; } }
public ActionResult Create(CoupleViewModel service) { if (ModelState.IsValid) { Couple couple = new Couple(); var userId = User.Identity.GetUserId(); var applicationUser = db.Users.Where(u => u.Id == userId).Select(u => u).SingleOrDefault(); service.CoupleEmail = applicationUser.Email; string json = JsonConvert.SerializeObject(service); var response = client.PostAsync("Couples", new StringContent(json, Encoding.UTF8, "application/json")); response.Wait(); var result = response.Result; if (result.IsSuccessStatusCode) { couple.ApplicationId = User.Identity.GetUserId(); response = client.GetAsync("Couples"); response.Wait(); result = response.Result; if (result.IsSuccessStatusCode) { var read = result.Content.ReadAsStringAsync(); read.Wait(); var readResult = read.Result; JArray jObject = JArray.Parse(readResult); var lastObject = jObject.Last(); couple.CoupleId = (int)lastObject["Id"]; db.Couples.Add(couple); db.SaveChanges(); } } return(RedirectToAction("LogOut", "Account")); } return(View(service)); }
public void Shift(int whichCouple, int howMuch) { howMuch %= Meals.Length; if (howMuch < 1) { return; } // Setup an array Couple[] array = new Couple[Meals.Length]; for (int i = 0; i < Meals.Length; i++) { array[i] = Meals[i].Couples[whichCouple]; } // Break up the array Couple[] partA = new Couple[howMuch]; Couple[] partB = new Couple[Meals.Length - howMuch]; Array.Copy(array, 0, partA, 0, howMuch); Array.Copy(array, howMuch, partB, 0, Meals.Length - howMuch); // Reconstruct the array Array.Copy(partB, 0, array, 0, partB.Length); Array.Copy(partA, 0, array, partB.Length, partA.Length); // Copy the results back for (int i = 0; i < Meals.Length; i++) { Meals[i].Couples[whichCouple] = array[i]; } }
private Couple <int> GetTwoMaxValue(BinaryNode <int> root) { if (root.ChildrenCount() == 0) { return(new Couple <int>(root.Value, int.MinValue)); } SortedList <int> sortedList = new SortedList <int>(false); // Left child Couple <int> left = GetTwoMaxValue(root.Left); sortedList.Add(left.First); sortedList.Add(left.Second); // Right child if (root.ChildrenCount() == 2) { Couple <int> right = GetTwoMaxValue(root.Right); sortedList.Add(right.First); sortedList.Add(right.Second); } // Root sortedList.Add(root.Value); // Extract two max values List <int> list = sortedList.ToList(); return(new Couple <int>(list[0], list[1])); }
private void créerToolStripMenuItem2_Click(object sender, EventArgs e) { if (stripBeforeListAnim.SelectedIndex == -1) { Program.AddAnimation(); } else { var baseAnim = Program.DynamicObject.Animations.FirstOrDefault((a) => a.Name == stripBeforeListAnim.SelectedItem.ToString()); var anim = Program.DynamicObject.CreateAnimation(); foreach (var bone in baseAnim.Bones) { var couple = new Couple <Bone, List <Animation.Key> >(); couple.Key = bone.Key; couple.Value = new List <Animation.Key>(); Animation.Key firstKey = bone.Value.FirstOrDefault(); if (firstKey != null) { couple.Value.Add(new Animation.Key() { Position = Time.FromSeconds(1), Transform = new Transformable(firstKey.Transform) }); anim.Bones.Add(couple); } } anim.Name = "Avant " + baseAnim.Name; anim.Duration = Time.FromSeconds(1); Program.selection = anim; } }
// déplace à une position donnée public void Deplace(Couple positionDestination) { positionDestination.X -= position.X; positionDestination.Y -= position.Y; Deplace(positionDestination.Xi, positionDestination.Yi); }
private int GetAttackNumber(List <Couple <int> > bishopPositions) { int count = 0; List <Couple <Couple <int> > > bishopsAttaks = new List <Couple <Couple <int> > >(); int mainDiagonal, secondDiagonal; foreach (Couple <int> bishopPosition in bishopPositions) { mainDiagonal = bishopPosition.First + bishopPosition.Second; secondDiagonal = bishopPosition.First - bishopPosition.Second; bishopsAttaks.Add(new Couple <Couple <int> >(bishopPosition, new Couple <int>(mainDiagonal, secondDiagonal))); } while (bishopsAttaks.Count > 0) { Couple <Couple <int> > bishopAttak = bishopsAttaks[0]; bishopsAttaks.RemoveAt(0); foreach (Couple <Couple <int> > otherAttak in bishopsAttaks) { if (bishopAttak.Second.First == otherAttak.Second.First || // mainDiagonal bishopAttak.Second.Second == otherAttak.Second.Second) // secondDiagonal { Console.WriteLine("Bishops in {0} attaks bishop in {1}.", bishopAttak.First, otherAttak.First); count++; } } } return(count); }
public int Add(Couple couple) { var coupleSaved = weddingContext.Couples.Add(couple); weddingContext.SaveChanges(); return(coupleSaved.CoupleID); }
public IActionResult Invitation(int guestId) { if (RSVPWasAlreadyRecieved(guestId)) { return(View("RSVPAlreadySubmitted")); } var guestOne = _context.Guests.FirstOrDefault(g => g.Id == guestId); Guest guestTwo = new Guest(); if (guestOne.PartOfCouple) { Couple couple = LookupCouple(guestId); guestTwo = (couple.GuestOneId == guestId) ? couple.GuestTwo : couple.GuestOne; } var rsvp = new RSVP { GuestOneId = guestOne.Id, GuestOneName = guestOne.FullName, GuestTwoId = guestTwo.Id, GuestTwoName = guestTwo.FullName, GuestTag = (guestTwo.FullName == null) ? guestOne.FullName : guestOne.FullName + " & " + guestTwo.FullName }; var invitationViewModel = new InvitationViewModel { RSVP = rsvp, DrinkItems = getSpecialtyDrinks().ToList() }; return(View(invitationViewModel)); }
/// <summary> /// Returns a couple of set code/name /// </summary> /// <returns></returns> private Couple <string> _PickSetManufacturer() { // Preparing manufacturer list Couple <string> returnedCodeName = null; SortedStringCollection sortedNameList = new SortedStringCollection(); Dictionary <string, string> index = new Dictionary <string, string>(); List <DB.Cell[]> brandCells = DatabaseHelper.SelectCellsFromTopic(_BrandsTable, SharedConstants.ID_BRANDS_DB_COLUMN); foreach (DB.Cell[] cells in brandCells) { DB.Cell currentCell = cells[0]; string brandCode = DatabaseHelper.GetResourceValueFromCell(currentCell, _BrandsResource); if (!index.ContainsKey(brandCode)) { sortedNameList.Add(brandCode); index.Add(brandCode, currentCell.value); } } // Displaying browse dialog TableBrowsingDialog dialog = new TableBrowsingDialog(_MESSAGE_BROWSE_MANUFACTURERS, sortedNameList, index); DialogResult dr = dialog.ShowDialog(); if (dr == DialogResult.OK && dialog.SelectedIndex != null) { returnedCodeName = new Couple <string>(dialog.SelectedIndex, dialog.SelectedValue); } return(returnedCodeName); }
public IHttpActionResult PutCouple(int id, Couple couple) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != couple.Id) { return(BadRequest()); } db.Entry(couple).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!CoupleExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
/// <summary> /// Met à jour l'entrée correspondante /// </summary> /// <param name="editedEntry">Entrée modifiée</param> /// <returns>entry after update. Contents may be modified for compatibility reasons</returns> public Entry UpdateEntry(Entry editedEntry) { Entry newEntry = new Entry(); // Parcours des entrées for (int i = 0; i < _Entries.Count; i++) { newEntry = _Entries[i]; if (newEntry.index == editedEntry.index) { ResourceIdentifier oldId = newEntry.id; // Process value to replace forbidden characters Couple <char> couple1 = new Couple <char>(DB._CHAR_START_TEXT, '('); Couple <char> couple2 = new Couple <char>(DB._CHAR_END_TEXT, ')'); newEntry.id = editedEntry.id.Clone() as ResourceIdentifier; if (newEntry.id != null) { newEntry.value = String2.ReplaceChars(editedEntry.value, couple1, couple2); _Entries[i] = newEntry; // Accelerator update ! entriesById.Remove(oldId); entriesById.Add(newEntry.id, newEntry); } break; } } return(newEntry); }
public bool Add(double x, double y) { // utilise l'ajoutre méthode Add Couple point = new Couple(x, y); return(Add(point)); }
private void btnAdd_Click(object sender, EventArgs e) { Couple couple = new Couple() { CoupleId = 1, Name = "CarterLee" }; CacheService.Set(couple.CoupleId.ToString(), couple); }
static void Main() { Couple Inko = new Couple(); Inko.Man = new Human(); Inko.Man.Name = "차인표"; Inko.Man.Age = 40; Inko.Wife = new Human(); Inko.Wife.Name = "신애라"; Inko.Wife.Age = 38; Console.WriteLine("남편 : {0}세 {1}, 아내 : {2}세 {3}", Inko.Man.Age, Inko.Man.Name, Inko.Wife.Age, Inko.Wife.Name); }
private void _checkClassification(string sequence, Couple[] expected) { Lexer lexer; ClassificationTag returned_tag; TestingClassifier classifier; StringBuilder recognized; string error; int i; classifier = new TestingClassifier(); lexer = new Lexer(); lexer.Parse(sequence); recognized = new StringBuilder(); i = 0; while (lexer.Next()) { recognized.Append(lexer.CurrentToken.Text); error = String.Format( "Token [{0}] was expected, but [{1}] was returned instead, near: [{2}].", expected[i].Text, lexer.CurrentToken.Text, recognized.ToString()); Assert.That(lexer.CurrentToken.Text, Is.EqualTo(expected[i].Text), error); returned_tag = classifier.Classify(lexer.CurrentToken); error = String.Format( "ClassificationTag [{0}] was expected, but [{1}] was returned instead, near: [{2}].", expected[i].Value, returned_tag, recognized.ToString()); Assert.That(returned_tag, Is.EqualTo(expected[i].Value), error); i++; } Assert.That(lexer.Next(), Is.False, "Error, there are unvisited tokens left."); Assert.That(i == expected.Length, "Error, more tokens were expected."); return; }
public void NewChild(Couple couple) { Person child = couple.MakeAChild(); }
/// <summary> /// Initializes a new instance of the <see cref="Breeder"/> class. /// Breeder takes two genotypes and breeds them, producing an offspring created from their genes. /// </summary> /// <param name="chanceOfMutation"> /// The chance a mutation occurs. Precise up to 3 decimal places /// </param> /// <param name="couple"> /// The couple to breed /// </param> public Breeder(double chanceOfMutation, Couple couple) { this.Couple = couple; this.ChanceOfMutation = chanceOfMutation; }