Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / ndp / fx / src / DataEntity / System / Data / Map / ViewGeneration / ConfigViewGenerator.cs / 1 / ConfigViewGenerator.cs
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....]
// @backupOwner [....]
//---------------------------------------------------------------------
using System.Data.Common.Utils;
using System.Text;
using System.Diagnostics;
namespace System.Data.Mapping.ViewGeneration {
internal enum ViewGenerationMode
{
GenerateAllViews = 0,
OfTypeViews,
OfTypeOnlyViews
}
internal enum ViewGenTraceLevel {
None = 0,
ViewsOnly,
Normal,
Verbose
}
internal enum PerfType {
InitialSetup = 0,
CellCreation,
KeyConstraint,
CellNormalizer,
UpdateViews,
DisjointConstraint,
PartitionConstraint,
DomainConstraint,
ForeignConstraint,
QueryViews,
BoolResolution,
Unsatisfiability,
ViewParsing,
}
// This class holds some configuration information for the view
// generation code
internal class ConfigViewGenerator : InternalBase {
#region Constructors
internal ConfigViewGenerator() {
m_watch = new Stopwatch();
m_singleWatch = new Stopwatch();
int numEnums = Enum.GetNames(typeof(PerfType)).Length;
m_breakdownTimes = new TimeSpan[numEnums];
TraceLevel = ViewGenTraceLevel.None;
GenerateViewsForEachType = false;
StartWatch();
}
#endregion
#region Fields
private bool m_generateViewsForEachType;
private ViewGenTraceLevel m_traceLevel;
private TimeSpan[] m_breakdownTimes;
private Stopwatch m_watch;
private Stopwatch m_singleWatch; // To measure a single thing at a time
private PerfType m_singlePerfOp; // Perf op being measured
private bool m_enableValidation = true;
#endregion
#region Properties
// Callers can set elements in this list
internal TimeSpan[] BreakdownTimes {
get { return m_breakdownTimes;}
}
internal ViewGenTraceLevel TraceLevel {
get { return m_traceLevel;}
set {m_traceLevel = value;}
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal bool IsValidationEnabled
{
get { return m_enableValidation; }
set { m_enableValidation = value; }
}
internal bool GenerateViewsForEachType {
get { return m_generateViewsForEachType; }
set { m_generateViewsForEachType = value; }
}
internal bool IsViewTracing {
get { return IsTraceAllowed(ViewGenTraceLevel.ViewsOnly);}
}
internal bool IsNormalTracing {
get { return IsTraceAllowed(ViewGenTraceLevel.Normal);}
}
internal bool IsVerboseTracing {
get { return IsTraceAllowed(ViewGenTraceLevel.Verbose);}
}
#endregion
#region Methods
private void StartWatch() {
m_watch.Start();
}
internal void StartSingleWatch(PerfType perfType) {
m_singleWatch.Start();
m_singlePerfOp = perfType;
}
// effects: Sets time for perfType for the individual timer
internal void StopSingleWatch(PerfType perfType) {
Debug.Assert(m_singlePerfOp == perfType, "Started op for different activity " + m_singlePerfOp + " -- not " + perfType);
TimeSpan timeElapsed = m_singleWatch.Elapsed;
int index = (int)perfType;
m_singleWatch.Stop();
m_singleWatch.Reset();
BreakdownTimes[index] = BreakdownTimes[index].Add(timeElapsed);
}
// effects: Sets time for perfType since the last call to SetTimeForActivity
internal void SetTimeForFinishedActivity(PerfType perfType) {
TimeSpan timeElapsed = m_watch.Elapsed;
int index = (int)perfType;
BreakdownTimes[index] = BreakdownTimes[index].Add(timeElapsed);
// Trace.WriteLine(perfType + " " + timeElapsed.TotalSeconds);
m_watch.Reset();
m_watch.Start();
}
// effects: Returns true if this's traceLevel is at least traceLevel
internal bool IsTraceAllowed(ViewGenTraceLevel traceLevel) {
return TraceLevel >= traceLevel;
}
internal override void ToCompactString(StringBuilder builder) {
StringUtil.FormatStringBuilder(builder, "Trace Switch: {0}", m_traceLevel);
}
#endregion
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....]
// @backupOwner [....]
//---------------------------------------------------------------------
using System.Data.Common.Utils;
using System.Text;
using System.Diagnostics;
namespace System.Data.Mapping.ViewGeneration {
internal enum ViewGenerationMode
{
GenerateAllViews = 0,
OfTypeViews,
OfTypeOnlyViews
}
internal enum ViewGenTraceLevel {
None = 0,
ViewsOnly,
Normal,
Verbose
}
internal enum PerfType {
InitialSetup = 0,
CellCreation,
KeyConstraint,
CellNormalizer,
UpdateViews,
DisjointConstraint,
PartitionConstraint,
DomainConstraint,
ForeignConstraint,
QueryViews,
BoolResolution,
Unsatisfiability,
ViewParsing,
}
// This class holds some configuration information for the view
// generation code
internal class ConfigViewGenerator : InternalBase {
#region Constructors
internal ConfigViewGenerator() {
m_watch = new Stopwatch();
m_singleWatch = new Stopwatch();
int numEnums = Enum.GetNames(typeof(PerfType)).Length;
m_breakdownTimes = new TimeSpan[numEnums];
TraceLevel = ViewGenTraceLevel.None;
GenerateViewsForEachType = false;
StartWatch();
}
#endregion
#region Fields
private bool m_generateViewsForEachType;
private ViewGenTraceLevel m_traceLevel;
private TimeSpan[] m_breakdownTimes;
private Stopwatch m_watch;
private Stopwatch m_singleWatch; // To measure a single thing at a time
private PerfType m_singlePerfOp; // Perf op being measured
private bool m_enableValidation = true;
#endregion
#region Properties
// Callers can set elements in this list
internal TimeSpan[] BreakdownTimes {
get { return m_breakdownTimes;}
}
internal ViewGenTraceLevel TraceLevel {
get { return m_traceLevel;}
set {m_traceLevel = value;}
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal bool IsValidationEnabled
{
get { return m_enableValidation; }
set { m_enableValidation = value; }
}
internal bool GenerateViewsForEachType {
get { return m_generateViewsForEachType; }
set { m_generateViewsForEachType = value; }
}
internal bool IsViewTracing {
get { return IsTraceAllowed(ViewGenTraceLevel.ViewsOnly);}
}
internal bool IsNormalTracing {
get { return IsTraceAllowed(ViewGenTraceLevel.Normal);}
}
internal bool IsVerboseTracing {
get { return IsTraceAllowed(ViewGenTraceLevel.Verbose);}
}
#endregion
#region Methods
private void StartWatch() {
m_watch.Start();
}
internal void StartSingleWatch(PerfType perfType) {
m_singleWatch.Start();
m_singlePerfOp = perfType;
}
// effects: Sets time for perfType for the individual timer
internal void StopSingleWatch(PerfType perfType) {
Debug.Assert(m_singlePerfOp == perfType, "Started op for different activity " + m_singlePerfOp + " -- not " + perfType);
TimeSpan timeElapsed = m_singleWatch.Elapsed;
int index = (int)perfType;
m_singleWatch.Stop();
m_singleWatch.Reset();
BreakdownTimes[index] = BreakdownTimes[index].Add(timeElapsed);
}
// effects: Sets time for perfType since the last call to SetTimeForActivity
internal void SetTimeForFinishedActivity(PerfType perfType) {
TimeSpan timeElapsed = m_watch.Elapsed;
int index = (int)perfType;
BreakdownTimes[index] = BreakdownTimes[index].Add(timeElapsed);
// Trace.WriteLine(perfType + " " + timeElapsed.TotalSeconds);
m_watch.Reset();
m_watch.Start();
}
// effects: Returns true if this's traceLevel is at least traceLevel
internal bool IsTraceAllowed(ViewGenTraceLevel traceLevel) {
return TraceLevel >= traceLevel;
}
internal override void ToCompactString(StringBuilder builder) {
StringUtil.FormatStringBuilder(builder, "Trace Switch: {0}", m_traceLevel);
}
#endregion
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- PassportAuthenticationEventArgs.cs
- CombinedGeometry.cs
- Query.cs
- MetaChildrenColumn.cs
- ScrollableControl.cs
- SizeKeyFrameCollection.cs
- JournalEntryStack.cs
- StringUtil.cs
- Latin1Encoding.cs
- Control.cs
- CqlErrorHelper.cs
- MimeWriter.cs
- TextSelectionHelper.cs
- JsonQNameDataContract.cs
- AttributeEmitter.cs
- ListViewTableCell.cs
- WinCategoryAttribute.cs
- ActiveDesignSurfaceEvent.cs
- PseudoWebRequest.cs
- FormatterConverter.cs
- NominalTypeEliminator.cs
- DispatchWrapper.cs
- PropertyReferenceSerializer.cs
- DrawingVisual.cs
- ProxyElement.cs
- DispatcherExceptionEventArgs.cs
- WebServiceTypeData.cs
- ContainerControl.cs
- PersonalizationProviderCollection.cs
- Header.cs
- XmlParserContext.cs
- assemblycache.cs
- ExpressionEditorAttribute.cs
- WebBrowsableAttribute.cs
- XmlAttributeProperties.cs
- ButtonPopupAdapter.cs
- SecurityKeyType.cs
- SubstitutionList.cs
- DrawingContextWalker.cs
- TextProviderWrapper.cs
- SymbolEqualComparer.cs
- XmlSchemaSimpleTypeRestriction.cs
- ObservableCollection.cs
- SqlConnection.cs
- LogicalExpr.cs
- TableCell.cs
- FormsIdentity.cs
- TrackingMemoryStream.cs
- BinaryCommonClasses.cs
- SolidColorBrush.cs
- FlowchartDesignerCommands.cs
- XmlSchemaRedefine.cs
- HttpRequest.cs
- RegexNode.cs
- SplineQuaternionKeyFrame.cs
- ExtendedPropertyInfo.cs
- FunctionCommandText.cs
- CharacterMetrics.cs
- TrustDriver.cs
- WebHttpBindingCollectionElement.cs
- RouteValueDictionary.cs
- ISO2022Encoding.cs
- MemoryMappedView.cs
- InfoCardRSACryptoProvider.cs
- EpmTargetPathSegment.cs
- ContentHostHelper.cs
- BaseHashHelper.cs
- FixedDocumentPaginator.cs
- LabelAutomationPeer.cs
- OleStrCAMarshaler.cs
- EventManager.cs
- SQLMoney.cs
- StringReader.cs
- PromptEventArgs.cs
- PathTooLongException.cs
- ForeignKeyFactory.cs
- localization.cs
- XamlDesignerSerializationManager.cs
- Certificate.cs
- SelectedPathEditor.cs
- FixedSOMContainer.cs
- XmlTypeMapping.cs
- CachedBitmap.cs
- IntegrationExceptionEventArgs.cs
- ToolbarAUtomationPeer.cs
- WebPartConnectVerb.cs
- TypeElementCollection.cs
- ListControlConvertEventArgs.cs
- WebPartTracker.cs
- RightsManagementResourceHelper.cs
- SelectionChangedEventArgs.cs
- MarkupCompilePass2.cs
- FormConverter.cs
- HScrollProperties.cs
- FormViewCommandEventArgs.cs
- RadioButtonBaseAdapter.cs
- Errors.cs
- RemotingHelper.cs
- OletxTransactionManager.cs
- SQLGuidStorage.cs