Exemple #1
0
 /// <summary>
 /// Load tethering manager if available.
 /// </summary>
 private bool MakeTetheringManagerAvailable()
 {
     if (tetheringManager == null)
     {
         // verify tethering capabilities
         var allAccounts = MobileBroadbandAccount.AvailableNetworkAccountIds;
         if (allAccounts.Count == 0)
         {
             rootPage.NotifyUser("There is no avaiable network account ID.", NotifyType.ErrorMessage);
             return(false);
         }
         string networkAccountId          = allAccounts[0];
         TetheringCapability capabilities = 0;
         try
         {
             capabilities = NetworkOperatorTetheringManager.GetTetheringCapability(networkAccountId);
             if (capabilities != TetheringCapability.Enabled)
             {
                 OnCapabilityError(capabilities);
             }
             else
             {
                 if (tetheringManager == null)
                 {
                     tetheringManager = NetworkOperatorTetheringManager.CreateFromNetworkAccountId(networkAccountId);
                     if (tetheringManager == null)
                     {
                         rootPage.NotifyUser("Failed to create NetworkOperatorTetheringManager object using : " + networkAccountId, NotifyType.ErrorMessage);
                         return(false);
                     }
                 }
             }
         }
         catch (Exception ex)
         {
             rootPage.NotifyUser("Unexpected exception occured: " + ex.ToString(), NotifyType.ErrorMessage);
             return(false);
         }
     }
     return(true);
 }