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
- NativeCompoundFileAPIs.cs
- CheckPair.cs
- TreeNode.cs
- DataGridViewButtonColumn.cs
- AccessedThroughPropertyAttribute.cs
- unsafenativemethodsother.cs
- Cursors.cs
- LongValidatorAttribute.cs
- SoapServerProtocol.cs
- DataGridViewAdvancedBorderStyle.cs
- NumericUpDown.cs
- BooleanAnimationUsingKeyFrames.cs
- PerformanceCounterManager.cs
- HostedTransportConfigurationManager.cs
- TreeNode.cs
- Int32RectConverter.cs
- DbParameterHelper.cs
- CodeMemberEvent.cs
- MediaTimeline.cs
- InteropBitmapSource.cs
- IProducerConsumerCollection.cs
- HideDisabledControlAdapter.cs
- NavigateEvent.cs
- OLEDB_Util.cs
- PreviewKeyDownEventArgs.cs
- DesignerHelpers.cs
- ServiceDescriptionContext.cs
- ObjectSet.cs
- ParameterBuilder.cs
- EndpointIdentityExtension.cs
- TextDecorationCollectionConverter.cs
- ControlParser.cs
- DataGridViewTextBoxColumn.cs
- WebConfigurationHost.cs
- XmlSchemaComplexContentExtension.cs
- SafeLibraryHandle.cs
- UIElementCollection.cs
- PropertyCollection.cs
- NodeCounter.cs
- SolidBrush.cs
- InstanceDataCollectionCollection.cs
- DeploymentSection.cs
- JoinGraph.cs
- OpenFileDialog.cs
- HwndSubclass.cs
- SqlBulkCopyColumnMappingCollection.cs
- KeyedCollection.cs
- TemplateEditingVerb.cs
- SchemeSettingElementCollection.cs
- OdbcTransaction.cs
- SqlNotificationEventArgs.cs
- DoubleLinkList.cs
- DecimalAnimationBase.cs
- IdentityModelDictionary.cs
- DispatcherHookEventArgs.cs
- SafeFileMappingHandle.cs
- MyContact.cs
- DataGridViewButtonColumn.cs
- MethodBuilderInstantiation.cs
- ButtonFlatAdapter.cs
- _UriSyntax.cs
- Typeface.cs
- ComponentDispatcher.cs
- GeneralTransformCollection.cs
- ScriptMethodAttribute.cs
- SortDescriptionCollection.cs
- KeyboardEventArgs.cs
- BamlRecordWriter.cs
- ColorMatrix.cs
- AmbientValueAttribute.cs
- FunctionImportElement.cs
- HttpClientChannel.cs
- TabControlAutomationPeer.cs
- Int32EqualityComparer.cs
- GeneralTransform2DTo3D.cs
- MiniCustomAttributeInfo.cs
- BuildProvidersCompiler.cs
- ProfileSettings.cs
- StatusBarPanel.cs
- ByteAnimationBase.cs
- SystemUnicastIPAddressInformation.cs
- tabpagecollectioneditor.cs
- GeometryConverter.cs
- LayoutUtils.cs
- DataGridViewTextBoxEditingControl.cs
- MimeObjectFactory.cs
- DirectoryInfo.cs
- DataTablePropertyDescriptor.cs
- StringInfo.cs
- EngineSiteSapi.cs
- TextWriter.cs
- SafeHandle.cs
- DataContractSerializerMessageContractImporter.cs
- ClientSettingsStore.cs
- StringStorage.cs
- QueryOptionExpression.cs
- EntityCommand.cs
- ObjectDataProvider.cs
- SHA1Cng.cs
- formatstringdialog.cs