Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / System.Activities / System / Activities / XamlIntegration / NamespaceTable.cs / 1305376 / NamespaceTable.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.Activities.XamlIntegration { using System.Collections.Generic; using System.Xaml; class NamespaceTable : IXamlNamespaceResolver { ListtempNamespaceList; Stack > namespaceStack; Dictionary
namespacesCache; public NamespaceTable() { this.tempNamespaceList = new List (); this.namespaceStack = new Stack >(); } public string GetNamespace(string prefix) { NamespaceDeclaration result; if (this.namespacesCache == null) { ConstructNamespaceCache(); } if (this.namespacesCache.TryGetValue(prefix, out result)) { return result.Namespace; } else { return null; } } public void ManageNamespace(XamlReader reader) { switch (reader.NodeType) { case XamlNodeType.NamespaceDeclaration: AddNamespace(reader.Namespace); break; case XamlNodeType.StartObject: case XamlNodeType.StartMember: case XamlNodeType.GetObject: EnterScope(); break; case XamlNodeType.EndMember: case XamlNodeType.EndObject: ExitScope(); break; } } public void AddNamespace(NamespaceDeclaration xamlNamespace) { this.tempNamespaceList.Add(xamlNamespace); this.namespacesCache = null; } public void EnterScope() { if (this.tempNamespaceList != null) { this.namespaceStack.Push(this.tempNamespaceList); this.tempNamespaceList = new List
(); } } public void ExitScope() { List namespaceList = this.namespaceStack.Pop(); if (namespaceList.Count != 0) { this.namespacesCache = null; } } public IEnumerable GetNamespacePrefixes() { if (this.namespacesCache == null) { ConstructNamespaceCache(); } return this.namespacesCache.Values; } void ConstructNamespaceCache() { Dictionary localNamespaces = new Dictionary (); if (this.tempNamespaceList != null && this.tempNamespaceList.Count > 0) { foreach (NamespaceDeclaration tempNamespace in tempNamespaceList) { if (!localNamespaces.ContainsKey(tempNamespace.Prefix)) { localNamespaces.Add(tempNamespace.Prefix, tempNamespace); } } } foreach (List currentNamespaces in this.namespaceStack) { foreach (NamespaceDeclaration currentNamespace in currentNamespaces) { if (!localNamespaces.ContainsKey(currentNamespace.Prefix)) { localNamespaces.Add(currentNamespace.Prefix, currentNamespace); } } } this.namespacesCache = localNamespaces; } } } // 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
- TextServicesPropertyRanges.cs
- ParsedAttributeCollection.cs
- GestureRecognizer.cs
- DefaultWorkflowLoaderService.cs
- FlowDocumentScrollViewerAutomationPeer.cs
- DecoderFallbackWithFailureFlag.cs
- ChtmlCommandAdapter.cs
- RuntimeWrappedException.cs
- _SSPIWrapper.cs
- WindowsEditBoxRange.cs
- BehaviorEditorPart.cs
- EndpointAddressAugust2004.cs
- QilTernary.cs
- SqlTriggerContext.cs
- assertwrapper.cs
- Light.cs
- UInt16Storage.cs
- RSAPKCS1SignatureDeformatter.cs
- IndependentAnimationStorage.cs
- TextPointer.cs
- DoubleCollectionValueSerializer.cs
- SiteOfOriginContainer.cs
- WebRequestModuleElement.cs
- XmlSchemaSubstitutionGroup.cs
- TemplateColumn.cs
- ListViewItem.cs
- SortedSetDebugView.cs
- EmptyReadOnlyDictionaryInternal.cs
- DateTimeFormat.cs
- SqlNotificationEventArgs.cs
- DrawingCollection.cs
- EntityDataSourceEntityTypeFilterConverter.cs
- DataGridCellEditEndingEventArgs.cs
- validation.cs
- EventEntry.cs
- QilInvoke.cs
- ColorDialog.cs
- TokenFactoryCredential.cs
- JsonWriterDelegator.cs
- CompilerGlobalScopeAttribute.cs
- DictionaryChange.cs
- ScriptManagerProxy.cs
- GetReadStreamResult.cs
- QueryGeneratorBase.cs
- GridErrorDlg.cs
- Sentence.cs
- DataSourceHelper.cs
- OneOf.cs
- ExternalCalls.cs
- MeasurementDCInfo.cs
- WsdlInspector.cs
- SecurityKeyUsage.cs
- PageContentCollection.cs
- AmbiguousMatchException.cs
- ClientBuildManagerCallback.cs
- SourceSwitch.cs
- GlobalizationSection.cs
- SoundPlayer.cs
- BaseUriHelper.cs
- RemotingConfigParser.cs
- InkCanvasSelection.cs
- PaginationProgressEventArgs.cs
- RoutedEventConverter.cs
- InfocardClientCredentials.cs
- TypeValidationEventArgs.cs
- StylusTouchDevice.cs
- StylusDownEventArgs.cs
- StringExpressionSet.cs
- DataSourceDesigner.cs
- IndicShape.cs
- LoginDesigner.cs
- CodeVariableReferenceExpression.cs
- ObjectDataSourceDisposingEventArgs.cs
- WebPartCatalogCloseVerb.cs
- WindowsListViewItem.cs
- TdsParserHelperClasses.cs
- DecoderBestFitFallback.cs
- PhysicalOps.cs
- FixedTextView.cs
- TraceShell.cs
- WindowsEditBox.cs
- AdjustableArrowCap.cs
- UnsafeNetInfoNativeMethods.cs
- Splitter.cs
- ObjectStateFormatter.cs
- CodeCatchClause.cs
- TypeElement.cs
- WeakEventManager.cs
- ClassicBorderDecorator.cs
- MemberNameValidator.cs
- FontNamesConverter.cs
- StringDictionary.cs
- AttachInfo.cs
- Scripts.cs
- NullableFloatMinMaxAggregationOperator.cs
- OptimizerPatterns.cs
- ControlBuilder.cs
- EdmMember.cs
- BCLDebug.cs
- CngProperty.cs