Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / Tools / System.Activities.Presentation / System / Activities / Presentation / EditorOptionAttribute.cs / 1305376 / EditorOptionAttribute.cs
//---------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. //--------------------------------------------------------------- namespace System.Activities.Presentation.PropertyEditing { using System.Runtime; using System.Collections; [Fx.Tag.XamlVisible(false)] [AttributeUsage(AttributeTargets.Property | AttributeTargets.Class, AllowMultiple = true)] sealed class EditorOptionsAttribute : Attribute { public string Name { get; set; } public object Value { get; set; } //TypeId is needed so that multiple EditorOptionsAttribute could be added to the same type/property public override object TypeId { get { return new EditorOptionsAttributeTypeId { BaseTypeId = base.TypeId, Name = this.Name, Value = this.Value }; } } public static T GetOptionValue(IEnumerable attributes, string optionName, T defaultValue) { object optionValue; if (TryGetOptionValue(attributes, optionName, out optionValue)) { return (T)optionValue; } return defaultValue; } public static bool TryGetOptionValue(IEnumerable attributes, string optionName, out object optionValue) { foreach (Attribute attribute in attributes) { EditorOptionsAttribute optionAttribute = attribute as EditorOptionsAttribute; if (optionAttribute != null && optionAttribute.Name.Equals(optionName)) { optionValue = optionAttribute.Value; return true; } } optionValue = null; return false; } //A class to uniquely identify a name-value pair class EditorOptionsAttributeTypeId { public object BaseTypeId { get; set; } public string Name { get; set; } public object Value { get; set; } public override bool Equals(object obj) { EditorOptionsAttributeTypeId that = obj as EditorOptionsAttributeTypeId; if (that == null) return false; return this.BaseTypeId == that.BaseTypeId && string.Equals(this.Name, that.Name) && object.Equals(this.Value, that.Value); } public override int GetHashCode() { return (BaseTypeId == null ? 0 : BaseTypeId.GetHashCode()) ^ (Name == null ? 0 : Name.GetHashCode()) ^ (Value == null ? 0 : Value.GetHashCode()); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //---------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. //--------------------------------------------------------------- namespace System.Activities.Presentation.PropertyEditing { using System.Runtime; using System.Collections; [Fx.Tag.XamlVisible(false)] [AttributeUsage(AttributeTargets.Property | AttributeTargets.Class, AllowMultiple = true)] sealed class EditorOptionsAttribute : Attribute { public string Name { get; set; } public object Value { get; set; } //TypeId is needed so that multiple EditorOptionsAttribute could be added to the same type/property public override object TypeId { get { return new EditorOptionsAttributeTypeId { BaseTypeId = base.TypeId, Name = this.Name, Value = this.Value }; } } public static T GetOptionValue (IEnumerable attributes, string optionName, T defaultValue) { object optionValue; if (TryGetOptionValue(attributes, optionName, out optionValue)) { return (T)optionValue; } return defaultValue; } public static bool TryGetOptionValue(IEnumerable attributes, string optionName, out object optionValue) { foreach (Attribute attribute in attributes) { EditorOptionsAttribute optionAttribute = attribute as EditorOptionsAttribute; if (optionAttribute != null && optionAttribute.Name.Equals(optionName)) { optionValue = optionAttribute.Value; return true; } } optionValue = null; return false; } //A class to uniquely identify a name-value pair class EditorOptionsAttributeTypeId { public object BaseTypeId { get; set; } public string Name { get; set; } public object Value { get; set; } public override bool Equals(object obj) { EditorOptionsAttributeTypeId that = obj as EditorOptionsAttributeTypeId; if (that == null) return false; return this.BaseTypeId == that.BaseTypeId && string.Equals(this.Name, that.Name) && object.Equals(this.Value, that.Value); } public override int GetHashCode() { return (BaseTypeId == null ? 0 : BaseTypeId.GetHashCode()) ^ (Name == null ? 0 : Name.GetHashCode()) ^ (Value == null ? 0 : Value.GetHashCode()); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ArraySet.cs
- ManipulationStartedEventArgs.cs
- IriParsingElement.cs
- OrElse.cs
- Normalizer.cs
- CapabilitiesAssignment.cs
- WebScriptServiceHostFactory.cs
- LogicalTreeHelper.cs
- ConfigurationErrorsException.cs
- SafeBitVector32.cs
- Brush.cs
- DataPagerFieldCommandEventArgs.cs
- InertiaExpansionBehavior.cs
- ContractNamespaceAttribute.cs
- GraphicsPathIterator.cs
- WebPartZoneBase.cs
- CurrentChangingEventManager.cs
- EventDescriptor.cs
- NullRuntimeConfig.cs
- ClockController.cs
- HttpListenerElement.cs
- FlowDocumentPage.cs
- EllipseGeometry.cs
- EntityDataSourceState.cs
- SocketException.cs
- NamespaceEmitter.cs
- SqlCommand.cs
- WebPartDisplayModeEventArgs.cs
- RSAOAEPKeyExchangeDeformatter.cs
- OrderPreservingPipeliningMergeHelper.cs
- DeviceSpecificDesigner.cs
- UrlMapping.cs
- GroupBoxRenderer.cs
- CheckBoxField.cs
- RSAPKCS1KeyExchangeFormatter.cs
- VirtualPath.cs
- StringArrayConverter.cs
- NavigateEvent.cs
- TaskScheduler.cs
- ColorBlend.cs
- ClientUrlResolverWrapper.cs
- FixedSOMImage.cs
- Documentation.cs
- HttpMethodConstraint.cs
- ConnectionManagementElementCollection.cs
- BufferedGraphicsManager.cs
- SqlConnection.cs
- DataGridRelationshipRow.cs
- M3DUtil.cs
- WorkflowTerminatedException.cs
- XsdCachingReader.cs
- ConfigsHelper.cs
- FontFamily.cs
- SqlDataSourceConfigureSortForm.cs
- MessageDecoder.cs
- DataGridViewComboBoxCell.cs
- Simplifier.cs
- RoleManagerModule.cs
- DesignerHierarchicalDataSourceView.cs
- SqlTypesSchemaImporter.cs
- FontStretchConverter.cs
- ChangePassword.cs
- XmlAtomicValue.cs
- GradientSpreadMethodValidation.cs
- DataGridTextBoxColumn.cs
- NonBatchDirectoryCompiler.cs
- LinkAreaEditor.cs
- XmlSchemaParticle.cs
- XmlSchemaExporter.cs
- ITextView.cs
- AttachInfo.cs
- FixedHighlight.cs
- WpfSharedBamlSchemaContext.cs
- MarkupWriter.cs
- EntityDataSourceValidationException.cs
- XsltCompileContext.cs
- EncoderFallback.cs
- CacheDependency.cs
- RijndaelManagedTransform.cs
- SelectionEditor.cs
- ThicknessAnimation.cs
- SimpleRecyclingCache.cs
- ExtendedPropertyDescriptor.cs
- RemoveStoryboard.cs
- safemediahandle.cs
- CompressEmulationStream.cs
- LogPolicy.cs
- DeploymentSection.cs
- PackageRelationship.cs
- ReverseQueryOperator.cs
- Set.cs
- Directory.cs
- WindowsFormsSectionHandler.cs
- GeneralTransform3DGroup.cs
- IPPacketInformation.cs
- Hyperlink.cs
- DynamicValidatorEventArgs.cs
- DbProviderSpecificTypePropertyAttribute.cs
- Rect3D.cs
- WindowPatternIdentifiers.cs