Contains the hosted service details
コード例 #1
0
 internal override void Parse()
 {
     IEnumerable<XElement> rootElements = Document.Element(GetSchema() + "StorageServices")
         .Elements(GetSchema() + "StorageService");
     foreach (XElement hostedService in rootElements)
     {
         var service = new StorageAccount
                           {
                               Name = (string) hostedService.Element(GetSchema() + "ServiceName"),
                               Url = (string) hostedService.Element(GetSchema() + "Url"),
                               Location = (string) hostedService.Element(GetSchema() + "StorageServiceProperties")
                                         .Element(GetSchema() + "Location")
                           };
         // this can happen if there is an affinity group - then there is no location -
         // we get a primary geolocation though
         if (service.Location == null)
         {
             service.Location = (string) hostedService.Element(GetSchema() + "StorageServiceProperties")
                 .Element(GetSchema() + "GeoPrimaryRegion");
         }
         CommandResponse.Add(service);
     }
 }
コード例 #2
0
        /// <summary>
        /// Used to commit the transaction data 
        /// </summary>
        /// <returns>A dynamic type which represents the return of the particular transaction</returns>
        dynamic IServiceTransaction.Commit()
        {
            // set the start flag
            _started = true;
            // ensure that the account has been given a name
            if (Manager.StorageAccountName == null)
                throw new ApplicationException(
                    "unable to continue - no storage account name present. Did you want to query instead?");

            // get the list of accounts and check to see whether the account already exists
            _storageAccount = FindAccounByName(Manager.StorageAccountName);
            // Check to see whether the operation is create or delete - we only want to support a transaction on the create
            // this API does not follow a crud methodology
            if (Manager.CreateNewStorageAccount)
            {
                if (_storageAccount != null)
                    throw new StorageAccountAlreadyExistsException(Manager.StorageAccountName);
                // create the account depending on the flag that has been set
                _success = CreateStorageAccount();
            }
            else
            {
                if (_storageAccount == null)
                    throw new StorageAccountDoesNotExistException(Manager.StorageAccountName);
                // delete the account depending on the flag that has been set
                _success = DeleteStorageAccount();
            }
            return _success;
        }