System.Diagnostics.LogSwitch.AddChildSwitch C# (CSharp) Method

AddChildSwitch() private method

private AddChildSwitch ( LogSwitch child ) : void
child LogSwitch
return void
    	private  void AddChildSwitch (LogSwitch child)
    	{
    		if (iChildArraySize <= iNumChildren)
    		{
    				int iIncreasedSize;
    
    				if (iChildArraySize == 0)
    					iIncreasedSize = 10;
    				else
    					iIncreasedSize = (iChildArraySize * 3) / 2;
    
    				// increase child array size in chunks of 4
    				LogSwitch[] newChildSwitchArray = new LogSwitch [iIncreasedSize];
    
    				// copy the old array objects into the new one.
    	            if (iNumChildren > 0) 
    					Array.Copy(ChildSwitch, newChildSwitchArray, iNumChildren);
    
    				iChildArraySize = iIncreasedSize;
    
    		        ChildSwitch = newChildSwitchArray;
    		}
    
    		ChildSwitch [iNumChildren++] = child;			
    	}
    

Usage Example

Beispiel #1
0
 	// Constructs a LogSwitch.  A LogSwitch is used to categorize log messages.
 	// 
 	// All switches (except for the global LogSwitch) have a parent LogSwitch.
 	//
 	/// <include file='doc\LogSwitch.uex' path='docs/doc[@for="LogSwitch.LogSwitch"]/*' />
 	public LogSwitch(String name, String description, LogSwitch parent)
 	{
 		if ((name != null) && (parent != null) )
 		{
 			if (name.Length == 0)
 				throw new ArgumentOutOfRangeException (
 				"Name", Environment.GetResourceString(
 					"Namelength_0"));
 				
 			strName = name;
 			strDescription = description;
 			iLevel = LoggingLevels.ErrorLevel;
 			iOldLevel = iLevel;
 
 			// update the parent switch to reflect this child switch
 			parent.AddChildSwitch (this);
 
 			ParentSwitch = parent;
 
 			ChildSwitch  = null;
 			iNumChildren = 0;
 			iChildArraySize = 0;
 
 			Log.m_Hashtable.Add (strName, this);			
 
 			// Call into the EE to let it know about the creation of
 			// this switch
 			Log.AddLogSwitch (this);
 
 			// update switch count
 			Log.iNumOfSwitches++;
 		}
 		else
 			throw new ArgumentNullException ((name==null ? "name" : "parent"));
 	}
All Usage Examples Of System.Diagnostics.LogSwitch::AddChildSwitch