コード例 #1
0
        public static  IList<Management.Compute.Models.ConfigurationSet> MapConfigurationSets(Collection<ConfigurationSet> configurationSets)
        {
            var result = new Collection<Management.Compute.Models.ConfigurationSet>();
            foreach (var networkConfig in configurationSets.OfType<NetworkConfigurationSet>())
            {
                result.Add(Mapper.Map<Management.Compute.Models.ConfigurationSet>(networkConfig));
            }
            foreach (var windowsConfig in configurationSets.OfType<WindowsProvisioningConfigurationSet>())
            {
                var newWinCfg = Mapper.Map<Management.Compute.Models.ConfigurationSet>(windowsConfig);
                if (windowsConfig.WinRM != null)
                {
                    newWinCfg.WindowsRemoteManagement = new WindowsRemoteManagementSettings();

                    // AutoMapper doesn't work for WinRM.Listeners -> WindowsRemoteManagement.Listeners
                    if (windowsConfig.WinRM.Listeners != null)
                    {
                        foreach (var s in windowsConfig.WinRM.Listeners)
                        {
                            newWinCfg.WindowsRemoteManagement.Listeners.Add(new WindowsRemoteManagementListener
                            {
                                ListenerType = (VirtualMachineWindowsRemoteManagementListenerType)Enum.Parse(typeof(VirtualMachineWindowsRemoteManagementListenerType), s.Protocol, true),
                                CertificateThumbprint = s.CertificateThumbprint
                            });
                        }
                    }
                }
                result.Add(newWinCfg);
            }
            foreach (var linuxConfig in configurationSets.OfType<LinuxProvisioningConfigurationSet>())
            {
                result.Add(Mapper.Map<Management.Compute.Models.ConfigurationSet>(linuxConfig));
            }
            return result;
        }