Наследование: ConnectionInfo, IComponent
 protected virtual void AddSession(PuttySessionInfo sessionInfo)
 {
     if (string.IsNullOrEmpty(sessionInfo?.Name) || Sessions.Any(child => child.Name == sessionInfo.Name))
         return;
     RootInfo.AddChild(sessionInfo);
     RaisePuttySessionCollectionChangedEvent(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, sessionInfo));
 }
        public override PuttySessionInfo GetSession(string sessionName)
        {
            var sessionsKey = Registry.CurrentUser.OpenSubKey(PuttySessionsKey);
            var sessionKey = sessionsKey?.OpenSubKey(sessionName);
            if (sessionKey == null)	return null;

            sessionName = HttpUtility.UrlDecode(sessionName.Replace("+", "%2B"));

            var sessionInfo = new PuttySessionInfo
            {
                PuttySession = sessionName,
                Name = sessionName,
                Hostname = Convert.ToString(sessionKey.GetValue("HostName")),
                Username = Convert.ToString(sessionKey.GetValue("UserName"))
            };
            var protocol = Convert.ToString(sessionKey.GetValue("Protocol")) ?? "ssh";
            switch (protocol.ToLowerInvariant())
            {
                case "raw":
                    sessionInfo.Protocol = ProtocolType.RAW;
                    break;
                case "rlogin":
                    sessionInfo.Protocol = ProtocolType.Rlogin;
                    break;
                case "serial":
                    return null;
                case "ssh":
                    var sshVersionObject = sessionKey.GetValue("SshProt");
                    if (sshVersionObject != null)
                    {
                        var sshVersion = Convert.ToInt32(sshVersionObject);
                        sessionInfo.Protocol = sshVersion >= 2 ? ProtocolType.SSH2 : ProtocolType.SSH1;
                    }
                    else
                    {
                        sessionInfo.Protocol = ProtocolType.SSH2;
                    }
                    break;
                case "telnet":
                    sessionInfo.Protocol = ProtocolType.Telnet;
                    break;
                default:
                    return null;
            }
            sessionInfo.Port = Convert.ToInt32(sessionKey.GetValue("PortNumber"));

            return sessionInfo;
        }
 public PuttySessionChangedEventArgs(PuttySessionInfo sessionChanged = null)
 {
     Session = sessionChanged;
 }
		public override PuttySessionInfo GetSession(string sessionName)
		{
            var registrySessionName = GetRegistrySessionName(sessionName);
			if (!string.IsNullOrEmpty(registrySessionName))
			{
				return ModifyRegistrySessionInfo(PuttySessionsRegistryProvider.GetSession(registrySessionName));
			}

            var sessionsFolderPath = GetSessionsFolderPath();
			if (!Directory.Exists(sessionsFolderPath))
			{
				return null;
			}

            var sessionFile = Path.Combine(sessionsFolderPath, sessionName);
			if (!File.Exists(sessionFile))
			{
				return null;
			}
				
			sessionName = System.Web.HttpUtility.UrlDecode(sessionName.Replace("+", "%2B"));

            var sessionFileReader = new SessionFileReader(sessionFile);
		    var sessionInfo = new PuttySessionInfo
		    {
		        PuttySession = sessionName,
		        Name = sessionName,
		        Hostname = sessionFileReader.GetValue("HostName"),
		        Username = sessionFileReader.GetValue("UserName")
		    };
		    var protocol = sessionFileReader.GetValue("Protocol") ?? "ssh";
		    switch (protocol.ToLowerInvariant())
			{
				case "raw":
					sessionInfo.Protocol = ProtocolType.RAW;
					break;
				case "rlogin":
					sessionInfo.Protocol = ProtocolType.Rlogin;
					break;
				case "serial":
					return null;
				case "ssh":
					object sshVersionObject = sessionFileReader.GetValue("SshProt");
					if (sshVersionObject != null)
					{
					    var sshVersion = Convert.ToInt32(sshVersionObject);
					    sessionInfo.Protocol = sshVersion >= 2 ? ProtocolType.SSH2 : ProtocolType.SSH1;
					}
					else
					{
						sessionInfo.Protocol = ProtocolType.SSH2;
					}
					break;
				case "telnet":
					sessionInfo.Protocol = ProtocolType.Telnet;
					break;
				default:
					return null;
			}
			sessionInfo.Port = Convert.ToInt32(sessionFileReader.GetValue("PortNumber"));
			
			return sessionInfo;
		}
		private static PuttySessionInfo ModifyRegistrySessionInfo(PuttySessionInfo sessionInfo)
		{
			sessionInfo.Name = string.Format(RegistrySessionNameFormat, sessionInfo.Name);
			sessionInfo.PuttySession = string.Format(RegistrySessionNameFormat, sessionInfo.PuttySession);
			return sessionInfo;
		}
 public void CantDragPuttySessionInfo()
 {
     var source = new PuttySessionInfo();
     var target = _container2;
     var dragDropEffects = _dragAndDropHandler.CanModelDrop(source, target, DropTargetLocation.Item);
     Assert.That(dragDropEffects, Is.EqualTo(DragDropEffects.None));
 }
 public void CantDragNodeBelowPuttySessionNodes()
 {
     var source = _connection1;
     var target = new PuttySessionInfo();
     var dragDropEffects = _dragAndDropHandler.CanModelDrop(source, target, DropTargetLocation.BelowItem);
     Assert.That(dragDropEffects, Is.EqualTo(DragDropEffects.None));
 }
 protected virtual void RemoveSession(PuttySessionInfo sessionInfo)
 {
     if (!Sessions.Contains(sessionInfo)) return;
     RootInfo.RemoveChild(sessionInfo);
     RaisePuttySessionCollectionChangedEvent(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, sessionInfo));
 }