Code:
/ 4.0 / 4.0 / untmp / 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- IntegerFacetDescriptionElement.cs
- ToolboxComponentsCreatingEventArgs.cs
- MemoryFailPoint.cs
- XmlDocumentType.cs
- ChannelTokenTypeConverter.cs
- WindowsComboBox.cs
- OdbcStatementHandle.cs
- ToolStripRendererSwitcher.cs
- DropShadowEffect.cs
- HideDisabledControlAdapter.cs
- _KerberosClient.cs
- NamespaceInfo.cs
- ParsedAttributeCollection.cs
- ReachSerializationUtils.cs
- DesignTimeType.cs
- CommandPlan.cs
- OverflowException.cs
- UnknownBitmapEncoder.cs
- ObjectQueryProvider.cs
- EntityDataSourceChangingEventArgs.cs
- ColorTransform.cs
- DictionaryTraceRecord.cs
- ObjectContextServiceProvider.cs
- NetSectionGroup.cs
- KerberosTicketHashIdentifierClause.cs
- BoundField.cs
- ResourceDescriptionAttribute.cs
- TextClipboardData.cs
- AssociationSet.cs
- UrlAuthFailureHandler.cs
- FontConverter.cs
- UIInitializationException.cs
- AuthStoreRoleProvider.cs
- CollectionViewProxy.cs
- SystemIPGlobalProperties.cs
- Italic.cs
- FilterFactory.cs
- ToolStripContainer.cs
- ThousandthOfEmRealDoubles.cs
- PropertyMap.cs
- IdleTimeoutMonitor.cs
- Registry.cs
- FamilyCollection.cs
- securitycriticaldataformultiplegetandset.cs
- ObjectParameterCollection.cs
- ThicknessConverter.cs
- ErrorsHelper.cs
- UserControl.cs
- EastAsianLunisolarCalendar.cs
- Triangle.cs
- DataPagerFieldCollection.cs
- ObjectStateEntryDbUpdatableDataRecord.cs
- CollectionChangeEventArgs.cs
- SizeIndependentAnimationStorage.cs
- HierarchicalDataSourceControl.cs
- ObjectCloneHelper.cs
- ComNativeDescriptor.cs
- UpdateTranslator.cs
- WebPartsPersonalizationAuthorization.cs
- WorkflowFormatterBehavior.cs
- TimelineClockCollection.cs
- DataContract.cs
- SafeEventLogWriteHandle.cs
- ActivityPropertyReference.cs
- PropertyTab.cs
- DBSqlParserTable.cs
- RegexWorker.cs
- Knowncolors.cs
- ExeContext.cs
- CodeDomExtensionMethods.cs
- DataBinder.cs
- XmlSchemaAny.cs
- Calendar.cs
- EventDescriptor.cs
- MetricEntry.cs
- TextPointerBase.cs
- Input.cs
- DbConnectionPoolOptions.cs
- BooleanAnimationUsingKeyFrames.cs
- UxThemeWrapper.cs
- Constants.cs
- SqlErrorCollection.cs
- EventLogPermissionEntry.cs
- TextBox.cs
- SchemaElementLookUpTable.cs
- ToolStripOverflow.cs
- ButtonFlatAdapter.cs
- BlurBitmapEffect.cs
- EntitySqlQueryState.cs
- XmlArrayAttribute.cs
- TripleDESCryptoServiceProvider.cs
- DataSourceCacheDurationConverter.cs
- PerfCounters.cs
- XslException.cs
- TypedTableBase.cs
- EUCJPEncoding.cs
- SiblingIterators.cs
- ClientProxyGenerator.cs
- ObjectViewListener.cs
- LineBreak.cs