Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / wpf / src / Framework / System / Windows / ComponentResourceKey.cs / 1 / ComponentResourceKey.cs
using System;
using System.Reflection;
using System.Text;
using System.ComponentModel;
namespace System.Windows
{
///
/// Key class for custom components to define the names of their resources to be loaded by SystemResources.
///
[TypeConverter(typeof(System.Windows.Markup.ComponentResourceKeyConverter))]
public class ComponentResourceKey : ResourceKey
{
///
/// Default constructor. Type and ID are null.
///
public ComponentResourceKey()
{
}
///
/// Type and ID are initialized to the specified parameters.
///
/// The Type to which this key is associated.
/// A unique ID to differentiate this key from others associated with this type.
public ComponentResourceKey(Type typeInTargetAssembly, object resourceId)
{
if (typeInTargetAssembly == null)
{
throw new ArgumentNullException("typeInTargetAssembly");
}
if (resourceId == null)
{
throw new ArgumentNullException("resourceId");
}
_typeInTargetAssembly = typeInTargetAssembly;
_typeInTargetAssemblyInitialized = true;
_resourceId = resourceId;
_resourceIdInitialized = true;
}
///
/// The Type associated with this resources. Must be in assembly where the resource is located.
///
public Type TypeInTargetAssembly
{
get
{
return _typeInTargetAssembly;
}
set
{
if (value == null)
{
throw new ArgumentNullException("value");
}
if (_typeInTargetAssemblyInitialized)
{
throw new InvalidOperationException(SR.Get(SRID.ChangingTypeNotAllowed));
}
_typeInTargetAssembly = value;
_typeInTargetAssemblyInitialized = true;
}
}
///
/// Used to determine where to look for the resource dictionary that holds this resource.
///
public override Assembly Assembly
{
get
{
return (_typeInTargetAssembly != null) ? _typeInTargetAssembly.Assembly : null;
}
}
///
/// A unique Id to differentiate this key from other keys associated with the same type.
///
public object ResourceId
{
get
{
return _resourceId;
}
set
{
if (_resourceIdInitialized)
{
throw new InvalidOperationException(SR.Get(SRID.ChangingIdNotAllowed));
}
_resourceId = value;
_resourceIdInitialized = true;
}
}
///
/// Determines if the passed in object is equal to this object.
/// Two keys will be equal if they both have equal Types and IDs.
///
/// The object to compare with.
/// True if the objects are equal. False otherwise.
public override bool Equals(object o)
{
ComponentResourceKey key = o as ComponentResourceKey;
if (key != null)
{
return ((key._typeInTargetAssembly != null) ? key._typeInTargetAssembly.Equals(this._typeInTargetAssembly) : (this._typeInTargetAssembly == null)) &&
((key._resourceId != null) ? key._resourceId.Equals(this._resourceId) : (this._resourceId == null));
}
return false;
}
///
/// Serves as a hash function for a particular type.
///
public override int GetHashCode()
{
return ((_typeInTargetAssembly != null) ? _typeInTargetAssembly.GetHashCode() : 0) ^ ((_resourceId != null) ? _resourceId.GetHashCode() : 0);
}
///
/// return string representation of this key
///
/// the string representation of the key
public override string ToString()
{
StringBuilder strBuilder = new StringBuilder(256);
strBuilder.Append("TargetType=");
strBuilder.Append((_typeInTargetAssembly != null) ? _typeInTargetAssembly.FullName : "null");
strBuilder.Append(" ID=");
strBuilder.Append((_resourceId != null) ? _resourceId.ToString() : "null");
return strBuilder.ToString();
}
private Type _typeInTargetAssembly;
private bool _typeInTargetAssemblyInitialized;
private object _resourceId;
private bool _resourceIdInitialized;
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
using System;
using System.Reflection;
using System.Text;
using System.ComponentModel;
namespace System.Windows
{
///
/// Key class for custom components to define the names of their resources to be loaded by SystemResources.
///
[TypeConverter(typeof(System.Windows.Markup.ComponentResourceKeyConverter))]
public class ComponentResourceKey : ResourceKey
{
///
/// Default constructor. Type and ID are null.
///
public ComponentResourceKey()
{
}
///
/// Type and ID are initialized to the specified parameters.
///
/// The Type to which this key is associated.
/// A unique ID to differentiate this key from others associated with this type.
public ComponentResourceKey(Type typeInTargetAssembly, object resourceId)
{
if (typeInTargetAssembly == null)
{
throw new ArgumentNullException("typeInTargetAssembly");
}
if (resourceId == null)
{
throw new ArgumentNullException("resourceId");
}
_typeInTargetAssembly = typeInTargetAssembly;
_typeInTargetAssemblyInitialized = true;
_resourceId = resourceId;
_resourceIdInitialized = true;
}
///
/// The Type associated with this resources. Must be in assembly where the resource is located.
///
public Type TypeInTargetAssembly
{
get
{
return _typeInTargetAssembly;
}
set
{
if (value == null)
{
throw new ArgumentNullException("value");
}
if (_typeInTargetAssemblyInitialized)
{
throw new InvalidOperationException(SR.Get(SRID.ChangingTypeNotAllowed));
}
_typeInTargetAssembly = value;
_typeInTargetAssemblyInitialized = true;
}
}
///
/// Used to determine where to look for the resource dictionary that holds this resource.
///
public override Assembly Assembly
{
get
{
return (_typeInTargetAssembly != null) ? _typeInTargetAssembly.Assembly : null;
}
}
///
/// A unique Id to differentiate this key from other keys associated with the same type.
///
public object ResourceId
{
get
{
return _resourceId;
}
set
{
if (_resourceIdInitialized)
{
throw new InvalidOperationException(SR.Get(SRID.ChangingIdNotAllowed));
}
_resourceId = value;
_resourceIdInitialized = true;
}
}
///
/// Determines if the passed in object is equal to this object.
/// Two keys will be equal if they both have equal Types and IDs.
///
/// The object to compare with.
/// True if the objects are equal. False otherwise.
public override bool Equals(object o)
{
ComponentResourceKey key = o as ComponentResourceKey;
if (key != null)
{
return ((key._typeInTargetAssembly != null) ? key._typeInTargetAssembly.Equals(this._typeInTargetAssembly) : (this._typeInTargetAssembly == null)) &&
((key._resourceId != null) ? key._resourceId.Equals(this._resourceId) : (this._resourceId == null));
}
return false;
}
///
/// Serves as a hash function for a particular type.
///
public override int GetHashCode()
{
return ((_typeInTargetAssembly != null) ? _typeInTargetAssembly.GetHashCode() : 0) ^ ((_resourceId != null) ? _resourceId.GetHashCode() : 0);
}
///
/// return string representation of this key
///
/// the string representation of the key
public override string ToString()
{
StringBuilder strBuilder = new StringBuilder(256);
strBuilder.Append("TargetType=");
strBuilder.Append((_typeInTargetAssembly != null) ? _typeInTargetAssembly.FullName : "null");
strBuilder.Append(" ID=");
strBuilder.Append((_resourceId != null) ? _resourceId.ToString() : "null");
return strBuilder.ToString();
}
private Type _typeInTargetAssembly;
private bool _typeInTargetAssemblyInitialized;
private object _resourceId;
private bool _resourceIdInitialized;
}
}
// 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
- CodeIndexerExpression.cs
- ButtonChrome.cs
- DataGridViewCellPaintingEventArgs.cs
- TaskResultSetter.cs
- ConfigurationFileMap.cs
- ItemsPanelTemplate.cs
- WithStatement.cs
- FrameworkTextComposition.cs
- SqlXmlStorage.cs
- AdditionalEntityFunctions.cs
- TypeHelpers.cs
- XmlRootAttribute.cs
- UIPermission.cs
- EntityDataSourceDesignerHelper.cs
- UnmanagedMemoryAccessor.cs
- LogManagementAsyncResult.cs
- QuaternionConverter.cs
- DataGridBoundColumn.cs
- XmlPropertyBag.cs
- ExtentKey.cs
- RtfToken.cs
- MetabaseSettings.cs
- BinaryMethodMessage.cs
- BoundingRectTracker.cs
- X500Name.cs
- RtfToken.cs
- EventWaitHandleSecurity.cs
- WSSecurityXXX2005.cs
- MarshalByRefObject.cs
- VisualTreeUtils.cs
- FtpRequestCacheValidator.cs
- HttpCacheParams.cs
- ClientSideQueueItem.cs
- OAVariantLib.cs
- SignatureDescription.cs
- DesignerSerializerAttribute.cs
- NullableLongMinMaxAggregationOperator.cs
- RegexNode.cs
- CoTaskMemHandle.cs
- XmlReturnReader.cs
- securitycriticaldataClass.cs
- HttpRequestWrapper.cs
- SafeNativeMethods.cs
- SectionInformation.cs
- Composition.cs
- CombinedTcpChannel.cs
- AuthenticationException.cs
- SoapCodeExporter.cs
- ClientTarget.cs
- infer.cs
- ZipPackagePart.cs
- BoundPropertyEntry.cs
- Matrix.cs
- AnimatedTypeHelpers.cs
- DataGridViewRowPrePaintEventArgs.cs
- CheckBoxRenderer.cs
- SiteMapNode.cs
- MdiWindowListItemConverter.cs
- DataGridItemCollection.cs
- CTreeGenerator.cs
- DataGridViewComboBoxEditingControl.cs
- EmptyEnumerator.cs
- PropertyKey.cs
- ArrayElementGridEntry.cs
- XmlAtomicValue.cs
- ToolStripSeparator.cs
- ViewGenResults.cs
- _CacheStreams.cs
- AuthorizationRule.cs
- DesignerAdapterUtil.cs
- UpdatePanel.cs
- WindowsSolidBrush.cs
- HttpHandlersSection.cs
- Rect3DValueSerializer.cs
- LicenseManager.cs
- CustomValidator.cs
- GC.cs
- CapabilitiesUse.cs
- ThreadExceptionDialog.cs
- UnsafeNativeMethodsMilCoreApi.cs
- OrderPreservingPipeliningMergeHelper.cs
- UnsafeNativeMethods.cs
- WindowsHyperlink.cs
- OracleDateTime.cs
- SoapParser.cs
- ProxyManager.cs
- RowParagraph.cs
- DataGridHelper.cs
- FormViewUpdateEventArgs.cs
- PointConverter.cs
- SQLSingle.cs
- XmlBindingWorker.cs
- NestedContainer.cs
- WebPartMovingEventArgs.cs
- GridViewSortEventArgs.cs
- BuildDependencySet.cs
- XamlSerializerUtil.cs
- HashHelper.cs
- TypeUtils.cs
- FloaterBaseParagraph.cs