Example #1
0
        internal ChoBufferProfileEx(bool condition, string name, string filePath, ChoProfileIntializationAction mode, TextWriter streamWriter, string msg, IChoProfile outerProfile, bool register)
        {
            _condition = condition;
            _mode      = mode;
            FilePath   = String.IsNullOrEmpty(filePath) ? filePath : ChoString.ExpandProperties(filePath);
            TextWriter = streamWriter;
            //OuterProfile = outerProfile;

            if (String.IsNullOrEmpty(msg))
            {
                msg = ChoProfile.GetDefaultMsg(ChoStackTrace.GetStackFrame(GetType().Namespace));
            }

            msg = ChoString.ExpandProperties(msg);

            if (_condition)
            {
                _formattedMsg.AppendFormat("{0} {{{1}", msg, Environment.NewLine);
            }

            if (register)
            {
                ChoProfile.Register(name, this, ChoStackTrace.GetStackFrame(GetType().Namespace), false);
            }

            //if (OuterProfile is ChoProfileContainer)
            //    ((ChoProfileContainer)OuterProfile).Add(this);
        }
Example #2
0
        internal ChoBaseProfile(bool condition, string name, string msg, IChoProfile outerProfile, bool delayedStartProfile, string startActions, string stopActions)
        {
            _condition = condition;
            _name      = name.IsNullOrWhiteSpace() || name == ChoProfile.DEFAULT_PROFILE_NAME ? String.Format("Profile_{0}".FormatString(ChoRandom.NextRandom())) : name;
            if (outerProfile != ChoProfile.NULL)
            {
                _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)
                {
                    if (outerProfile.ProfilerName != ChoProfile.GLOBAL_PROFILE_NAME && outerProfile.ProfilerName != ChoProfile.NULL_PROFILE_NAME)
                    {
                        _indent = outerProfile.Indent + 1;
                    }
                }
            }
            if (!_delayedStartProfile)
            {
                StartIfNotStarted();
            }

            if (_outerProfile is ChoProfileContainer)
            {
                ((ChoProfileContainer)_outerProfile).Add(this);
                _parentProfile = outerProfile;
            }

            if (name != ChoProfile.GLOBAL_PROFILE_NAME && name != ChoProfile.NULL_PROFILE_NAME && name != ChoProfile.CURRENT_CONTEXT_PROFILE /* && outerProfile != null */)
            {
                ChoProfile.Register(this);
                _registered = true;
            }
        }