Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataEntity / System / Data / SqlClient / SqlGen / SymbolUsageManager.cs / 1305376 / SymbolUsageManager.cs
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....]
//---------------------------------------------------------------------
using System;
using System.Collections.Generic;
namespace System.Data.SqlClient.SqlGen
{
///
/// Used for wrapping a boolean value as an object.
///
internal class BoolWrapper
{
internal bool Value {get; set;}
internal BoolWrapper()
{
this.Value = false;
}
}
///
/// Tracks the usage of symbols.
/// When registering a symbol with the usage manager if an input symbol is specified,
/// than the usage of the two is 'connected' - if one ever gets marked as used,
/// the other one becomes 'used' too.
///
internal class SymbolUsageManager
{
private readonly Dictionary optionalColumnUsage = new Dictionary();
internal bool ContainsKey(Symbol key)
{
return optionalColumnUsage.ContainsKey(key);
}
internal bool TryGetValue(Symbol key, out bool value)
{
BoolWrapper wrapper;
if (optionalColumnUsage.TryGetValue(key, out wrapper))
{
value = wrapper.Value;
return true;
}
value = false;
return false;
}
internal void Add(Symbol sourceSymbol, Symbol symbolToAdd)
{
BoolWrapper wrapper;
if (sourceSymbol == null || !this.optionalColumnUsage.TryGetValue(sourceSymbol, out wrapper))
{
wrapper = new BoolWrapper();
}
this.optionalColumnUsage.Add(symbolToAdd, wrapper);
}
internal void MarkAsUsed(Symbol key)
{
if (optionalColumnUsage.ContainsKey(key))
{
optionalColumnUsage[key].Value = true;
}
}
internal bool IsUsed(Symbol key)
{
return optionalColumnUsage[key].Value;
}
}
}
// 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
- PersistenceProvider.cs
- ExitEventArgs.cs
- Focus.cs
- Ports.cs
- UnsafeNativeMethodsTablet.cs
- ScriptServiceAttribute.cs
- ChannelServices.cs
- XmlReaderSettings.cs
- FixedSOMTableCell.cs
- StrongNameMembershipCondition.cs
- CrossAppDomainChannel.cs
- HashMembershipCondition.cs
- BaseComponentEditor.cs
- EventTrigger.cs
- TextTreeTextBlock.cs
- MultiView.cs
- ToolboxItemFilterAttribute.cs
- RSAPKCS1KeyExchangeFormatter.cs
- Int32AnimationUsingKeyFrames.cs
- InkCanvasSelectionAdorner.cs
- MsmqInputChannelBase.cs
- GridItemProviderWrapper.cs
- FormViewPageEventArgs.cs
- XmlSerializationReader.cs
- EditingScopeUndoUnit.cs
- PartitionedStreamMerger.cs
- ConnectionsZone.cs
- DesignBindingPropertyDescriptor.cs
- ControlBuilderAttribute.cs
- _HeaderInfo.cs
- Frame.cs
- WebAdminConfigurationHelper.cs
- VariableExpressionConverter.cs
- StrokeCollection2.cs
- BasicAsyncResult.cs
- HttpResponseBase.cs
- Int32CollectionConverter.cs
- Expression.cs
- RectKeyFrameCollection.cs
- FixedDocument.cs
- LogicalTreeHelper.cs
- SimpleWebHandlerParser.cs
- EntityProxyTypeInfo.cs
- SetMemberBinder.cs
- BindUriHelper.cs
- TTSEngineTypes.cs
- VarRemapper.cs
- IdentitySection.cs
- PublisherMembershipCondition.cs
- DataGridItemAutomationPeer.cs
- CellTreeNodeVisitors.cs
- OptimalTextSource.cs
- _ListenerRequestStream.cs
- EmptyElement.cs
- PixelFormatConverter.cs
- MaskInputRejectedEventArgs.cs
- parserscommon.cs
- Vector3DAnimation.cs
- PersonalizationProviderCollection.cs
- TimeManager.cs
- DataGridViewCellCancelEventArgs.cs
- PointAnimationClockResource.cs
- _Events.cs
- Thread.cs
- Rfc2898DeriveBytes.cs
- x509store.cs
- RuntimeDelegateArgument.cs
- Parameter.cs
- ToolStripLabel.cs
- ConnectionString.cs
- BasicExpressionVisitor.cs
- ContextActivityUtils.cs
- ChtmlCommandAdapter.cs
- UserUseLicenseDictionaryLoader.cs
- OutputCacheModule.cs
- IsolatedStoragePermission.cs
- ValidationPropertyAttribute.cs
- DragStartedEventArgs.cs
- EventBuilder.cs
- DataViewManager.cs
- AlignmentXValidation.cs
- StatusStrip.cs
- MethodToken.cs
- HandlerBase.cs
- CodeBlockBuilder.cs
- HttpContextServiceHost.cs
- KnownTypesHelper.cs
- TextEndOfSegment.cs
- ImageMetadata.cs
- RankException.cs
- InstanceDataCollection.cs
- TextRangeEdit.cs
- IListConverters.cs
- AudioFormatConverter.cs
- SqlFactory.cs
- OperationGenerator.cs
- WebUtil.cs
- AsyncOperationLifetimeManager.cs
- MessageSmuggler.cs
- METAHEADER.cs