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
- DateTimeStorage.cs
- XmlDataProvider.cs
- ContextMenuService.cs
- EntityKeyElement.cs
- ToolStripItemCollection.cs
- IndexExpression.cs
- QueryAccessibilityHelpEvent.cs
- TouchesCapturedWithinProperty.cs
- SoapSchemaExporter.cs
- DataBinder.cs
- SamlSubject.cs
- SpAudioStreamWrapper.cs
- InterleavedZipPartStream.cs
- BitmapEffectGroup.cs
- EntityDataSourceValidationException.cs
- BaseValidator.cs
- Pointer.cs
- InvalidCommandTreeException.cs
- ConnectionInterfaceCollection.cs
- TreeWalkHelper.cs
- TraceRecord.cs
- FormParameter.cs
- CapabilitiesUse.cs
- assemblycache.cs
- ToolStripItemBehavior.cs
- TraceLog.cs
- DataSet.cs
- MULTI_QI.cs
- Camera.cs
- TypedTableHandler.cs
- FlowDocumentPage.cs
- Utils.cs
- OneOf.cs
- CharStorage.cs
- Models.cs
- RootProfilePropertySettingsCollection.cs
- ConstraintStruct.cs
- TextRunTypographyProperties.cs
- SimpleColumnProvider.cs
- UnaryNode.cs
- TypeDescriptor.cs
- TreeNodeMouseHoverEvent.cs
- ValidatorCollection.cs
- ToolStripEditorManager.cs
- XmlSchemaGroupRef.cs
- XmlReader.cs
- X509ChainPolicy.cs
- ArraySubsetEnumerator.cs
- ResourceContainerWrapper.cs
- BridgeDataReader.cs
- WsdlExporter.cs
- SiteMembershipCondition.cs
- CommandEventArgs.cs
- TagPrefixCollection.cs
- XamlBrushSerializer.cs
- NameValueConfigurationCollection.cs
- ZoneButton.cs
- GroupStyle.cs
- SecurityContext.cs
- PriorityBindingExpression.cs
- StartUpEventArgs.cs
- PingOptions.cs
- UnionExpr.cs
- SoundPlayer.cs
- GlyphInfoList.cs
- FreezableOperations.cs
- UrlPath.cs
- ProtocolsSection.cs
- WebPartZoneBase.cs
- InstanceContextMode.cs
- ServiceReference.cs
- TextEncodedRawTextWriter.cs
- ToolTip.cs
- Image.cs
- HiddenField.cs
- COSERVERINFO.cs
- OutgoingWebRequestContext.cs
- CategoryAttribute.cs
- Point3D.cs
- LiteralText.cs
- SizeFConverter.cs
- CTreeGenerator.cs
- LocalBuilder.cs
- SafeMILHandle.cs
- MethodImplAttribute.cs
- SeparatorAutomationPeer.cs
- ArithmeticException.cs
- EntityDataSourceConfigureObjectContext.cs
- DesignConnectionCollection.cs
- Rect3D.cs
- RequestCachingSection.cs
- Misc.cs
- CfgParser.cs
- PerfCounters.cs
- StandardToolWindows.cs
- PathSegmentCollection.cs
- BufferCache.cs
- XmlSchemaComplexContentRestriction.cs
- WebServiceTypeData.cs
- HtmlListAdapter.cs