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
- ArrayExtension.cs
- CollectionsUtil.cs
- UniqueConstraint.cs
- TokenBasedSet.cs
- ToolStripActionList.cs
- MetaChildrenColumn.cs
- ParameterElementCollection.cs
- WebBrowserUriTypeConverter.cs
- XmlSchemaValidationException.cs
- RtfNavigator.cs
- DoubleLink.cs
- Base64Decoder.cs
- InkCanvasFeedbackAdorner.cs
- SafeNativeMethods.cs
- ParallelLoopState.cs
- ParallelDesigner.cs
- PageSetupDialog.cs
- AnnotationResource.cs
- NotifyIcon.cs
- NameValueCollection.cs
- InfoCardRSAPKCS1KeyExchangeFormatter.cs
- AlternateViewCollection.cs
- Int16Animation.cs
- StringReader.cs
- WizardPanelChangingEventArgs.cs
- MulticastOption.cs
- ContainerSelectorGlyph.cs
- FixedStringLookup.cs
- ScaleTransform3D.cs
- SiteMapPathDesigner.cs
- CacheSection.cs
- WebPartMenu.cs
- OutputScope.cs
- OleDbCommand.cs
- InvalidEnumArgumentException.cs
- ListMarkerSourceInfo.cs
- QuaternionValueSerializer.cs
- ClientFormsAuthenticationCredentials.cs
- Tile.cs
- MouseWheelEventArgs.cs
- OdbcPermission.cs
- RepeatButton.cs
- TextTrailingWordEllipsis.cs
- DateTimeConstantAttribute.cs
- SqlTrackingWorkflowInstance.cs
- DataGridViewCellStyle.cs
- ReadWriteObjectLock.cs
- FixedSchema.cs
- safesecurityhelperavalon.cs
- _Events.cs
- DateTime.cs
- TimeSpan.cs
- CacheForPrimitiveTypes.cs
- DetailsViewUpdatedEventArgs.cs
- StackSpiller.Generated.cs
- EntityDataSourceContainerNameConverter.cs
- HostingEnvironmentWrapper.cs
- NamespaceImport.cs
- DataGridCommandEventArgs.cs
- SessionParameter.cs
- GeneralTransformCollection.cs
- KeyValuePairs.cs
- NamespaceMapping.cs
- ContextMenu.cs
- StyleCollection.cs
- ContextMenu.cs
- AnnotationHelper.cs
- OdbcRowUpdatingEvent.cs
- ValidatedControlConverter.cs
- RelationshipSet.cs
- MenuAdapter.cs
- DetailsViewRowCollection.cs
- DesignerDataConnection.cs
- SocketInformation.cs
- DiscoveryExceptionDictionary.cs
- TransactionTraceIdentifier.cs
- ToolStripDesignerAvailabilityAttribute.cs
- InstanceDataCollectionCollection.cs
- TemplateField.cs
- ViewStateModeByIdAttribute.cs
- DataBoundControl.cs
- X509Chain.cs
- QueryCreatedEventArgs.cs
- CompilationRelaxations.cs
- UnsafeNativeMethods.cs
- SelectionHighlightInfo.cs
- Point3DAnimationBase.cs
- AccessDataSource.cs
- FragmentQueryKB.cs
- ApplicationServiceHelper.cs
- ClientRolePrincipal.cs
- OperatorExpressions.cs
- XmlSortKey.cs
- ObjectView.cs
- MulticastDelegate.cs
- ConfigUtil.cs
- MultilineStringEditor.cs
- Point3DAnimationBase.cs
- X509Certificate.cs
- BufferedReadStream.cs