private void Button_GO_Click(object sender, RoutedEventArgs e) { PatronDeConceptionFabriqueEtCommande.Trame.Trame trame = new PatronDeConceptionFabriqueEtCommande.Trame.Trame(); if (RadioButton_Information.IsChecked.Value) { trame.TypeDeMessage = CommandeFactory.TypeMessageInfo; } if (RadioButton_Avertissement.IsChecked.Value) { trame.TypeDeMessage = CommandeFactory.TypeMessageAvertissement; } if (RadioButton_Fermer.IsChecked.Value) { trame.TypeDeMessage = CommandeFactory.TypeMessageFermerLeProgramme; } if (RadioButton_AfficherLesBovins.IsChecked.Value) { trame.TypeDeMessage = CommandeFactory.TypeMessageAfficherLesBovins; } trame.ChargeUtile = ExempleDeTrame.Text; Commande commande = CommandeFactory.GetCommande(trame); if (commande != null) { commande.Execute(); } }
static public Commande GetCommande(PatronDeConceptionFabriqueEtCommande.Trame.Trame trame) { Commande commande = null; if (trame != null) { switch (trame.TypeDeMessage) { case TypeMessageInfo: commande = new CommandeAfficherBoiteInfo(); commande.Parametre = DeserialisationJSon.GetParametreAfficherBoiteInfo(trame.ChargeUtile); break; case TypeMessageAvertissement: commande = new CommandeAfficherBoiteAvertissement(); commande.Parametre = DeserialisationJSon.GetParametreAfficherBoiteAvertissement(trame.ChargeUtile); break; case TypeMessageFermerLeProgramme: commande = new CommandeFermerLeProgramme(); commande.Parametre = DeserialisationJSon.GetParametreFermerLeProgramme(trame.ChargeUtile); break; case TypeMessageAfficherLesBovins: commande = new CommandeAfficherLesBovins(); commande.Parametre = DeserialisationJSon.GetParametreAfficherLesBovins(trame.ChargeUtile); break; } } return(commande); }