Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / ComponentResourceKey.cs / 1305600 / 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- WindowsListViewItemCheckBox.cs
- Registry.cs
- AutomationIdentifier.cs
- HttpContextServiceHost.cs
- Tablet.cs
- ThrowHelper.cs
- AnimationException.cs
- ResourceDisplayNameAttribute.cs
- DocumentEventArgs.cs
- NamespaceEmitter.cs
- TableCell.cs
- SettingsSection.cs
- Certificate.cs
- BackgroundFormatInfo.cs
- AnchoredBlock.cs
- GACMembershipCondition.cs
- StreamGeometry.cs
- DecoderNLS.cs
- PointLightBase.cs
- SafeMarshalContext.cs
- TypedTableGenerator.cs
- ZipFileInfoCollection.cs
- DataGridViewRowHeightInfoNeededEventArgs.cs
- StreamInfo.cs
- PickBranch.cs
- ServiceOperationListItem.cs
- MenuStrip.cs
- WebPartRestoreVerb.cs
- TransformGroup.cs
- SkinIDTypeConverter.cs
- CodeDOMProvider.cs
- ActiveDocumentEvent.cs
- EventProvider.cs
- DbMetaDataFactory.cs
- Privilege.cs
- MexHttpBindingCollectionElement.cs
- EntryWrittenEventArgs.cs
- MailAddressParser.cs
- SmiXetterAccessMap.cs
- OracleDataAdapter.cs
- Domain.cs
- LightweightEntityWrapper.cs
- UnsupportedPolicyOptionsException.cs
- HtmlInputControl.cs
- AutomationPatternInfo.cs
- ListViewUpdateEventArgs.cs
- MemberDescriptor.cs
- Char.cs
- ImageBrush.cs
- HierarchicalDataBoundControl.cs
- XmlSchemaSimpleType.cs
- VarRemapper.cs
- DictionaryContent.cs
- ObjectItemCollection.cs
- DataGridViewRowContextMenuStripNeededEventArgs.cs
- CodeAccessSecurityEngine.cs
- Cursors.cs
- ZipIOZip64EndOfCentralDirectoryBlock.cs
- DataGridViewCellStateChangedEventArgs.cs
- ColorBlend.cs
- ItemsControlAutomationPeer.cs
- BitmapEffectGroup.cs
- ParameterInfo.cs
- ItemsControl.cs
- StringFunctions.cs
- _NetRes.cs
- RightsManagementPermission.cs
- ReflectPropertyDescriptor.cs
- DataGridViewColumnCollection.cs
- SlipBehavior.cs
- SectionInput.cs
- EncodingInfo.cs
- HtmlInputHidden.cs
- PropertyDescriptorComparer.cs
- QilInvokeEarlyBound.cs
- XPathAncestorQuery.cs
- Annotation.cs
- EntityContainerEmitter.cs
- ProxyGenerationError.cs
- EventBuilder.cs
- CommonProperties.cs
- ActiveDocumentEvent.cs
- HttpException.cs
- EditorPart.cs
- ToolStripSplitStackLayout.cs
- SmtpFailedRecipientsException.cs
- Hash.cs
- EdgeModeValidation.cs
- QueryGeneratorBase.cs
- WebSysDefaultValueAttribute.cs
- DocumentReferenceCollection.cs
- DataGridViewImageColumn.cs
- Preprocessor.cs
- DecimalStorage.cs
- UIServiceHelper.cs
- CalendarBlackoutDatesCollection.cs
- Parser.cs
- CommonDialog.cs
- Dynamic.cs
- DataTableNewRowEvent.cs