Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / wpf / src / Base / System / Windows / Markup / XmlnsDefinitionAttribute.cs / 1 / XmlnsDefinitionAttribute.cs
//------------------------------------------------------------------------
//
// Microsoft Windows Client Platform
// Copyright (C) Microsoft Corporation, 2005
//
// File: XmlnsDefinitionAttribute.cs
//
// Contents: Attribute that keep mapping between Xml namespace and
// the known types in assembly.
//
// Created: 01/19/2005 weibz
//
//-----------------------------------------------------------------------
using System;
using System.ComponentModel;
namespace System.Windows.Markup
{
///
///
/// XmlnsDefinitionAttribute keeps a mapping between Xml namespace and CLR namespace in an Assembly.
/// The Xml namespace can be used in a Xaml Markup file.
///
///
/// To find the appropriate types for element and attribute in xaml file, xaml processors MUST
/// search each referenced assembly for XmlnsDefinitionAttribute. If the xmlns for element tag
/// or attribute matches with the XmlNamespace in this XmlnsDefinitionAttibute, the Xaml processor
/// then takes use of the ClrNamespace and AssemblyName stored in this Attibute instance to check
/// if the element or attribute matches any type inside this namespace in the Assembly.
///
/// For a WinFX assembly, it can set this attibute like below:
///
/// [assembly:XmlnsDefinition("http://schemas.fabrikam.com/mynamespace", "fabrikam.myproduct.mycategory1")]
/// [assembly:XmlnsDefinition("http://schemas.fabrikam.com/mynamespace", "fabrikam.myproduct.mycategory2")]
///
/// [assembly:XmlnsDefinition("xmlnamsspace", "clrnamespace", AssemblyName="myassembly or full assemblyname")]
///
/// If fabrikam.myproduct.mycategory namespace in this assembly contains a UIElement such as "MyButton", the
/// xaml file could use it like below:
///
/// Page xmlns:myns="http://schemas.fabrikam.com/mynamespace" ....
/// myns:MyButton ...../myns:MyButton
/// /Page
///
///
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
public sealed class XmlnsDefinitionAttribute: Attribute
{
///
/// Constructor
///
///
/// XmlNamespace used by Markup file
///
///
/// Clr namespace which contains known types that are used by Markup File.
///
public XmlnsDefinitionAttribute(string xmlNamespace, string clrNamespace)
{
// Validate Input Arguments
if (xmlNamespace == null)
{
throw new ArgumentNullException("xmlNamespace");
}
if (clrNamespace == null)
{
throw new ArgumentNullException("clrNamespace");
}
_xmlNamespace = xmlNamespace;
_clrNamespace = clrNamespace;
}
#region public properties
///
/// XmlNamespace which can be used in Markup file.
/// such as XmlNamespace is set to
/// "http://schemas.fabrikam.com/mynamespace".
///
/// The markup file can have definition like
/// xmlns:myns="http://schemas.fabrikam.com/mynamespace"
///
///
public string XmlNamespace
{
get { return _xmlNamespace; }
}
///
/// ClrNamespace which map to XmlNamespace.
/// This ClrNamespace should contain some types which are used
/// by Xaml markup file.
///
public string ClrNamespace
{
get { return _clrNamespace; }
}
///
/// The name of Assembly that contains some types inside CLRNamespace.
/// If the assemblyName is not set, the code should take the assembly
/// for which the instance of this attribute is created.
///
public string AssemblyName
{
get { return _assemblyName; }
set { _assemblyName = value; }
}
#endregion public properties
#region Private Fields
private string _xmlNamespace;
private string _clrNamespace;
private string _assemblyName;
#endregion Private Fields
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------
//
// Microsoft Windows Client Platform
// Copyright (C) Microsoft Corporation, 2005
//
// File: XmlnsDefinitionAttribute.cs
//
// Contents: Attribute that keep mapping between Xml namespace and
// the known types in assembly.
//
// Created: 01/19/2005 weibz
//
//-----------------------------------------------------------------------
using System;
using System.ComponentModel;
namespace System.Windows.Markup
{
///
///
/// XmlnsDefinitionAttribute keeps a mapping between Xml namespace and CLR namespace in an Assembly.
/// The Xml namespace can be used in a Xaml Markup file.
///
///
/// To find the appropriate types for element and attribute in xaml file, xaml processors MUST
/// search each referenced assembly for XmlnsDefinitionAttribute. If the xmlns for element tag
/// or attribute matches with the XmlNamespace in this XmlnsDefinitionAttibute, the Xaml processor
/// then takes use of the ClrNamespace and AssemblyName stored in this Attibute instance to check
/// if the element or attribute matches any type inside this namespace in the Assembly.
///
/// For a WinFX assembly, it can set this attibute like below:
///
/// [assembly:XmlnsDefinition("http://schemas.fabrikam.com/mynamespace", "fabrikam.myproduct.mycategory1")]
/// [assembly:XmlnsDefinition("http://schemas.fabrikam.com/mynamespace", "fabrikam.myproduct.mycategory2")]
///
/// [assembly:XmlnsDefinition("xmlnamsspace", "clrnamespace", AssemblyName="myassembly or full assemblyname")]
///
/// If fabrikam.myproduct.mycategory namespace in this assembly contains a UIElement such as "MyButton", the
/// xaml file could use it like below:
///
/// Page xmlns:myns="http://schemas.fabrikam.com/mynamespace" ....
/// myns:MyButton ...../myns:MyButton
/// /Page
///
///
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
public sealed class XmlnsDefinitionAttribute: Attribute
{
///
/// Constructor
///
///
/// XmlNamespace used by Markup file
///
///
/// Clr namespace which contains known types that are used by Markup File.
///
public XmlnsDefinitionAttribute(string xmlNamespace, string clrNamespace)
{
// Validate Input Arguments
if (xmlNamespace == null)
{
throw new ArgumentNullException("xmlNamespace");
}
if (clrNamespace == null)
{
throw new ArgumentNullException("clrNamespace");
}
_xmlNamespace = xmlNamespace;
_clrNamespace = clrNamespace;
}
#region public properties
///
/// XmlNamespace which can be used in Markup file.
/// such as XmlNamespace is set to
/// "http://schemas.fabrikam.com/mynamespace".
///
/// The markup file can have definition like
/// xmlns:myns="http://schemas.fabrikam.com/mynamespace"
///
///
public string XmlNamespace
{
get { return _xmlNamespace; }
}
///
/// ClrNamespace which map to XmlNamespace.
/// This ClrNamespace should contain some types which are used
/// by Xaml markup file.
///
public string ClrNamespace
{
get { return _clrNamespace; }
}
///
/// The name of Assembly that contains some types inside CLRNamespace.
/// If the assemblyName is not set, the code should take the assembly
/// for which the instance of this attribute is created.
///
public string AssemblyName
{
get { return _assemblyName; }
set { _assemblyName = value; }
}
#endregion public properties
#region Private Fields
private string _xmlNamespace;
private string _clrNamespace;
private string _assemblyName;
#endregion Private Fields
}
}
// 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
- StreamReader.cs
- HiddenFieldPageStatePersister.cs
- BufferBuilder.cs
- ContentFileHelper.cs
- XmlDocumentFragment.cs
- GroupQuery.cs
- ReliableSession.cs
- ObservableCollectionDefaultValueFactory.cs
- HttpProfileGroupBase.cs
- Set.cs
- WebPartTransformerAttribute.cs
- ApplicationBuildProvider.cs
- DataServiceConfiguration.cs
- PolicyStatement.cs
- XmlSchemaAppInfo.cs
- SymbolType.cs
- ToolStripDropTargetManager.cs
- SHA1.cs
- AspNetSynchronizationContext.cs
- StringSorter.cs
- HostedHttpContext.cs
- TabItemAutomationPeer.cs
- WhiteSpaceTrimStringConverter.cs
- TextMessageEncoder.cs
- NodeInfo.cs
- ToolboxItemAttribute.cs
- DataTableTypeConverter.cs
- NavigationProperty.cs
- AsmxEndpointPickerExtension.cs
- OdbcCommandBuilder.cs
- SmtpSpecifiedPickupDirectoryElement.cs
- CodeDomComponentSerializationService.cs
- EventLogPermissionEntryCollection.cs
- CopyAttributesAction.cs
- SpeechAudioFormatInfo.cs
- CustomTypeDescriptor.cs
- ColorPalette.cs
- RightsManagementPermission.cs
- SettingsPropertyValue.cs
- DBCommandBuilder.cs
- EventWaitHandleSecurity.cs
- Drawing.cs
- Timeline.cs
- OleDbWrapper.cs
- FixedDocument.cs
- LinkUtilities.cs
- QueryLifecycle.cs
- BamlResourceSerializer.cs
- InvalidFilterCriteriaException.cs
- FuncTypeConverter.cs
- XmlIgnoreAttribute.cs
- ServiceAuthorizationElement.cs
- FormClosedEvent.cs
- JournalEntryStack.cs
- StateBag.cs
- Image.cs
- StorageEntitySetMapping.cs
- SystemEvents.cs
- Ticks.cs
- LowerCaseStringConverter.cs
- VisualBasicDesignerHelper.cs
- FormsAuthenticationUserCollection.cs
- ServiceDescription.cs
- PathSegment.cs
- ChildDocumentBlock.cs
- HostedHttpContext.cs
- PropertyCondition.cs
- TextTreeFixupNode.cs
- EncodingInfo.cs
- SchemaName.cs
- UnmanagedMarshal.cs
- FileUtil.cs
- util.cs
- SerialPinChanges.cs
- SQLRoleProvider.cs
- SiteMapDataSource.cs
- Rect.cs
- DataGridItemAttachedStorage.cs
- WebPartTransformerAttribute.cs
- RotateTransform3D.cs
- NavigationProgressEventArgs.cs
- HttpListenerException.cs
- Timer.cs
- MailAddressCollection.cs
- ChtmlPageAdapter.cs
- SecurityException.cs
- FlowDocumentPaginator.cs
- MetadataUtil.cs
- CodeDomConfigurationHandler.cs
- SymLanguageType.cs
- PrintPageEvent.cs
- WebPartDescription.cs
- HttpCapabilitiesBase.cs
- ChtmlCommandAdapter.cs
- SEHException.cs
- StringArrayEditor.cs
- ObjectConverter.cs
- CatalogZoneBase.cs
- RealizationContext.cs
- EntityContainerRelationshipSet.cs