/// <summary>
 ///     Initializes a new instance of the <see cref="MainPage" /> class.
 /// </summary>
 /// <param name="battleId"></param>
 public MainPage([NotNull] int battleId)
 {
     InitializeComponent();
     this.InitializeBusyDialog();
     //get battle context via web api
     var webClient = new WebClient();
     var apiHelper = new WebApi("audiobattle");
     apiHelper.ChangeToLocalHost();
     BusyIndicatorContext.Current.Busy = true;
     webClient.OpenReadCompleted += (sender, e) =>
     {
         if (e.Error == null)
         {
             var stream = new StreamReader(e.Result);
             var jsonObj = stream.ReadToEnd().ToString();
             RapAudioContext.Current.Service = JsonConvert.DeserializeObject<AudioBattleModel>(jsonObj);
             var factory = new SilverlightFactory(RapAudioContext.Current.Service, this.Beat);
             factory.Build(this.RecorderUser1, this.RecorderUser2);
             factory.Build(this.Beat);
         }
         BusyIndicatorContext.Current.Busy = false;
     };
     webClient.OpenReadAsync(
         new Uri(apiHelper.GetByAction(battleId, "getbattle")));
 }
Beispiel #2
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="Get" /> class.
 /// </summary>
 /// <param name="controllerName">Name of the controller.</param>
 /// <param name="id">The identifier.</param>
 /// <param name="e">The e.</param>
 /// <param name="methodUrl">The method URL.</param>
 public Get(string controllerName, int id, DownloadStringCompletedEventHandler e = null, string methodUrl = "")
 {
     var api = new WebApi(controllerName);
     var webClient = new RapWebClient {CookieContainer = RapClientCookie.Current};
     webClient.DownloadStringCompleted += e;
     webClient.DownloadStringAsync(string.IsNullOrEmpty(methodUrl)
         ? new Uri(api.Get(id))
         : new Uri(api.GetByAction(id, methodUrl)));
 }