Tracer.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WF / Activities / Rules / Tracer.cs / 1305376 / Tracer.cs

                            // ---------------------------------------------------------------------------- 
// Copyright (C) 2006 Microsoft Corporation All Rights Reserved
// ---------------------------------------------------------------------------

using System; 
using System.Collections.Generic;
using System.Diagnostics; 
using System.Globalization; 
using System.Workflow.ComponentModel;
 
namespace System.Workflow.Activities.Rules
{
 	internal class Tracer
	{ 
		private string tracePrefix;
 
		// get the localized trace messages once 
 		private static string traceRuleIdentifier = Messages.TraceRuleIdentifier;
		private static string traceRuleHeader = Messages.TraceRuleHeader; 
 		private static string traceRuleSetEvaluate = Messages.TraceRuleSetEvaluate;
 		private static string traceRuleEvaluate = Messages.TraceRuleEvaluate;
		private static string traceRuleResult = Messages.TraceRuleResult;
 		private static string traceRuleActions = Messages.TraceRuleActions; 
		private static string traceCondition = Messages.Condition;
		private static string traceThen = Messages.Then; 
		private static string traceElse = Messages.Else; 
 		private static string traceUpdate = Messages.TraceUpdate;
		private static string traceRuleTriggers = Messages.TraceRuleTriggers; 
 		private static string traceRuleConditionDependency = Messages.TraceRuleConditionDependency;
 		private static string traceRuleActionSideEffect = Messages.TraceRuleActionSideEffect;

		internal Tracer(string name, ActivityExecutionContext activityExecutionContext) 
 		{
			if (activityExecutionContext != null) 
				tracePrefix = string.Format(CultureInfo.CurrentCulture, traceRuleIdentifier, name, activityExecutionContext.ContextGuid.ToString()); 
			else
 				tracePrefix = string.Format(CultureInfo.CurrentCulture, traceRuleHeader, name); 
		}

 		internal void StartRuleSet()
 		{ 
			WorkflowActivityTrace.Rules.TraceEvent(TraceEventType.Information, 0, traceRuleSetEvaluate, tracePrefix);
 		} 
 
		internal void StartRule(string ruleName)
		{ 
			WorkflowActivityTrace.Rules.TraceEvent(TraceEventType.Verbose, 0, traceRuleEvaluate, tracePrefix, ruleName);
 		}

		internal void RuleResult(string ruleName, bool result) 
 		{
 			WorkflowActivityTrace.Rules.TraceEvent(TraceEventType.Information, 0, traceRuleResult, tracePrefix, ruleName, result.ToString()); 
		} 

 		internal void StartActions(string ruleName, bool result) 
		{
			WorkflowActivityTrace.Rules.TraceEvent(TraceEventType.Verbose, 0, traceRuleActions, tracePrefix,
				(result ? traceThen : traceElse), ruleName);
 		} 

		internal void TraceUpdate(string ruleName, string otherName) 
 		{ 
 			WorkflowActivityTrace.Rules.TraceEvent(TraceEventType.Verbose, 0, traceUpdate, tracePrefix, ruleName, otherName);
		} 

 		internal void TraceConditionSymbols(string ruleName, ICollection symbols)
		{
			TraceRuleSymbols(traceRuleConditionDependency, traceCondition, ruleName, symbols); 
		}
 
 		internal void TraceThenSymbols(string ruleName, ICollection symbols) 
		{
 			TraceRuleSymbols(traceRuleActionSideEffect, traceThen, ruleName, symbols); 
 		}

		internal void TraceElseSymbols(string ruleName, ICollection symbols)
 		{ 
			TraceRuleSymbols(traceRuleActionSideEffect, traceElse, ruleName, symbols);
		} 
 
		private void TraceRuleSymbols(string message, string clause, string ruleName, ICollection symbols)
 		{ 
			foreach (string symbol in symbols)
 				WorkflowActivityTrace.Rules.TraceEvent(TraceEventType.Verbose, 0, message, tracePrefix, ruleName, clause, symbol);
 		}
 
		internal void TraceThenTriggers(string currentRuleName, ICollection triggeredRules, List ruleStates)
 		{ 
			TraceRuleTriggers(traceThen, currentRuleName, triggeredRules, ruleStates); 
		}
 
		internal void TraceElseTriggers(string currentRuleName, ICollection triggeredRules, List ruleStates)
 		{
			TraceRuleTriggers(traceElse, currentRuleName, triggeredRules, ruleStates);
 		} 

 		private void TraceRuleTriggers(string thenOrElse, string currentRuleName, ICollection triggeredRules, List ruleStates) 
		{ 
 			foreach (int r in triggeredRules)
				WorkflowActivityTrace.Rules.TraceEvent(TraceEventType.Verbose, 0, traceRuleTriggers, tracePrefix, currentRuleName, thenOrElse, ruleStates[r].Rule.Name); 
		}
	}
}

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
// ---------------------------------------------------------------------------- 
// Copyright (C) 2006 Microsoft Corporation All Rights Reserved
// ---------------------------------------------------------------------------

using System; 
using System.Collections.Generic;
using System.Diagnostics; 
using System.Globalization; 
using System.Workflow.ComponentModel;
 
namespace System.Workflow.Activities.Rules
{
 	internal class Tracer
	{ 
		private string tracePrefix;
 
		// get the localized trace messages once 
 		private static string traceRuleIdentifier = Messages.TraceRuleIdentifier;
		private static string traceRuleHeader = Messages.TraceRuleHeader; 
 		private static string traceRuleSetEvaluate = Messages.TraceRuleSetEvaluate;
 		private static string traceRuleEvaluate = Messages.TraceRuleEvaluate;
		private static string traceRuleResult = Messages.TraceRuleResult;
 		private static string traceRuleActions = Messages.TraceRuleActions; 
		private static string traceCondition = Messages.Condition;
		private static string traceThen = Messages.Then; 
		private static string traceElse = Messages.Else; 
 		private static string traceUpdate = Messages.TraceUpdate;
		private static string traceRuleTriggers = Messages.TraceRuleTriggers; 
 		private static string traceRuleConditionDependency = Messages.TraceRuleConditionDependency;
 		private static string traceRuleActionSideEffect = Messages.TraceRuleActionSideEffect;

		internal Tracer(string name, ActivityExecutionContext activityExecutionContext) 
 		{
			if (activityExecutionContext != null) 
				tracePrefix = string.Format(CultureInfo.CurrentCulture, traceRuleIdentifier, name, activityExecutionContext.ContextGuid.ToString()); 
			else
 				tracePrefix = string.Format(CultureInfo.CurrentCulture, traceRuleHeader, name); 
		}

 		internal void StartRuleSet()
 		{ 
			WorkflowActivityTrace.Rules.TraceEvent(TraceEventType.Information, 0, traceRuleSetEvaluate, tracePrefix);
 		} 
 
		internal void StartRule(string ruleName)
		{ 
			WorkflowActivityTrace.Rules.TraceEvent(TraceEventType.Verbose, 0, traceRuleEvaluate, tracePrefix, ruleName);
 		}

		internal void RuleResult(string ruleName, bool result) 
 		{
 			WorkflowActivityTrace.Rules.TraceEvent(TraceEventType.Information, 0, traceRuleResult, tracePrefix, ruleName, result.ToString()); 
		} 

 		internal void StartActions(string ruleName, bool result) 
		{
			WorkflowActivityTrace.Rules.TraceEvent(TraceEventType.Verbose, 0, traceRuleActions, tracePrefix,
				(result ? traceThen : traceElse), ruleName);
 		} 

		internal void TraceUpdate(string ruleName, string otherName) 
 		{ 
 			WorkflowActivityTrace.Rules.TraceEvent(TraceEventType.Verbose, 0, traceUpdate, tracePrefix, ruleName, otherName);
		} 

 		internal void TraceConditionSymbols(string ruleName, ICollection symbols)
		{
			TraceRuleSymbols(traceRuleConditionDependency, traceCondition, ruleName, symbols); 
		}
 
 		internal void TraceThenSymbols(string ruleName, ICollection symbols) 
		{
 			TraceRuleSymbols(traceRuleActionSideEffect, traceThen, ruleName, symbols); 
 		}

		internal void TraceElseSymbols(string ruleName, ICollection symbols)
 		{ 
			TraceRuleSymbols(traceRuleActionSideEffect, traceElse, ruleName, symbols);
		} 
 
		private void TraceRuleSymbols(string message, string clause, string ruleName, ICollection symbols)
 		{ 
			foreach (string symbol in symbols)
 				WorkflowActivityTrace.Rules.TraceEvent(TraceEventType.Verbose, 0, message, tracePrefix, ruleName, clause, symbol);
 		}
 
		internal void TraceThenTriggers(string currentRuleName, ICollection triggeredRules, List ruleStates)
 		{ 
			TraceRuleTriggers(traceThen, currentRuleName, triggeredRules, ruleStates); 
		}
 
		internal void TraceElseTriggers(string currentRuleName, ICollection triggeredRules, List ruleStates)
 		{
			TraceRuleTriggers(traceElse, currentRuleName, triggeredRules, ruleStates);
 		} 

 		private void TraceRuleTriggers(string thenOrElse, string currentRuleName, ICollection triggeredRules, List ruleStates) 
		{ 
 			foreach (int r in triggeredRules)
				WorkflowActivityTrace.Rules.TraceEvent(TraceEventType.Verbose, 0, traceRuleTriggers, tracePrefix, currentRuleName, thenOrElse, ruleStates[r].Rule.Name); 
		}
	}
}

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.

                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK