internal static IChoProfile GetContext(StackFrame frame) { string name = null; MemberInfo method = frame.GetMethod(); if (method != null) { name = method.Name; ChoProfileAttribute profileAttribute = ChoType.GetMemberAttributeByBaseType <ChoProfileAttribute>(method); if (profileAttribute == null) { var type = method.DeclaringType; name = type.Name; profileAttribute = ChoType.GetAttribute(type, typeof(ChoProfileAttribute)) as ChoProfileAttribute; } if (profileAttribute != null) { if (_profileAttribute == profileAttribute) { return(_contextProfile); } else { _profileAttribute = profileAttribute; } if (profileAttribute.Name.IsNullOrWhiteSpace()) { profileAttribute.Name = name; } if (profileAttribute.OuterProfileName.IsNullOrWhiteSpace()) { _contextProfile = profileAttribute.ConstructProfile(null, null); } else { _contextProfile = profileAttribute.ConstructProfile(null, GetProfile(profileAttribute.OuterProfileName)); } } } return(_contextProfile); }
private static IChoProfile Register(string name, string profileName, MemberInfo memberInfo, string typeProfileName, ChoProfileAttribute memberProfileAttribute, ChoProfileAttribute typeProfileAttribute) { lock (MemberProfileCache.SyncRoot) { IChoProfile profile = null; if (MemberProfileCache.TryGetValue(profileName, out profile)) { return(profile); } if (!String.IsNullOrEmpty(typeProfileName) && !MemberProfileCache.ContainsKey(typeProfileName)) { if (typeProfileAttribute != null) { IChoProfile profile1 = typeProfileAttribute.ConstructProfile(ChoThreadLocalStorage.Target, null); //SetAsNotDisposed(profile1, false); MemberProfileCache.Add(typeProfileName, profile1); } else { MemberProfileCache.Add(typeProfileName, GlobalProfile); } } if (memberProfileAttribute == null) { return(MemberProfileCache[typeProfileName]); } else { IChoProfile profile1 = memberProfileAttribute.ConstructProfile(ChoThreadLocalStorage.Target, MemberProfileCache[typeProfileName]); //SetAsNotDisposed(profile1, false); MemberProfileCache.Add(profileName, profile1); return(MemberProfileCache[profileName]); } } }