Example #1
0
        public IPersistentSettingsCollection <ConnectionSettingsBase> GetConnectionSettings(
            IProjectExplorerNode node)
        {
            if (node is IProjectExplorerProjectNode projectNode)
            {
                return(this.repository.GetProjectSettings(projectNode.Project.ProjectId)
                       .ToPersistentSettingsCollection(s => this.repository.SetProjectSettings(s)));
            }
            else if (node is IProjectExplorerZoneNode zoneNode)
            {
                var projectSettings = this.repository.GetProjectSettings(
                    zoneNode.Zone.ProjectId);
                var zoneSettings = this.repository.GetZoneSettings(
                    zoneNode.Zone.ProjectId,
                    zoneNode.Zone.Name);

                // Apply overlay to get effective settings.
                return(projectSettings
                       .OverlayBy(zoneSettings)
                       .ToPersistentSettingsCollection(s => this.repository.SetZoneSettings(s)));
            }
            else if (node is IProjectExplorerInstanceNode vmNode)
            {
                var projectSettings = this.repository.GetProjectSettings(
                    vmNode.Instance.ProjectId);
                var zoneSettings = this.repository.GetZoneSettings(
                    vmNode.Instance.ProjectId,
                    vmNode.Instance.Zone);
                var instanceSettings = this.repository.GetVmInstanceSettings(
                    vmNode.Instance.ProjectId,
                    vmNode.Instance.Name);

                var supportsRdp = vmNode.IsRdpSupported();
                var supportsSsh = vmNode.IsSshSupported();

                // Apply overlay to get effective settings.
                return(projectSettings
                       .OverlayBy(zoneSettings)
                       .OverlayBy(instanceSettings)

                       // Save back to same repository.
                       .ToPersistentSettingsCollection(s => this.repository.SetVmInstanceSettings(s))

                       // Hide any settings that are not applicable to the operating system.
                       .ToFilteredSettingsCollection((coll, setting) => supportsRdp
                        ? coll.IsRdpSetting(setting)
                        : supportsSsh?coll.IsSshSetting(setting) : false));
            }
            else
            {
                throw new ArgumentException("Unsupported node type: " + node.GetType().Name);
            }
        }
        public ConnectionSettingsBase GetConnectionSettings(IProjectExplorerNode node)
        {
            if (node is IProjectExplorerProjectNode projectNode)
            {
                return(this.repository.GetProjectSettings(projectNode.ProjectId));
            }
            else if (node is IProjectExplorerZoneNode zoneNode)
            {
                var projectSettings = this.repository.GetProjectSettings(
                    zoneNode.ProjectId);
                var zoneSettings = this.repository.GetZoneSettings(
                    zoneNode.ProjectId,
                    zoneNode.ZoneId);

                // Apply overlay to get effective settings.
                return(projectSettings
                       .OverlayBy(zoneSettings));
            }
            else if (node is IProjectExplorerVmInstanceNode vmNode)
            {
                var projectSettings = this.repository.GetProjectSettings(
                    vmNode.ProjectId);
                var zoneSettings = this.repository.GetZoneSettings(
                    vmNode.ProjectId,
                    vmNode.ZoneId);
                var instanceSettings = this.repository.GetVmInstanceSettings(
                    vmNode.ProjectId,
                    vmNode.InstanceName);

                // Apply overlay to get effective settings.
                return(projectSettings
                       .OverlayBy(zoneSettings)
                       .OverlayBy(instanceSettings));
            }
            else
            {
                throw new ArgumentException("Unsupported node type: " + node.GetType().Name);
            }
        }
Example #3
0
 public ConnectionSettingsEditor GetConnectionSettingsEditor(IProjectExplorerNode node)
 {
     if (node is IProjectExplorerProjectNode projectNode)
     {
         return(GetProjectConnectionSettingsEditor(projectNode.ProjectId));
     }
     else if (node is IProjectExplorerZoneNode zoneNode)
     {
         return(GetZoneConnectionSettingsEditor(zoneNode.ProjectId, zoneNode.ZoneId));
     }
     else if (node is IProjectExplorerVmInstanceNode vmNode)
     {
         return(GetVmInstanceConnectionSettingsEditor(
                    vmNode.ProjectId,
                    vmNode.ZoneId,
                    vmNode.InstanceName));
     }
     else
     {
         throw new ArgumentException("Unsupported node type: " + node.GetType().Name);
     }
 }