Beispiel #1
0
        private static LoggerOptionsAttribute GetCallingMethodOptions(string customCategory)
        {
            StackFrame[] frames   = new StackTrace(2).GetFrames();
            int          hashCode = frames.Aggregate(0, (v, a) => v ^ a.GetMethod().GetHashCode() + 13);
            ConcurrentDictionary <MethodBase, LoggerOptionsAttribute> dictionary = attributeCaches.EnsureKeyValue(hashCode);
            LoggerOptionsAttribute attribute = dictionary.EnsureKeyValue(frames[0].GetMethod(), () => GetCallingMethodOptions(dictionary, frames));

            attribute          = attribute.Clone();
            attribute.Category = customCategory ?? attribute.Category ?? "General";
            return(attribute);
        }
Beispiel #2
0
 public override int GetHashCode()
 {
     return(StackTrace.Aggregate(123, (current, stackFrame) => (current ^ stackFrame.DisplayString.GetHashCode())));
 }