GetValue() public method

Gets a stat value for the specified server.
public GetValue ( IPEndPoint server, StatItem item ) : long
server System.Net.IPEndPoint The adress of the server. If is specified it will return the sum of all server stat values.
item StatItem The stat to be returned
return long
        public InstanceStatistics(System.Net.IPEndPoint serverEndPoint, Server server, Instance instance, ServerStats serverStats, State serviceState)
        {
            string memcachedFileVersion = null;

            if (File.Exists(Configuration.Default.MemcachedBinarySource) == true)
                memcachedFileVersion = FileVersionInfo.GetVersionInfo(Configuration.Default.MemcachedBinarySource).FileVersion;

            _serverName = server.ServerName;
            _instanceName = instance.DisplayName;
            _serviceState = serviceState;

            Instance = instance;

            _statusIconIndex = StatusIconIndex.CommunicationError;
            _statusTooltip = Constants.TooltipCommunicationError;

            if (serverStats != null && serverStats.GetRaw(serverEndPoint, StatItem.Version) != null)
            {

                foreach (StatItem statItem in Enum.GetValues(typeof(Enyim.Caching.Memcached.StatItem)))
                {
                    switch (statItem)
                    {
                        case StatItem.BytesRead:
                            _bytesRead = serverStats.GetValue(serverEndPoint, statItem);
                            break;

                        case StatItem.BytesWritten:
                            _bytesWritten = serverStats.GetValue(serverEndPoint, statItem);
                            break;

                        case StatItem.ConnectionCount:
                            _connectionCount = serverStats.GetValue(serverEndPoint, statItem);
                            break;

                        case StatItem.ConnectionStructures:
                            _connectionStructures = serverStats.GetValue(serverEndPoint, statItem);
                            break;

                        case StatItem.GetCount:
                            _getCount = serverStats.GetValue(serverEndPoint, statItem);
                            break;

                        case StatItem.GetHits:
                            _getHits = serverStats.GetValue(serverEndPoint, statItem);
                            break;

                        case StatItem.GetMisses:
                            _getMisses = serverStats.GetValue(serverEndPoint, statItem);
                            break;

                        case StatItem.ItemCount:
                            _itemCount = serverStats.GetValue(serverEndPoint, statItem);
                            break;

                        case StatItem.MaxBytes:
                            _maxBytes = serverStats.GetValue(serverEndPoint, statItem);
                            break;

                        case StatItem.ServerTime:
                            string serverTimeRaw = serverStats.GetRaw(serverEndPoint, statItem);
                            int serverTimeSeconds;
                            if (serverTimeRaw != null && Int32.TryParse(serverTimeRaw, out serverTimeSeconds) == true)
                                _serverTime = new DateTime(1970, 1, 1).AddSeconds(serverTimeSeconds).ToLocalTime().ToString();
                            else
                                _serverTime = "<unknown>";
                            break;

                        case StatItem.SetCount:
                            _setCount = serverStats.GetValue(serverEndPoint, statItem);
                            break;

                        case StatItem.TotalConnections:
                            _totalConnections = serverStats.GetValue(serverEndPoint, statItem);
                            break;

                        case StatItem.TotalItems:
                            _totalItems = serverStats.GetValue(serverEndPoint, statItem);
                            break;

                        case StatItem.Uptime:
                            string uptimeRaw = serverStats.GetRaw(serverEndPoint, statItem);
                            int uptimeSeconds;
                            if (uptimeRaw != null && Int32.TryParse(uptimeRaw, out uptimeSeconds) == true)
                                _uptime = TimeSpan.FromSeconds(uptimeSeconds).ToString();
                            else
                                _uptime = "<unknown>";
                            break;

                        case StatItem.UsedBytes:
                            _usedBytes = serverStats.GetValue(serverEndPoint, statItem);
                            break;

                        case StatItem.Version:
                            _version = serverStats.GetRaw(serverEndPoint, statItem);
                            break;
                    }
                }
            }

            if (_serviceState != State.Running && _serviceState != State.Unknown)
            {
                _statusIconIndex = StatusIconIndex.ServiceDown;
                _statusTooltip = Constants.TooltipServiceDown;
            }
            else if (_serviceState == State.Unknown)
            {
                _statusIconIndex = StatusIconIndex.ServiceNonControllable;
                _statusTooltip = Constants.TooltipServiceNonControllable;
            }
            else if (_version == null || _version == String.Empty)
            {
                _statusIconIndex = StatusIconIndex.CommunicationError;
                _statusTooltip = Constants.TooltipCommunicationError;
            }
            else if (memcachedFileVersion != null && memcachedFileVersion != _version)
            {
                _statusIconIndex = StatusIconIndex.NeedsUpdate;
                _statusTooltip = Constants.TooltipNeedsUpdate;
            }
            else
            {
                _statusIconIndex = StatusIconIndex.Up;
                _statusTooltip = Constants.TooltipUp;
            }
        }