Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / XamlBuildTask / Microsoft / Build / Tasks / Xaml / NamespaceTable.cs / 1305376 / NamespaceTable.cs
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Xaml; namespace Microsoft.Build.Tasks.Xaml { internal class NamespaceTable : IXamlNamespaceResolver { DictionarytempNamespaceList = new Dictionary (); Stack > namespaceStack = new Stack >(); string localAssemblyName; public NamespaceTable(string localAssemblyName) { this.localAssemblyName = localAssemblyName; } public IEnumerable GetNamespacePrefixes() { List list = new List (); HashSet prefixSet = new HashSet (); if (tempNamespaceList != null && tempNamespaceList.Count > 0) { foreach (NamespaceDeclaration ns in tempNamespaceList.Values) { if (!prefixSet.Contains(ns.Prefix)) { prefixSet.Add(ns.Prefix); list.Add(ns); } } } foreach (Dictionary currentNamespaces in this.namespaceStack) { foreach (NamespaceDeclaration ns in currentNamespaces.Values) { if (!prefixSet.Contains(ns.Prefix)) { prefixSet.Add(ns.Prefix); list.Add(ns); } } } return list; } public string GetNamespace(string prefix) { NamespaceDeclaration @namespace = null; foreach (Dictionary currentNamespaces in this.namespaceStack) { if (null != currentNamespaces && currentNamespaces.TryGetValue(prefix, out @namespace)) { return @namespace.Namespace; } } if (tempNamespaceList != null && tempNamespaceList.TryGetValue(prefix, out @namespace)) { return @namespace.Namespace; } return @namespace.Namespace; } public void ManageNamespace(XamlReader reader) { switch (reader.NodeType) { case XamlNodeType.NamespaceDeclaration: tempNamespaceList.Add(reader.Namespace.Prefix, new NamespaceDeclaration( XamlBuildTaskServices.UpdateClrNamespaceUriWithLocalAssembly(reader.Namespace.Namespace, this.localAssemblyName), reader.Namespace.Prefix)); break; case XamlNodeType.StartObject: case XamlNodeType.StartMember: case XamlNodeType.GetObject: if (tempNamespaceList != null) { namespaceStack.Push(tempNamespaceList); tempNamespaceList = new Dictionary (); } break; case XamlNodeType.EndMember: case XamlNodeType.EndObject: namespaceStack.Pop(); break; default: break; } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Xaml; namespace Microsoft.Build.Tasks.Xaml { internal class NamespaceTable : IXamlNamespaceResolver { Dictionary tempNamespaceList = new Dictionary (); Stack > namespaceStack = new Stack >(); string localAssemblyName; public NamespaceTable(string localAssemblyName) { this.localAssemblyName = localAssemblyName; } public IEnumerable GetNamespacePrefixes() { List list = new List (); HashSet prefixSet = new HashSet (); if (tempNamespaceList != null && tempNamespaceList.Count > 0) { foreach (NamespaceDeclaration ns in tempNamespaceList.Values) { if (!prefixSet.Contains(ns.Prefix)) { prefixSet.Add(ns.Prefix); list.Add(ns); } } } foreach (Dictionary currentNamespaces in this.namespaceStack) { foreach (NamespaceDeclaration ns in currentNamespaces.Values) { if (!prefixSet.Contains(ns.Prefix)) { prefixSet.Add(ns.Prefix); list.Add(ns); } } } return list; } public string GetNamespace(string prefix) { NamespaceDeclaration @namespace = null; foreach (Dictionary currentNamespaces in this.namespaceStack) { if (null != currentNamespaces && currentNamespaces.TryGetValue(prefix, out @namespace)) { return @namespace.Namespace; } } if (tempNamespaceList != null && tempNamespaceList.TryGetValue(prefix, out @namespace)) { return @namespace.Namespace; } return @namespace.Namespace; } public void ManageNamespace(XamlReader reader) { switch (reader.NodeType) { case XamlNodeType.NamespaceDeclaration: tempNamespaceList.Add(reader.Namespace.Prefix, new NamespaceDeclaration( XamlBuildTaskServices.UpdateClrNamespaceUriWithLocalAssembly(reader.Namespace.Namespace, this.localAssemblyName), reader.Namespace.Prefix)); break; case XamlNodeType.StartObject: case XamlNodeType.StartMember: case XamlNodeType.GetObject: if (tempNamespaceList != null) { namespaceStack.Push(tempNamespaceList); tempNamespaceList = new Dictionary (); } break; case XamlNodeType.EndMember: case XamlNodeType.EndObject: namespaceStack.Pop(); break; default: break; } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- BooleanStorage.cs
- ExtendedPropertyCollection.cs
- TaskForm.cs
- CustomExpressionEventArgs.cs
- BuildProvider.cs
- PropertyEntry.cs
- StorageEntityTypeMapping.cs
- listitem.cs
- SynchronizationLockException.cs
- OutputCacheModule.cs
- XmlBinaryReader.cs
- SqlRowUpdatedEvent.cs
- FontFamily.cs
- CoreChannel.cs
- OleDbConnectionInternal.cs
- documentsequencetextview.cs
- EntityDescriptor.cs
- LabelExpression.cs
- ExportOptions.cs
- XmlTextReader.cs
- Evidence.cs
- DeleteHelper.cs
- DataMisalignedException.cs
- ComboBox.cs
- COM2EnumConverter.cs
- TextEditorLists.cs
- RewritingSimplifier.cs
- PromptBuilder.cs
- SelectionChangedEventArgs.cs
- AttachedAnnotationChangedEventArgs.cs
- ToolStripSeparatorRenderEventArgs.cs
- CompareValidator.cs
- ProxyHelper.cs
- PerspectiveCamera.cs
- DesignBindingValueUIHandler.cs
- MultiTrigger.cs
- TypeElementCollection.cs
- ModelItemKeyValuePair.cs
- EventDescriptor.cs
- shaper.cs
- DataGridViewCellStyle.cs
- MatcherBuilder.cs
- CustomTrackingRecord.cs
- Privilege.cs
- CompositeFontFamily.cs
- SetMemberBinder.cs
- ValueType.cs
- ReservationCollection.cs
- XmlEncoding.cs
- ValidatedControlConverter.cs
- SettingsSection.cs
- AdRotator.cs
- SHA256Managed.cs
- DoubleLinkListEnumerator.cs
- PrimitiveRenderer.cs
- Grid.cs
- MultilineStringEditor.cs
- EmptyStringExpandableObjectConverter.cs
- WebControl.cs
- DetailsViewPagerRow.cs
- OperationCanceledException.cs
- NegatedCellConstant.cs
- AnonymousIdentificationSection.cs
- ActivityXRefConverter.cs
- TextParaClient.cs
- CreateParams.cs
- UnescapedXmlDiagnosticData.cs
- EntitySqlQueryState.cs
- ConfigUtil.cs
- WebPartUserCapability.cs
- TreeNodeSelectionProcessor.cs
- _SslSessionsCache.cs
- CalloutQueueItem.cs
- DesignOnlyAttribute.cs
- UnsafeNativeMethodsCLR.cs
- DesignerActionGlyph.cs
- SelfIssuedAuthRSAPKCS1SignatureDeformatter.cs
- ContentType.cs
- CryptoProvider.cs
- PlainXmlWriter.cs
- VirtualizingPanel.cs
- ReachSerializationCacheItems.cs
- FontResourceCache.cs
- ActivityValidator.cs
- ShapeTypeface.cs
- MatrixAnimationUsingKeyFrames.cs
- BindingManagerDataErrorEventArgs.cs
- VisualBrush.cs
- MouseGestureConverter.cs
- XomlCompilerResults.cs
- TypeSystem.cs
- ClientRolePrincipal.cs
- PropertyPath.cs
- TypeLibConverter.cs
- TransactionManager.cs
- GenericPrincipal.cs
- TypeConvertions.cs
- ColumnCollection.cs
- EventHandlerList.cs
- ClientSettings.cs