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
- _AutoWebProxyScriptEngine.cs
- GridViewRow.cs
- HtmlInputFile.cs
- CodeCommentStatement.cs
- WebFaultException.cs
- ProjectionRewriter.cs
- XmlILOptimizerVisitor.cs
- DeviceContexts.cs
- ImportContext.cs
- ObjectDisposedException.cs
- RelationshipSet.cs
- WebPartDisplayModeCancelEventArgs.cs
- SerialErrors.cs
- _HelperAsyncResults.cs
- SchemaComplexType.cs
- SqlServer2KCompatibilityCheck.cs
- FocusChangedEventArgs.cs
- Constants.cs
- ObjectSecurityT.cs
- ClientScriptManagerWrapper.cs
- GridViewRowCollection.cs
- UIntPtr.cs
- DataTableReader.cs
- Atom10FormatterFactory.cs
- StorageConditionPropertyMapping.cs
- JsonDeserializer.cs
- PaginationProgressEventArgs.cs
- InstancePersistenceContext.cs
- WorkflowTransactionOptions.cs
- TextEmbeddedObject.cs
- DefaultAutoFieldGenerator.cs
- SqlTypesSchemaImporter.cs
- EnumConverter.cs
- ObjectStateEntryBaseUpdatableDataRecord.cs
- HtmlTable.cs
- Separator.cs
- ProfileSettingsCollection.cs
- WindowsTooltip.cs
- DeobfuscatingStream.cs
- RegistryPermission.cs
- TypeConverterAttribute.cs
- TreeNodeCollection.cs
- DeobfuscatingStream.cs
- OleServicesContext.cs
- GlyphsSerializer.cs
- ClientBuildManager.cs
- GeneratedCodeAttribute.cs
- GradientBrush.cs
- SiteMapNode.cs
- CompilerScopeManager.cs
- AggregateNode.cs
- ColorMatrix.cs
- PackageRelationshipCollection.cs
- BamlRecords.cs
- FormViewInsertEventArgs.cs
- AppSecurityManager.cs
- TextUtf8RawTextWriter.cs
- Compensation.cs
- Variable.cs
- AssemblyBuilderData.cs
- WindowsToolbarItemAsMenuItem.cs
- WindowsPrincipal.cs
- BlockUIContainer.cs
- Clause.cs
- SystemFonts.cs
- MetadataCache.cs
- OdbcConnectionHandle.cs
- XmlSerializerFactory.cs
- EntityContainerAssociationSetEnd.cs
- ColumnTypeConverter.cs
- RunWorkerCompletedEventArgs.cs
- DetailsViewPageEventArgs.cs
- DmlSqlGenerator.cs
- ExtensibleClassFactory.cs
- HttpMethodAttribute.cs
- SessionIDManager.cs
- SafeCertificateStore.cs
- Timeline.cs
- DocumentOrderQuery.cs
- DispatcherObject.cs
- BuildProvider.cs
- NonBatchDirectoryCompiler.cs
- _SslStream.cs
- QuaternionConverter.cs
- MemberMaps.cs
- codemethodreferenceexpression.cs
- SerializationInfo.cs
- ComEventsSink.cs
- SecUtil.cs
- StringComparer.cs
- UrlPropertyAttribute.cs
- OdbcException.cs
- BigInt.cs
- HttpWebResponse.cs
- DependencyObjectType.cs
- WebChannelFactory.cs
- ComponentEditorPage.cs
- invalidudtexception.cs
- HttpWebResponse.cs
- PropertyValueUIItem.cs