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
- DataSourceControl.cs
- HitTestParameters.cs
- CodeNamespaceImport.cs
- XamlGridLengthSerializer.cs
- linebase.cs
- FastPropertyAccessor.cs
- LogExtentCollection.cs
- SQLUtility.cs
- EmissiveMaterial.cs
- GetLedgerEntryForRecipientRequest.cs
- CustomWebEventKey.cs
- FontUnitConverter.cs
- PropertyMetadata.cs
- KeyNameIdentifierClause.cs
- altserialization.cs
- RecommendedAsConfigurableAttribute.cs
- UdpDiscoveryEndpointElement.cs
- DbConnectionOptions.cs
- QilDataSource.cs
- NonSerializedAttribute.cs
- ResizingMessageFilter.cs
- TypeConverterHelper.cs
- ErrorProvider.cs
- CalendarDayButton.cs
- EventToken.cs
- UnsafeNativeMethods.cs
- XNodeNavigator.cs
- PerformanceCounterPermissionEntryCollection.cs
- TheQuery.cs
- FontStretches.cs
- SystemFonts.cs
- AppDomainAttributes.cs
- FunctionQuery.cs
- Transform.cs
- JsonSerializer.cs
- VisualStates.cs
- CaseInsensitiveComparer.cs
- SecurityTokenTypes.cs
- SerializationEventsCache.cs
- ObservableDictionary.cs
- PropertyTab.cs
- ToolStripPanel.cs
- TagPrefixAttribute.cs
- MessagePartDescriptionCollection.cs
- MutexSecurity.cs
- Content.cs
- DependencyPropertyDescriptor.cs
- LineProperties.cs
- XmlJsonWriter.cs
- EncryptedData.cs
- NamespaceDecl.cs
- SpellerStatusTable.cs
- webeventbuffer.cs
- EventPropertyMap.cs
- ToolStripItemRenderEventArgs.cs
- ToolStripControlHost.cs
- BrowserCapabilitiesCodeGenerator.cs
- TransactionCache.cs
- BmpBitmapDecoder.cs
- DateTimeFormatInfo.cs
- StylusPointCollection.cs
- ConfigurationSection.cs
- DisplayNameAttribute.cs
- MediaEntryAttribute.cs
- InvalidOleVariantTypeException.cs
- OpenFileDialog.cs
- Matrix.cs
- ExpressionPrinter.cs
- StateWorkerRequest.cs
- OleStrCAMarshaler.cs
- MobileControlDesigner.cs
- CssTextWriter.cs
- StorageBasedPackageProperties.cs
- AddInPipelineAttributes.cs
- MetaModel.cs
- HostExecutionContextManager.cs
- ByteKeyFrameCollection.cs
- DocumentEventArgs.cs
- DataGridViewRowDividerDoubleClickEventArgs.cs
- UnhandledExceptionEventArgs.cs
- FamilyTypeface.cs
- MarginsConverter.cs
- PageContentAsyncResult.cs
- EventSetterHandlerConverter.cs
- ParseChildrenAsPropertiesAttribute.cs
- unitconverter.cs
- TimeZone.cs
- Attributes.cs
- ValidationResult.cs
- ToolBarButtonClickEvent.cs
- List.cs
- HandlerFactoryCache.cs
- Queue.cs
- AttachedPropertiesService.cs
- QueryReaderSettings.cs
- PackageDigitalSignature.cs
- XmlChildNodes.cs
- XmlAttributeCache.cs
- cookiecollection.cs
- OutputCacheProfile.cs