Esempio n. 1
0
        public void ClearResetsList()
        {
            var protArray = new[] { _protocol1, _protocol2, _protocol3 };

            _protocolList.AddRange(protArray);
            _protocolList.Clear();
            Assert.That(_protocolList.Count == 0);
        }
Esempio n. 2
0
        public VmServerEditorPage(ProtocolServerBase server, VmServerListPage host, bool isDuplicate = false)
        {
            Server       = (ProtocolServerBase)server.Clone();
            _isDuplicate = isDuplicate;
            if (_isDuplicate)
            {
                Server.Id = 0;
            }
            Host      = host;
            IsAddMode = server.GetType() == typeof(ProtocolServerNone) || Server.Id == 0;

            // decrypt pwd
            if (Server.GetType() != typeof(ProtocolServerNone))
            {
                SystemConfig.Instance.DataSecurity.DecryptPwd(Server);
            }

            var assembly = typeof(ProtocolServerBase).Assembly;
            var types    = assembly.GetTypes();

            // reflect remote protocols
            {
                ProtocolList.Clear();
                ProtocolList = types.Where(item => item.IsSubclassOf(typeof(ProtocolServerBase)) && !item.IsAbstract)
                               .Where(x => x.FullName != typeof(ProtocolServerNone).FullName)
                               .Select(type => (ProtocolServerBase)Activator.CreateInstance(type)).ToList();
            }

            // set selected protocol
            try
            {
                ProtocolSelected = ProtocolList.First(x => x.GetType() == Server.GetType());
            }
            catch (Exception)
            {
                ProtocolSelected = ProtocolList.First();
            }

            if (!IsAddMode)
            {
                ProtocolList.Clear();
                ProtocolList.Add(ProtocolSelected);
            }
            else
            {
                if (string.IsNullOrEmpty(Server.GroupName))
                {
                    Server.GroupName = Host.SelectedGroup;
                }
            }

            Debug.Assert(Server.GetType() != typeof(ProtocolServerNone));
        }
Esempio n. 3
0
        public override void Dispose()
        {
            base.Dispose();
            _LangDictionary.Clear();
            _CredentialList.Clear();
            _FolderList.Clear();
            _SelectedDefaultFolder = null;
            ProtocolList.Clear();

            CmdCancelClick.CloseTab -= CmdCancelClick_CloseTab;
            CmdSaveClick.Save       -= CmdSaveClick_Save;
            CmdTabLoaded.Loaded     -= CmdTabLoaded_Loaded;

            CmdCancelClick = null;
            CmdSaveClick   = null;
            CmdTabLoaded   = null;
        }