public void Lox_ScopeDomains() { UT_INIT(); // we have tell alox to include more directories in the scope path Log.ClearSourcePathTrimRules( Reach.Global, false); Log.SetSourcePathTrimRule( "*/alox/src.cs/", Inclusion.Exclude ); Lox lox= new Lox( "ReleaseLox" ); TextLogger consoleLogger= Lox.CreateConsoleLogger(); MemoryLogger ml= new MemoryLogger(); ml.MetaInfo.Format._()._("@%D#"); lox.SetVerbosity(ml, Verbosity.Verbose ); lox.SetVerbosity(consoleLogger, Verbosity.Verbose ); lox.SetVerbosity(consoleLogger, Verbosity.Verbose, ALox.InternalDomains ); // scope global lox.SetDomain( "REPLACE", Scope.Global ); lox.Info( "" , "" ); SDCHECK_RL( "@/REPLACE#" ,ml ); lox.SetDomain( "GLOBAL", Scope.Global ); lox.Info( "" , "" ); SDCHECK_RL( "@/GLOBAL#" ,ml ); lox.SetDomain( null, Scope.Global ); lox.Info( "" , "" ); SDCHECK_RL( "@/#" ,ml ); // scope source lox.SetDomain( "REPLACE", Scope.Filename ); lox.Info( "" , "" ); CICHECK_RL( "@/REPLACE#" ,ml ); lox.SetDomain( "FILE", Scope.Filename ); lox.Info( "" , "" ); CICHECK_RL( "@/FILE#" ,ml ); // scope method lox.SetDomain( "REPLACE", Scope.Method ); lox.Info( "" , "" ); CICHECK_RL( "@/FILE/REPLACE#" ,ml ); lox.SetDomain( "Method", Scope.Method ); lox.Info( "" , "" ); CICHECK_RL( "@/FILE/METHOD#" ,ml ); lox.SetDomain( "/ABS", Scope.Method ); lox.Info( "" , "" ); CICHECK_RL( "@/ABS#" ,ml ); // unset method with null lox.SetDomain( null, Scope.Method ); lox.Info( "" , "" ); CICHECK_RL( "@/FILE#" ,ml ); // unset method with "" lox.SetDomain( "/METHOD", Scope.Method ); lox.Info( "" , "" ); CICHECK_RL( "@/METHOD#" ,ml ); lox.SetDomain( "", Scope.Method ); lox.Info( "" , "" ); CICHECK_RL( "@/FILE#" ,ml ); lox.SetDomain( "Method", Scope.Method ); lox.Info( "" , "" ); CICHECK_RL( "@/FILE/METHOD#" ,ml ); // source path lox.SetDomain( "REPLACE", Scope.Path ); lox.Info( "" , "" ); CICHECK_RL( "@/REPLACE/FILE/METHOD#" ,ml ); lox.SetDomain( "PATH", Scope.Path ); lox.Info( "" , "" ); CICHECK_RL( "@/PATH/FILE/METHOD#" ,ml ); lox.SetDomain( "REPLACE", Scope.Path, 1 ); lox.Info( "" , "" ); CICHECK_RL( "@/REPLACE/PATH/FILE/METHOD#" ,ml ); lox.SetDomain( "PO1", Scope.Path, 1 ); lox.Info( "" , "" ); CICHECK_RL( "@/PO1/PATH/FILE/METHOD#" ,ml ); lox.SetDomain( "REPLACE", Scope.Path, 2 ); lox.Info( "" , "" ); CICHECK_RL( "@/REPLACE/PO1/PATH/FILE/METHOD#",ml ); lox.SetDomain( "PO2", Scope.Path, 2 ); lox.Info( "" , "" ); CICHECK_RL( "@/PO2/PO1/PATH/FILE/METHOD#" ,ml ); lox.SetDomain( "GLOBAL", Scope.Global ); lox.Info( "" , "" ); CICHECK_RL( "@/GLOBAL/PO2/PO1/PATH/FILE/METHOD#" , ml ); // remove all previous scope domains lox.SetDomain( "", Scope.Global ); lox.SetDomain( "", Scope.Path ); lox.SetDomain( "", Scope.Path ,1 ); lox.SetDomain( "", Scope.Path ,2 ); lox.SetDomain( "", Scope.Filename ); lox.SetDomain( "", Scope.Method ); lox.Info( "LOC", "" ); SDCHECK_RL( "@/LOC#" ,ml ); // Thread-related lox.SetDomain( "T_O", Scope.ThreadOuter ); lox.Info( "" , "" ); SDCHECK_RL( "@/T_O#" ,ml ); lox.SetDomain( "GL", Scope.Global ); lox.Info( "" , "" ); SDCHECK_RL( "@/GL/T_O#" ,ml ); lox.SetDomain( "MET", Scope.Method ); lox.Info( "" , "" ); CICHECK_RL( "@/GL/T_O/MET#" ,ml ); lox.Info( "LOC", "" ); CICHECK_RL( "@/GL/T_O/MET/LOC#" ,ml ); lox.SetDomain( "T_I", Scope.ThreadInner ); lox.Info( "" , "" ); CICHECK_RL( "@/GL/T_O/MET/T_I#" ,ml ); lox.Info( "LOC", "" ); CICHECK_RL( "@/GL/T_O/MET/LOC/T_I#" ,ml ); lox.SetDomain( "T_O2", Scope.ThreadOuter ); lox.Info( "" , "" ); CICHECK_RL( "@/GL/T_O/T_O2/MET/T_I#" ,ml ); lox.SetDomain( "T_I2", Scope.ThreadInner ); lox.Info( "" , "" ); CICHECK_RL( "@/GL/T_O/T_O2/MET/T_I/T_I2#" ,ml ); lox.SetDomain( "/T_O3",Scope.ThreadOuter ); lox.Info( "" , "" ); CICHECK_RL( "@/T_O3/MET/T_I/T_I2#" ,ml ); lox.SetDomain( "/T_I3",Scope.ThreadInner ); lox.Info( "" , "" ); SDCHECK_RL( "@/T_I3#" ,ml ); lox.SetDomain( "", Scope.Method ); lox.Info( "" , "" ); SDCHECK_RL( "@/T_I3#" ,ml ); lox.SetDomain ( "" ,Scope.ThreadInner ); lox.Info( "" , "" ); SDCHECK_RL( "@/T_O3/T_I/T_I2#" ,ml ); lox.RemoveThreadDomain( "T_IXX",Scope.ThreadInner ); lox.Info( "" , "" ); SDCHECK_RL( "@/T_O3/T_I/T_I2#" ,ml ); lox.RemoveThreadDomain( "T_I" ,Scope.ThreadInner ); lox.Info( "" , "" ); SDCHECK_RL( "@/T_O3/T_I2#" ,ml ); lox.RemoveThreadDomain( "" ,Scope.ThreadInner ); lox.Info( "" , "" ); SDCHECK_RL( "@/T_O3/T_I2#" ,ml ); lox.SetDomain ( "" ,Scope.ThreadInner ); lox.Info( "" , "" ); SDCHECK_RL( "@/T_O3#" ,ml ); lox.SetDomain ( "" ,Scope.ThreadOuter ); lox.Info( "" , "" ); SDCHECK_RL( "@/GL/T_O/T_O2#" ,ml ); lox.SetDomain ( "T_O3", Scope.ThreadOuter ); lox.Info( "" , "" ); SDCHECK_RL( "@/GL/T_O/T_O2/T_O3#",ml ); lox.RemoveThreadDomain( "T_O2" ,Scope.ThreadOuter ); lox.Info( "" , "" ); SDCHECK_RL( "@/GL/T_O/T_O3#" ,ml ); lox.RemoveThreadDomain( "T_O" ,Scope.ThreadOuter ); lox.Info( "" , "" ); SDCHECK_RL( "@/GL/T_O3#" ,ml ); lox.SetDomain ( "" ,Scope.ThreadOuter ); lox.Info( "" , "" ); SDCHECK_RL( "@/GL#" ,ml ); lox.SetDomain ( "" ,Scope.Global ); lox.Info( "" , "" ); SDCHECK_RL( "@/#" ,ml ); // second thread Thread thread= new Thread( new ParameterizedThreadStart( DomainTestThreadRun_RL ) ); lox.SetDomain( "THIS_THREAD", Scope.ThreadOuter ); lox.SetDomain( "OTHER_THREAD", Scope.ThreadOuter, thread ); thread.Start( lox ); while( thread.IsAlive ) ALIB.SleepMillis(1); UT_EQ( "@/OTHER_THREAD/DTT#", ml.MemoryLog ); ml.MemoryLog._(); ml.AutoSizes.Reset(); lox.Info( "ME", "" ); UT_EQ( "@/THIS_THREAD/ME#" , ml.MemoryLog ); ml.MemoryLog._(); ml.AutoSizes.Reset(); // cleanup lox.RemoveLogger( consoleLogger ); lox.RemoveLogger( ml ); }