private void LoadDefaultProfile() { AgentProfile first = AgentProfileFactory.Create(Guid.Empty, VersionCode.V1, new IPEndPoint(IPAddress.Loopback, 161), "public", "private", "localhost", string.Empty, string.Empty, 0, 0, string.Empty, 1000); AddProfile(first); DefaultProfile = first; }
public void DeleteProfile(AgentProfile profile) { DeleteInternal(profile.Id); if (OnChanged != null) { OnChanged(null, EventArgs.Empty); } }
public void AddProfile(AgentProfile profile) { AddInternal(profile); if (OnChanged != null) { OnChanged(null, EventArgs.Empty); } }
public FormProfile(AgentProfile agent) { InitializeComponent(); _profile = agent; if (PlatformSupport.Platform == PlatformType.Windows) { Icon = Properties.Resources.network_server; } }
private void ActEditExecute(object sender, EventArgs e) { AgentProfile profile = listView1.SelectedItems[0].Tag as AgentProfile; using (FormProfile editor = new FormProfile(profile)) { if (editor.ShowDialog() == DialogResult.OK) { } } }
private void TxtIpValidating(object sender, CancelEventArgs e) { IPAddress ip; if (AgentProfile.IsValid(txtIP.Text, out ip)) { return; } e.Cancel = true; txtIP.SelectAll(); errorProvider1.SetError(txtIP, "IP address is not valid"); }
private void AddInternal(AgentProfile profile) { if (_profiles.ContainsKey(profile.Id)) { throw new BrowserException("This endpoint is already registered"); } _profiles.Add(profile.Id, profile); if (DefaultProfile == null) { DefaultProfile = profile; } }
private int LoadProfilesFromFile() { if (!File.Exists(SettingFile)) { return 0; } Guid defaultId = Guid.Empty; using (XmlTextReader reader = new XmlTextReader(SettingFile)) { try { while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: { if (reader.Name == NameAgent) { defaultId = new Guid(reader.GetAttribute(NameDefaultAgent)); } else if (reader.Name == NameAdd) { string name = reader.GetAttribute(NameName); Guid id = new Guid(reader.GetAttribute(NameId)); string[] parts = reader.GetAttribute(NameBinding).Split(new[] { ':' }); IPAddress def = IPAddress.Parse(parts[0]); int port = int.Parse(parts[1], CultureInfo.InvariantCulture); VersionCode vc = (VersionCode)int.Parse(reader.GetAttribute(NameVersion), CultureInfo.InvariantCulture); string get = reader.GetAttribute(NameGetCommunity); string set = reader.GetAttribute(NameSetCommunity); string authenticationPassphrase = reader.GetAttribute(NameAuthenticationPassphrase); string privacyPassphrase = reader.GetAttribute(NamePrivacyPassphrase); string authenticationMethod = reader.GetAttribute(NameAuthenticationMethod); string privacyMethod = reader.GetAttribute(NamePrivacyMethod); string userName = reader.GetAttribute(NameUserName); int timeout = int.Parse(reader.GetAttribute(NameTimeout), CultureInfo.InvariantCulture); AgentProfile profile = AgentProfileFactory.Create( id, vc, new IPEndPoint(def, port), get, set, name, authenticationPassphrase, privacyPassphrase, string.IsNullOrEmpty(authenticationMethod) ? 0 : int.Parse(authenticationMethod, CultureInfo.InvariantCulture), string.IsNullOrEmpty(privacyMethod) ? 0 : int.Parse(privacyMethod, CultureInfo.InvariantCulture), userName, timeout); if (id == defaultId) { DefaultProfile = profile; } AddProfile(profile); } break; } default: break; } } } catch (Exception ex) { Logger.Info(ex.ToString()); } finally { reader.Close(); } } return _profiles.Count; }
private int LoadProfilesFromFile() { if (!File.Exists(SettingFile)) { return(0); } Guid defaultId = Guid.Empty; using (XmlTextReader reader = new XmlTextReader(SettingFile)) { try { while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: { if (reader.Name == NameAgent) { defaultId = new Guid(reader.GetAttribute(NameDefaultAgent)); } else if (reader.Name == NameAdd) { string name = reader.GetAttribute(NameName); Guid id = new Guid(reader.GetAttribute(NameId)); string[] parts = reader.GetAttribute(NameBinding).Split(new[] { ':' }); IPAddress def = IPAddress.Parse(parts[0]); int port = int.Parse(parts[1], CultureInfo.InvariantCulture); VersionCode vc = (VersionCode)int.Parse(reader.GetAttribute(NameVersion), CultureInfo.InvariantCulture); string get = reader.GetAttribute(NameGetCommunity); string set = reader.GetAttribute(NameSetCommunity); string authenticationPassphrase = reader.GetAttribute(NameAuthenticationPassphrase); string privacyPassphrase = reader.GetAttribute(NamePrivacyPassphrase); string authenticationMethod = reader.GetAttribute(NameAuthenticationMethod); string privacyMethod = reader.GetAttribute(NamePrivacyMethod); string userName = reader.GetAttribute(NameUserName); int timeout = int.Parse(reader.GetAttribute(NameTimeout), CultureInfo.InvariantCulture); AgentProfile profile = AgentProfileFactory.Create( id, vc, new IPEndPoint(def, port), get, set, name, authenticationPassphrase, privacyPassphrase, string.IsNullOrEmpty(authenticationMethod) ? 0 : int.Parse(authenticationMethod, CultureInfo.InvariantCulture), string.IsNullOrEmpty(privacyMethod) ? 0 : int.Parse(privacyMethod, CultureInfo.InvariantCulture), userName, timeout); if (id == defaultId) { DefaultProfile = profile; } AddProfile(profile); } break; } default: break; } } } catch (Exception ex) { Logger.Info(ex.ToString()); } finally { reader.Close(); } } return(_profiles.Count); }