/// <summary> /// Returns performance settings instance for a NetOffice wrapper class /// </summary> /// <param name="componentName">name of the component. for example:ExcelApi</param> /// <param name="entityName">name of the class. for example:Range or Application</param> /// <param name="methodName">method or property name. for example: Visible or Activate</param> /// <returns>settings instance</returns> public PerformanceTraceSetting this[string componentName, string entityName, string methodName] { get { if (String.IsNullOrWhiteSpace(componentName)) { throw new ArgumentNullException("componentName"); } if (String.IsNullOrWhiteSpace(entityName)) { throw new ArgumentNullException("entityName"); } if (String.IsNullOrWhiteSpace(methodName)) { throw new ArgumentNullException("methodName"); } lock (_lock) { PerformanceTraceSettingCollection list = null; if (!_repository.TryGetValue(componentName, out list)) { list = new PerformanceTraceSettingCollection(); _repository.Add(componentName, list); } return(list[entityName, methodName]); } } }
internal bool StartMeasureTime(string componentName, string entityName, string methodName, CallType callType) { PerformanceTraceSettingCollection list = null; if (_repository.TryGetValue(componentName, out list)) { return(list.TryStartMeasureTime(entityName, methodName, callType)); } else { return(false); } }
internal void StopMeasureTime(string componentName, string entityName, string methodName, params object[] arguments) { DateTime now = DateTime.Now; PerformanceTraceSettingCollection list = null; if (_repository.TryGetValue(componentName, out list)) { IEnumerable <PerformanceTraceSetting> settings = list.GetTargetEnabledSettings(entityName, methodName); foreach (var item in settings) { TimeSpan ts = now - item.LastCallTime; if (ts.TotalMilliseconds >= item.IntervalMS) { List <string> args = new List <string>(); foreach (var arg in arguments) { args.Add((null == arg || arg == Type.Missing) ? "<Empty>" : arg.ToString()); } RaiseAlert(componentName, entityName, methodName, ts.TotalMilliseconds, ts.Ticks, item.LastCallType, args.ToArray()); return; } } } }