Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / XamlBuildTask / Microsoft / Build / Tasks / Xaml / WrappingXamlSchemaContext.cs / 1305376 / WrappingXamlSchemaContext.cs
using System;
using System.Collections.Generic;
using System.Text;
using System.Xaml;
using System.Reflection;
namespace Microsoft.Build.Tasks.Xaml
{
class XamlNsReplacingContext : XamlSchemaContext
{
string localAssemblyName;
string realAssemblyName;
IDictionary MasterTypeList;
public XamlNsReplacingContext(IEnumerable referenceAssemblies, string localAssemblyName, string realAssemblyName)
: base(referenceAssemblies)
{
this.localAssemblyName = localAssemblyName;
this.realAssemblyName = realAssemblyName;
MasterTypeList = new Dictionary();
}
public override XamlType GetXamlType(Type type)
{
if (type == null)
{
throw FxTrace.Exception.AsError(new ArgumentNullException("type"));
}
XamlNsReplacingType xamlType = null;
if (!MasterTypeList.TryGetValue(type, out xamlType))
{
xamlType = new XamlNsReplacingType(type, this, localAssemblyName, realAssemblyName);
MasterTypeList.Add(type, xamlType);
}
return xamlType;
}
protected override XamlType GetXamlType(string xamlNamespace, string name, params XamlType[] typeArguments)
{
XamlType xamlType = base.GetXamlType(xamlNamespace, name, typeArguments);
if (xamlType == null || xamlType.IsUnknown)
{
xamlNamespace = XamlBuildTaskServices.UpdateClrNamespaceUriWithLocalAssembly(xamlNamespace, this.localAssemblyName, this.realAssemblyName);
xamlType = base.GetXamlType(xamlNamespace, name, typeArguments);
}
return xamlType;
}
}
class XamlNsReplacingType : XamlType
{
string localAssemblyName;
string realAssemblyName;
List namespaces;
public XamlNsReplacingType(Type underlyingType, XamlSchemaContext context, string localAssemblyName, string realAssemblyName)
: base(underlyingType, context)
{
this.localAssemblyName = localAssemblyName;
this.realAssemblyName = realAssemblyName;
namespaces = null;
}
public override IList GetXamlNamespaces()
{
if (namespaces == null)
{
namespaces = new List();
IList originalNamespaces = base.GetXamlNamespaces();
foreach (var ns in originalNamespaces)
{
namespaces.Add(XamlBuildTaskServices.UpdateClrNamespaceUriWithLocalAssembly(ns, this.localAssemblyName, this.realAssemblyName));
}
}
return namespaces;
}
}
}
// 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
- WinFormsSpinner.cs
- AuthenticationModuleElement.cs
- TimelineGroup.cs
- LightweightCodeGenerator.cs
- WeakRefEnumerator.cs
- ListBoxItemAutomationPeer.cs
- SystemKeyConverter.cs
- BitmapData.cs
- ToolStripOverflow.cs
- ZipIOBlockManager.cs
- UserPreferenceChangedEventArgs.cs
- MasterPageBuildProvider.cs
- TreeBuilder.cs
- ExternalFile.cs
- XmlPropertyBag.cs
- COAUTHIDENTITY.cs
- ActivityLocationReferenceEnvironment.cs
- HandlerMappingMemo.cs
- WaitingCursor.cs
- ColumnPropertiesGroup.cs
- Quack.cs
- TextTreeNode.cs
- XsltOutput.cs
- Exception.cs
- ReadOnlyHierarchicalDataSourceView.cs
- VarRemapper.cs
- AppSettingsExpressionBuilder.cs
- ICspAsymmetricAlgorithm.cs
- WebHttpSecurityModeHelper.cs
- WebServicesDescriptionAttribute.cs
- DataServiceRequestOfT.cs
- Animatable.cs
- TableDetailsCollection.cs
- QueryFunctions.cs
- XmlDocumentType.cs
- ExpressionPrefixAttribute.cs
- ResourceAssociationType.cs
- ICollection.cs
- Blend.cs
- AutomationElementCollection.cs
- AutomationIdentifier.cs
- PropertyRecord.cs
- QuaternionAnimation.cs
- UIElementIsland.cs
- HostingMessageProperty.cs
- DescendantQuery.cs
- UntypedNullExpression.cs
- QilInvoke.cs
- Certificate.cs
- SearchExpression.cs
- printdlgexmarshaler.cs
- LoopExpression.cs
- ControlSerializer.cs
- PipelineModuleStepContainer.cs
- SizeF.cs
- UIAgentInitializationException.cs
- StylusPointProperties.cs
- GenericArgumentsUpdater.cs
- AsyncResult.cs
- ResourcePermissionBase.cs
- TreeNodeStyle.cs
- WebExceptionStatus.cs
- TreeBuilderXamlTranslator.cs
- VariableQuery.cs
- WindowShowOrOpenTracker.cs
- RequestUriProcessor.cs
- VectorCollectionValueSerializer.cs
- SingleAnimationUsingKeyFrames.cs
- SqlClientPermission.cs
- SystemFonts.cs
- DesignerAttribute.cs
- DesignTimeTemplateParser.cs
- ValidatingReaderNodeData.cs
- BitmapCodecInfoInternal.cs
- IISMapPath.cs
- WebControlParameterProxy.cs
- ZipPackage.cs
- Substitution.cs
- AuthenticatingEventArgs.cs
- ServiceContractGenerator.cs
- CommandBindingCollection.cs
- DesignBindingEditor.cs
- XmlNamespaceMapping.cs
- AspProxy.cs
- StringInfo.cs
- IxmlLineInfo.cs
- PlatformNotSupportedException.cs
- SurrogateEncoder.cs
- ArglessEventHandlerProxy.cs
- DataGridTablesFactory.cs
- XhtmlTextWriter.cs
- BigInt.cs
- QueueAccessMode.cs
- BooleanExpr.cs
- Decimal.cs
- HiddenFieldPageStatePersister.cs
- RadioButtonPopupAdapter.cs
- UserPreferenceChangedEventArgs.cs
- ValidationError.cs
- SecurityState.cs