using System; using System.Net; namespace InfoCenter.Agent.Entities { /// <summary> /// Represent a computer /// </summary> public class Computer { #region private fields private string _name; private string _ip; private string _userName; private string _osVersion; #endregion #region public properties public string Name { get { return _name; } set { _name = value; } } public string Ip { get { return _ip; } set { _ip = value; } } public string UserName { get { return _userName; } set { _userName = value; } } public string OsVersion { get { return _osVersion; } set { _osVersion = value; } } #endregion /// <summary> /// Return computer instance /// </summary> /// <returns></returns> public static Computer Create() { Computer computer = new Computer(); computer.Name = Environment.MachineName; //get ip foreach (IPAddress ip in Dns.GetHostAddresses(computer.Name)) { if (((ip != IPAddress.Any) || (ip != IPAddress.Loopback)) && (ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)) { computer.Ip = ip.ToString(); } } computer.UserName = Environment.UserName; computer.OsVersion = Environment.OSVersion.ToString(); return computer; } } }
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)