private void FixCrossReferencesWithLegacyApplianceConfig(LegacyApplianceConfig config)
        {
            List<BandwidthSetting> bandwidthSettingList = (List<BandwidthSetting>)config.BandwidthSettings;
            List<StorageAccountCredential> sacList = (List<StorageAccountCredential>)config.StorageAccountCredentials;
            foreach(MigrationDataContainer dataContainer in config.CloudConfigurations)
            {
                dataContainer.BandwidthSetting = bandwidthSettingList.Find(bwSetting => bwSetting.InstanceId == dataContainer.BandwidthSetting.InstanceId);
                dataContainer.PrimaryStorageAccountCredential = sacList.Find(sac => sac.InstanceId == dataContainer.PrimaryStorageAccountCredential.InstanceId);
                dataContainer.BackupStorageAccountCredential = sacList.Find(sac => sac.InstanceId == dataContainer.BackupStorageAccountCredential.InstanceId);
            }

            List<AccessControlRecord> acrList = (List<AccessControlRecord>)config.AccessControlRecords;
            foreach( VirtualDisk virtualDisk in config.Volumes)
            {
                MigrationDataContainer dataContainer = ((List<MigrationDataContainer>)config.CloudConfigurations).Find(dc => dc.InstanceId == virtualDisk.DataContainerId);
                virtualDisk.DataContainer = this.ConvertToDataContainer(dataContainer);
                virtualDisk.DataContainer.VolumeCount++;
                virtualDisk.AcrList = acrList.FindAll(acr => virtualDisk.AcrIdList.Contains(acr.InstanceId));
                foreach(AccessControlRecord acr in virtualDisk.AcrList)
                {
                    acr.VolumeCount++;
                }
            }
        }
 private LegacyApplianceConfig CreateLegacyApplianceConfig(XmlDocument document)
 {
     LegacyApplianceConfig config = new LegacyApplianceConfig();
     XmlNode node = document.SelectSingleNode(@"//LegacyApplianceConfig");
     config.InstanceId = node.Attributes["Id"].Value;
     config.Name = node.Attributes["Name"].Value;
     config.SerialNumber = int.Parse(node.Attributes["SerialNo"].Value);
     config.TotalCount = int.Parse(node.Attributes["TotalCount"].Value);
     return config;
 }
 /// <summary>
 /// Hydra spec for import legacy appliance config rest api.The rest api
 /// imports the legacy config to the service
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.StorSimple.IMigrationOperations.
 /// </param>
 /// <param name='configId'>
 /// Required. Unique id for config being imported
 /// </param>
 /// <param name='request'>
 /// Required. Legacy appliance config to be imported
 /// </param>
 /// <param name='customRequestHeaders'>
 /// Required. The Custom Request Headers which client must use.
 /// </param>
 /// <returns>
 /// A standard service response including an HTTP status code and
 /// request ID.
 /// </returns>
 public static Task<AzureOperationResponse> ImportLegacyApplianceConfigAsync(this IMigrationOperations operations, string configId, LegacyApplianceConfig request, CustomRequestHeaders customRequestHeaders)
 {
     return operations.ImportLegacyApplianceConfigAsync(configId, request, customRequestHeaders, CancellationToken.None);
 }
 public AzureOperationResponse ImportLegacyApplianceConfig(string configId, LegacyApplianceConfig legacyApplConfig)
 {
     return this.GetStorSimpleClient().MigrateLegacyAppliance.ImportLegacyApplianceConfig(configId, legacyApplConfig, this.GetCustomRequestHeaders());
 }
 /// <summary>
 /// Hydra spec for import legacy appliance config rest api.The rest api
 /// imports the legacy config to the service
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.StorSimple.IMigrationOperations.
 /// </param>
 /// <param name='configId'>
 /// Required. Unique id for config being imported
 /// </param>
 /// <param name='request'>
 /// Required. Legacy appliance config to be imported
 /// </param>
 /// <param name='customRequestHeaders'>
 /// Required. The Custom Request Headers which client must use.
 /// </param>
 /// <returns>
 /// A standard service response including an HTTP status code and
 /// request ID.
 /// </returns>
 public static AzureOperationResponse ImportLegacyApplianceConfig(this IMigrationOperations operations, string configId, LegacyApplianceConfig request, CustomRequestHeaders customRequestHeaders)
 {
     return Task.Factory.StartNew((object s) => 
     {
         return ((IMigrationOperations)s).ImportLegacyApplianceConfigAsync(configId, request, customRequestHeaders);
     }
     , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
 }