Exemplo n.º 1
0
 /// <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")));
 }
Exemplo n.º 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)));
 }
Exemplo n.º 3
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="RapBeats" /> class.
 /// </summary>
 public RapBeats()
 {
     InitializeComponent();
     this.State = PlayerState.Stop;
     this._apiHelper = new WebApi("beat");
     this._apiHelper.ChangeToLocalHost();
     this._background.ImageSource = new BitmapImage(new Uri("../images/Play.png", UriKind.Relative));
     this.PlayBeat.Background = this._background;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Post" /> class.
 /// </summary>
 /// <param name="controllerName">Name of the controller.</param>
 /// <param name="id">The identifier.</param>
 /// <param name="e">The e.</param>
 /// <param name="actionName">Name of the action.</param>
 public Delete(string controllerName, int id, UploadStringCompletedEventHandler e = null, string actionName = "")
 {
     var api = new WebApi(controllerName);
     var webClient = new RapWebClient {CookieContainer = RapClientCookie.Current};
     webClient.UploadStringCompleted += e;
     webClient.UploadStringAsync(string.IsNullOrEmpty(actionName) ? 
         new Uri(api.Delete(id)) : 
         new Uri(api.DeleteByAction(id, actionName)), "DELETE", "");
 }
Exemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Post" /> class.
 /// </summary>
 /// <param name="controllerName">Name of the controller.</param>
 /// <param name="payLoad">The pay load.</param>
 /// <param name="e">The e.</param>
 /// <param name="methodUrl">The method URL after the controller name from web api.</param>
 public Post(string controllerName, object payLoad, UploadStringCompletedEventHandler e = null,
     string methodUrl = "")
 {
     var api = new WebApi(controllerName);
     var url = new Uri(api.Post() + methodUrl);
     var webClient = new RapWebClient {CookieContainer = RapClientCookie.Current};
     webClient.Headers[HttpRequestHeader.ContentType] = "application/json";
     webClient.UploadStringCompleted += e;
     webClient.UploadStringAsync(url, "POST", JsonConvert.SerializeObject(payLoad));
 }
Exemplo n.º 6
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="Put" /> class.
 /// </summary>
 /// <param name="controllerName">Name of the controller.</param>
 /// <param name="id">The identifier.</param>
 /// <param name="payLoad">The pay load.</param>
 /// <param name="e">The e.</param>
 /// <param name="methodUrl">The method URL.</param>
 public Put(string controllerName, int id, object payLoad, UploadStringCompletedEventHandler e = null,
     string actionName = "")
 {
     var api = new WebApi(controllerName);
     var webClient = new RapWebClient {CookieContainer = RapClientCookie.Current};
     webClient.Headers[HttpRequestHeader.ContentType] = "application/json";
     webClient.UploadStringCompleted += e;
     webClient.UploadStringAsync(string.IsNullOrEmpty(actionName) ?
         new Uri(api.Put(id)) :
         new Uri(api.PutByAction(id, actionName)), "PUT", JsonConvert.SerializeObject(payLoad));
 }