示例#1
0
        internal static void Register(ChoBaseProfile profile)
        {
            if (profile == null || profile.ProfilerName.IsNullOrWhiteSpace())
            {
                return;
            }
            if (profile.ProfilerName == ChoProfile.GLOBAL_PROFILE_NAME ||
                profile.ProfilerName == ChoProfile.NULL_PROFILE_NAME)
            {
                return;
            }

            lock (_profileCacheLock)
            {
                if (!_profileCache.ContainsKey(profile.ProfilerName))
                {
                    _profileCache.AddOrUpdate(profile.ProfilerName, profile, (k, v) => v);
                }

                if (_profileStack == null)
                {
                    _profileStack = new Stack <ChoBaseProfile>();
                }

                _profileStack.Push(profile);
                _contextProfile = profile;
                if (_contextProfile == null)
                {
                    _contextProfile = ChoProfile.Default;
                }
            }
        }
示例#2
0
        internal ChoBaseProfile(bool condition, string name, string msg, ChoBaseProfile outerProfile, bool delayedStartProfile, string startActions, string stopActions)
        {
            _condition    = condition;
            _name         = name;
            _outerProfile = outerProfile;
            if (_outerProfile == null)
            {
                _profileBackingStore = ChoProfileBackingStoreManager.GetProfileBackingStore(name, startActions, stopActions);
            }
            _delayedStartProfile = delayedStartProfile;
            if (_condition)
            {
                if (!msg.IsNullOrEmpty())
                {
                    _msg = msg;
                }
                else if (!_name.IsNullOrEmpty())
                {
                    _msg = String.Format(_msg, _name);
                }
                else
                {
                    _msg = ChoProfile.GetDefaultMsg(ChoStackTrace.GetStackFrame(GetType().Namespace));
                }
            }

            if (ChoTraceSettings.Me.IndentProfiling)
            {
                if (outerProfile != null)
                {
                    _indent = outerProfile.Indent + 1;
                }
            }
            if (!_delayedStartProfile)
            {
                StartIfNotStarted();
            }

            if (_outerProfile is ChoProfileContainer)
            {
                ((ChoProfileContainer)_outerProfile).Add(this);
            }
        }
示例#3
0
        internal static void Unregister(ChoBaseProfile profile)
        {
            if (profile == null || profile.ProfilerName.IsNullOrWhiteSpace())
            {
                return;
            }
            if (profile.ProfilerName == ChoProfile.GLOBAL_PROFILE_NAME ||
                profile.ProfilerName == ChoProfile.NULL_PROFILE_NAME)
            {
                return;
            }

            lock (_profileCacheLock)
            {
                ChoBaseProfile x = null;
                if (_profileCache.ContainsKey(profile.ProfilerName))
                {
                    _profileCache.TryRemove(profile.ProfilerName, out x);
                }

                if (_profileStack != null)
                {
                    if (_profileStack.Count > 0)
                    {
                        _profileStack.Pop();
                    }

                    if (_profileStack.Count > 0)
                    {
                        _contextProfile = _profileStack.Peek();
                    }
                    else
                    {
                        _contextProfile = null;
                    }
                }

                if (_contextProfile == null)
                {
                    _contextProfile = ChoProfile.Default;
                }
            }
        }
示例#4
0
 private ChoBaseProfile(bool condition, string name, string msg, ChoBaseProfile outerProfile)
     : this(condition, name, msg, outerProfile, false, null, null)
 {
 }
示例#5
0
 public ChoBaseProfile(string msg, ChoBaseProfile outerProfile)
     : this(_defaultCondition, DEFAULT_NAME, msg, outerProfile)
 {
 }
示例#6
0
 internal ChoStreamProfile(bool condition, string name, string msg, ChoBaseProfile outerProfile, bool delayedStartProfile, string startActions, string stopActions)
     : base(condition, name, msg, outerProfile, delayedStartProfile, startActions, stopActions)
 {
 }
示例#7
0
 public ChoStreamProfile(string msg, ChoBaseProfile outerProfile)
     : base(msg, outerProfile)
 {
 }
示例#8
0
 public ChoBufferProfile(string msg, ChoBaseProfile outerProfile)
     : base(msg, outerProfile)
 {
 }