private string GetNextEventUri(UcwaResource resource)
 {
     try
     {
         if (resource.LinkNames.Contains("resync"))
         {
             return(resource.GetLinkUri("resync"));
         }
         if (resource.LinkNames.Contains("resume"))
         {
             return(resource.GetLinkUri("resume"));
         }
         if (resource.LinkNames.Contains("next"))
         {
             return(resource.GetLinkUri("next"));
         }
         return(null);
     }
     catch { return(null); }
 }
        /// <summary>
        /// Get an application resource bound to the user's local endpoint
        /// </summary>
        /// <param name="resUser">The authenticated user resource</param>
        /// <param name="userAgent">The name of this application</param>
        /// <param name="culture">The locale of this application</param>
        /// <returns>The application resoure as part of UcwaAppOperationResult</returns>
        async Task <UcwaAppOperationResult> GetApplicationResource(UcwaResource resUser,
                                                                   string userAgent = "ContosoApp/1.0 (WinStore)", string culture = "en-us")
        {
            applicationsUrl = resUser.GetLinkUri("applications");
            var    endpointId  = Guid.NewGuid().ToString();
            string appSettings = string.Format(appSettingsFormatter, culture, endpointId, userAgent);
            var    result      = await Transport.PostResourceAsync(applicationsUrl, appSettings);

            if (result.StatusCode != HttpStatusCode.Created)
            {
                return(new UcwaAppOperationResult(result.StatusCode, result.ResponseHeaders, result.ResponseBody,
                                                  new Exception("Failed to PostRequest on " + applicationsUrl)));
            }
            return(result);
        }