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
- FormViewActionList.cs
- QueryStringParameter.cs
- Type.cs
- RuleEngine.cs
- OleDbWrapper.cs
- ExecutionScope.cs
- ImageDesigner.cs
- TypedTableBaseExtensions.cs
- NullableBoolConverter.cs
- VScrollProperties.cs
- TextAnchor.cs
- TextElement.cs
- Page.cs
- ResXDataNode.cs
- CounterSetInstance.cs
- ToolStripControlHost.cs
- DataTableNewRowEvent.cs
- TemplateInstanceAttribute.cs
- WebSysDisplayNameAttribute.cs
- ConfigurationCollectionAttribute.cs
- RtfToken.cs
- TypeSemantics.cs
- VectorValueSerializer.cs
- Permission.cs
- UIPermission.cs
- AmbientValueAttribute.cs
- UnmanagedHandle.cs
- HttpBufferlessInputStream.cs
- IndexExpression.cs
- SchemaImporter.cs
- OuterGlowBitmapEffect.cs
- _BaseOverlappedAsyncResult.cs
- BuildProviderCollection.cs
- XmlBindingWorker.cs
- MessageFault.cs
- PropertyChangeTracker.cs
- ScriptBehaviorDescriptor.cs
- ExpressionBindings.cs
- DrawItemEvent.cs
- HttpProfileGroupBase.cs
- PlatformNotSupportedException.cs
- cache.cs
- FixedDocumentPaginator.cs
- InlinedAggregationOperatorEnumerator.cs
- SystemTcpConnection.cs
- BmpBitmapDecoder.cs
- MobileSysDescriptionAttribute.cs
- DispatcherObject.cs
- JoinSymbol.cs
- X509CertificateCollection.cs
- SpoolingTaskBase.cs
- Array.cs
- TypeToTreeConverter.cs
- Pkcs7Signer.cs
- _CommandStream.cs
- DesignTable.cs
- LookupNode.cs
- PropertyPathConverter.cs
- ResourceReferenceExpressionConverter.cs
- HtmlInputControl.cs
- ConfigXmlAttribute.cs
- SQLInt32.cs
- XmlChildNodes.cs
- CommentEmitter.cs
- StringFreezingAttribute.cs
- IsolatedStorageException.cs
- GridLengthConverter.cs
- QueryCursorEventArgs.cs
- BaseValidatorDesigner.cs
- GroupBox.cs
- TablePattern.cs
- SQLBoolean.cs
- WsdlExporter.cs
- PackagePartCollection.cs
- PresentationTraceSources.cs
- StrokeNodeData.cs
- SettingsPropertyValueCollection.cs
- TogglePattern.cs
- ZipIOLocalFileDataDescriptor.cs
- RtfFormatStack.cs
- DotAtomReader.cs
- DependencyObjectType.cs
- DataTableExtensions.cs
- DynamicDocumentPaginator.cs
- ConfigXmlElement.cs
- PropertyStore.cs
- LocalizableAttribute.cs
- DispatchChannelSink.cs
- WeakEventTable.cs
- ActivityCodeDomReferenceService.cs
- ArraySegment.cs
- PriorityQueue.cs
- DataGridViewTextBoxColumn.cs
- SqlResolver.cs
- UserControl.cs
- Predicate.cs
- LinqDataSource.cs
- WSSecureConversation.cs
- OutputScopeManager.cs
- StylusButtonEventArgs.cs