Ejemplo n.º 1
0
        protected override void Dispose(bool finalize)
        {
            if (!finalize)
            {
                return;
            }

            try
            {
                Clear();
                if (!DelayedStartProfile || (DelayedStartProfile && Started))
                {
                    if (TraceOnDispose)
                    {
                        if (Condition)
                        {
                            string msg = Environment.NewLine + ToString().Indent(Indent - 1);
                            if (!String.IsNullOrEmpty(FilePath))
                            {
                                //if (Mode == ChoProfileIntializationAction.Roll)
                                //    ChoBufferProfile.RollNWriteLine(FilePath, msg);
                                //else if (Mode == ChoProfileIntializationAction.Truncate)
                                //    ChoBufferProfile.CleanNWriteLine(FilePath, msg);
                                //else
                                //    ChoBufferProfile.WriteLine(FilePath, msg);
                            }
                            else if (TextWriter != null)
                            {
                                TextWriter.Write(msg);
                                TextWriter.Flush();
                            }
                            else
                            {
                                ChoTrace.WriteIf(Condition, ChoStackTrace.GetStackFrame(GetType()), msg);
                            }
                        }
                    }
                    //else if (OuterProfile != null)
                    //    OuterProfile.Append(ToString());
                }

                //ChoProfile.Unregister(CanDispose);

                //if (!finalize)
                //    GC.SuppressFinalize(this);
            }
            catch (Exception ex)
            {
                ChoTrace.Write(ex);
            }
            finally
            {
                IsDisposed = true;
            }
            ChoProfile.Unregister(this);
        }
Ejemplo n.º 2
0
        public static void WriteIf(bool condition, string msg)
        {
            IChoProfile profile = GetDefaultContext(new StackFrame(1));

            if (profile != null)
            {
                profile.AppendIf(condition, msg);
            }
            else
            {
                ChoTrace.WriteIf(condition, msg);
            }
        }
Ejemplo n.º 3
0
        public static void WriteIf(bool condition, string format, params object[] args)
        {
            IChoProfile profile = GetDefaultContext(new StackFrame(1));

            if (profile != null)
            {
                profile.AppendIf(condition, String.Format(format, args));
            }
            else
            {
                ChoTrace.WriteIf(condition, String.Format(format, args));
            }
        }
Ejemplo n.º 4
0
        private void _WriteIf(bool condition, string msg)
        {
            if (!condition)
            {
                return;
            }

            if (ChoTraceSettings.Me.IndentProfiling)
            {
                msg = msg.Indent(_indent + 1);
            }

            ChoTrace.WriteIf(condition, ChoStackTrace.GetStackFrame(typeof(ChoProfile)), msg);
        }