/// <summary> /// 写入未支持行 /// </summary> /// <param name="handler">处理器</param> private void WriteNotSupportLine(IMonitorHandler handler) { outputs.Add(new Dictionary <string, object> { { "name", handler.Name }, { "value", "code.notSupport" }, { "unit", string.Empty }, { "tags", handler.Tags }, }); }
public ProductsMonitorService(IDateTimeNow dateTimeNow) { _dateTimeNow = dateTimeNow; _modelPortfolioRepository = new ModelPortfolioRepository(); _behaviourFactory = new BehaviourFactory(); _productRepository = new ProductRepository(_modelPortfolioRepository, _behaviourFactory, _dateTimeNow); _rebalancerHandler = new RebalanceHandler(_behaviourFactory); _payoutHandler = new PayoutHandler(_behaviourFactory); _monitorFactory = new MonitorFactory(_dateTimeNow, _rebalancerHandler, _payoutHandler); _monitorHandler = new MonitorHandler(_monitorFactory); }
public Monitor(IMonitorHandler handler, String ipPort) { _handler = handler; _playersHandler = new PlayersHandler(_handler); ParseIp(ipPort); _socket = new UdpClient(_sIp, _port); new Thread(Receiver).Start(); SendPlayersRequest(); }
private void InitializeMappings() { using (ILogMethod method = Log.LogMethod(this.DYN_MODULE_NAME, "InitializeMappings")) { IDictionary <string, IMonitorHandler> handlerInstances = null; try { _handlerMappings = new StringDictionary <IMonitorHandler>(); handlerInstances = new StringDictionary <IMonitorHandler>(); foreach (var mappingType in _handlerMappingTypes.AsParallel()) { MonitorHandlerBase handler = null; string mappingTypeKey = mappingType.Value.FullName; if (handlerInstances.ContainsKey(mappingTypeKey)) { handler = handlerInstances[mappingTypeKey] as MonitorHandlerBase; } else { handler = Activator.CreateInstance(mappingType.Value, true) as MonitorHandlerBase; handlerInstances.Add(mappingTypeKey, handler); } if (handler == null) { continue; } if (!_handlerMappings.ContainsKey(mappingType.Key)) { _handlerMappings.Add(mappingType.Key, handler); } } const string faultKey = "-1_-1"; _faultHandler = _handlerMappings[faultKey]; } catch (Exception ex) { method.Exception(ex); } finally { if (handlerInstances != null) { handlerInstances.Clear(); handlerInstances = null; } } } }
/// <summary> /// 写入一条监控信息 /// </summary> /// <param name="handler">处理器</param> public void WriteLine(IMonitorHandler handler) { try { outputs.Add(new Dictionary <string, object> { { "name", handler.Name }, { "value", handler.Value }, { "unit", handler.Unit }, { "tags", handler.Tags }, }); } catch (TypeLoadException) { WriteNotSupportLine(handler); } catch (MissingMethodException) { WriteNotSupportLine(handler); } }
private void InitializeMappings() { using (ILogMethod method = Log.LogMethod(this.DYN_MODULE_NAME, "InitializeMappings")) { IDictionary<string, IMonitorHandler> handlerInstances = null; try { _handlerMappings = new StringDictionary<IMonitorHandler>(); handlerInstances = new StringDictionary<IMonitorHandler>(); foreach (var mappingType in _handlerMappingTypes.AsParallel()) { MonitorHandlerBase handler = null; string mappingTypeKey = mappingType.Value.FullName; if (handlerInstances.ContainsKey(mappingTypeKey)) { handler = handlerInstances[mappingTypeKey] as MonitorHandlerBase; } else { handler = Activator.CreateInstance(mappingType.Value, true) as MonitorHandlerBase; handlerInstances.Add(mappingTypeKey, handler); } if (handler == null) continue; if (!_handlerMappings.ContainsKey(mappingType.Key)) { _handlerMappings.Add(mappingType.Key, handler); } } const string faultKey = "-1_-1"; _faultHandler = _handlerMappings[faultKey]; } catch (Exception ex) { method.Exception(ex); } finally { if (handlerInstances != null) { handlerInstances.Clear(); handlerInstances = null; } } } }
public PlayersHandler(IMonitorHandler endpointHandler) { _endpointHandler = endpointHandler; }