Example #1
0
        public void ActivityThenLogical()
        {
            var source = new ExtendedTraceSource();

            using (var scope = new ActivityScope(source, "MultipleTracedClassTestScope"))
            {
                var sample1 = new SampleClass();

                sample1 = Extensions.Wrap<SampleClass>(sample1);

                var sample2 = new SampleClass();

                var oppId = "MyLogicalOpp";

                using (var lScope = new LogicalOperationScope(source, "MyLogicalScope"))
                {
                    sample1.Method1();

                    using (var scope2 = new ActivityScope(source, "Sub Activity"))
                    {
                        using (var lScope1 = new LogicalOperationScope(source, "Scope 2"))
                            sample1.TraceInformation("test1");
                        sample2.TraceInformation("test2");
                    }
                }

                var listeners = sample2.Trace.Listeners;
                var listener = listeners.OfType<TransactionTraceListener>().First();

                var log = listener.GetTransaction();
            }
        }
Example #2
0
        public void TracedClassTest()
        {
            var sample = new SampleClass();

            sample.Method1();
            sample.Method2("1", "2");

            sample.TraceInformation("---------------------------------------");

            sample = Extensions.Wrap<SampleClass>(sample);

            sample.Method1();
            sample.Method2("1", "2");

            var listeners = sample.Trace.Listeners;
            var listener = listeners.OfType<TransactionTraceListener>().First();

            sample.Indent();

            sample.TraceData(TraceEventType.Error, 100, "Error1");

            sample.UnIndent();

            sample.TraceData(TraceEventType.Verbose, 101, "End");
            var msg = listener.GetTransaction();

            Trace.WriteLine(msg.Length);
        }