/// <summary> /// 检测缓存是否存在 /// </summary> /// <param name="value">日志信息</param> /// <param name="isQueue">是否缓存队列</param> /// <returns>是否继续输出日志</returns> private bool checkCache(debug value, bool isQueue) { hashString key = value.ToString(); if (isQueue) { Monitor.Enter(cacheLock); try { if (cache.Get(key, false)) { return(false); } cache.Set(key, true); if (cache.Count > maxCacheCount) { cache.UnsafePopValue(); } } finally { Monitor.Exit(cacheLock); } return(true); } if (key.Equals(lastCache)) { return(false); } lastCache = key; return(true); }
/// <summary> /// 加载程序集 /// </summary> /// <param name="assemblyFileName">程序集文件名</param> public Assembly Load(string assemblyFileName) { if (!string.IsNullOrEmpty(assemblyFileName)) { Assembly assembly; hashString nameKey = assemblyFileName; if (assemblys.TryGetValue(nameKey, out assembly)) { return(assembly); } try { if (assemblyFileName.Length > 4 && assemblyFileName.EndsWith(".dll")) { assembly = Assembly.LoadFrom(assemblyFileName.Substring(0, assemblyFileName.Length - 4)); } else { assembly = Assembly.LoadFrom(assemblyFileName); } assemblys[nameKey] = assembly; return(assembly); } catch (Exception error) { log.Error.Add(error, "动态应用程序域加载程序集 " + assemblyFileName + " 失败", false); } } return(null); }
/// <summary> /// 搜索对象 /// </summary> private void searchValue() { if (OnValue != null) { OnValue(); if (IsStop) { return; } } if (!values.Contains(Value)) { values.Add(Value); if (OnNewValue != null) { OnNewValue(); if (IsStop) { return; } } hashString typeKey = Value.Type.FullName; if (!types.Contains(typeKey)) { types.Add(typeKey); if (OnType != null) { OnType(); if (IsStop) { return; } } } if (Value.Values != null) { field[] fields = Value.Type.Fields; int index = 0; if (fields == null) { foreach (value value in Value.Values) { if (IsStop) { break; } if (value != null) { path.Add(index.toString()); Value = value; searchValue(); path.UnsafePop(); } ++index; } } else { foreach (value value in Value.Values) { if (IsStop) { break; } if (value != null) { path.Add(fields[index].Name); Value = value; searchValue(); path.UnsafePop(); } ++index; } } } } }