{"id":561,"date":"2011-08-21T00:20:10","date_gmt":"2011-08-21T00:20:10","guid":{"rendered":"http:\/\/nestor.nestasoft.fr\/?p=561"},"modified":"2011-08-21T00:20:10","modified_gmt":"2011-08-21T00:20:10","slug":"part-2-childwindow-silverlight-connexion-au-service-web","status":"publish","type":"post","link":"https:\/\/nestasoft.fr\/?p=561","title":{"rendered":"Part 2 : ChildWindow (Silverlight) : Connexion au Service Web"},"content":{"rendered":"<p><img decoding=\"async\" class=\"alignleft\" src=\"http:\/\/www.nestor.nestasoft.fr\/wp-content\/uploads\/2011\/07\/silverlight.bmp\"\/><br \/>\nBonjour.<br \/>\nNous d\u00e9couvrirons dans cette seconde partie comment se connecter au Service Web.<br \/>\nAre you ready, let&rsquo;s go \ud83d\ude42<br \/>\n<!--more--><\/p>\n<p>Dans le fichier AdministrationModel.cs, nous allons d\u00e9finir notre Model:<\/p>\n<p><b>AdministrationModel<\/b><\/p>\n<pre class=\"brush:csharp\"> \r\npublic class AdministrationModel\r\n{\r\n   private List<Utilisateur> _utilisateurs;\r\n\r\n   public List<Utilisateur> Utilisateurs\r\n   {\r\n            get { return _utilisateurs; }\r\n            set { _utilisateurs = value;}\r\n   }\r\n}\r\n<\/pre>\n<p>Dans la ViewModel, nous allons appeler le Web Service n\u00e9cessaire pour obtenir la liste des utilisateurs:<\/p>\n<pre class=\"brush:csharp\"> \r\npublic void LoadUsers(Role role, string nom)\r\n{\r\n    Model.Utilisateurs = null;\r\n\r\n    UserServiceClient client = HelperWCF.CreateUserClient();\r\n    client.GetUtilisateurCompleted += new EventHandler<GetUtilisateurCompletedEventArgs>(GetUtilisateurCompleted);\r\n    client.GetUtilisateurAsync(new Utilisateur());\r\n\r\n}\r\n\r\nvoid GetUtilisateurCompleted(object sender, AsyncCompletedEventArgs e)\r\n{\r\n   try\r\n   {\r\n     if (e.Error == null)\r\n     {\r\n         if (e is GetUtilisateurCompletedEventArgs)\r\n               Model.Utilisateurs = (e as GetUtilisateurCompletedEventArgs).Result;\r\n     }\r\n  }\r\n  catch (Exception ex)\r\n  {\r\n     \/\/Code...\r\n  }\r\n}\r\n<\/pre>\n<p>Ici s&rsquo;ach\u00e8ve notre seconde partie.<br \/>\nDans la partie trois nous allons vois comment utiliser la m\u00e9thode LoadUser() de notre ViewModel afin de binder notre ListBox.<\/p>\n<p>A tr\u00e8s bient\u00f4t<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_561\" class=\"pvc_stats all  \" data-element-id=\"561\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/nestasoft.fr\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Bonjour. Nous d\u00e9couvrirons dans cette seconde partie comment se connecter au Service Web. Are you ready, let&rsquo;s go \ud83d\ude42<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_561\" class=\"pvc_stats all  \" data-element-id=\"561\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/nestasoft.fr\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-561","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/nestasoft.fr\/index.php?rest_route=\/wp\/v2\/posts\/561","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nestasoft.fr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nestasoft.fr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nestasoft.fr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nestasoft.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=561"}],"version-history":[{"count":4,"href":"https:\/\/nestasoft.fr\/index.php?rest_route=\/wp\/v2\/posts\/561\/revisions"}],"predecessor-version":[{"id":565,"href":"https:\/\/nestasoft.fr\/index.php?rest_route=\/wp\/v2\/posts\/561\/revisions\/565"}],"wp:attachment":[{"href":"https:\/\/nestasoft.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=561"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nestasoft.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=561"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nestasoft.fr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=561"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}