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
- ValuePattern.cs
- ToolStripButton.cs
- DataServiceQueryContinuation.cs
- TransactionWaitAsyncResult.cs
- Label.cs
- PropertyFilterAttribute.cs
- XmlComplianceUtil.cs
- InputMethodStateChangeEventArgs.cs
- MailAddress.cs
- DPTypeDescriptorContext.cs
- SafeRightsManagementSessionHandle.cs
- RectangleF.cs
- PropertyExpression.cs
- SqlVisitor.cs
- RoleManagerModule.cs
- ViewStateException.cs
- XmlHierarchicalEnumerable.cs
- PenThread.cs
- Native.cs
- ParseHttpDate.cs
- Helpers.cs
- GradientSpreadMethodValidation.cs
- NativeObjectSecurity.cs
- MappingMetadataHelper.cs
- BufferBuilder.cs
- GenericIdentity.cs
- ActivationArguments.cs
- AnnotationComponentManager.cs
- PeerTransportListenAddressValidator.cs
- httpserverutility.cs
- WorkflowShape.cs
- TransformationRules.cs
- XmlUrlResolver.cs
- ElementProxy.cs
- DocumentGrid.cs
- SqlNodeAnnotation.cs
- ClientUtils.cs
- TextParagraphProperties.cs
- EventSourceCreationData.cs
- HitTestDrawingContextWalker.cs
- TargetControlTypeAttribute.cs
- ReaderWriterLockWrapper.cs
- AssemblyHash.cs
- DbConnectionHelper.cs
- FontFamily.cs
- SqlIdentifier.cs
- AutomationEventArgs.cs
- RuleInfoComparer.cs
- RSAOAEPKeyExchangeDeformatter.cs
- DataContractFormatAttribute.cs
- SubtreeProcessor.cs
- DataGridTableStyleMappingNameEditor.cs
- ControlValuePropertyAttribute.cs
- OleDbConnectionFactory.cs
- DataServiceBehavior.cs
- SqlCachedBuffer.cs
- CroppedBitmap.cs
- ClientUIRequest.cs
- Button.cs
- WindowsTreeView.cs
- LineGeometry.cs
- SQLInt32Storage.cs
- ProviderIncompatibleException.cs
- COM2PropertyPageUITypeConverter.cs
- ReadOnlyTernaryTree.cs
- bidPrivateBase.cs
- SHA256Cng.cs
- WebPartEventArgs.cs
- ResizeGrip.cs
- ClosureBinding.cs
- ServiceRoute.cs
- GridViewCellAutomationPeer.cs
- SpecularMaterial.cs
- SizeKeyFrameCollection.cs
- GatewayDefinition.cs
- RtfControls.cs
- TagPrefixInfo.cs
- ObjectConverter.cs
- ProfileGroupSettingsCollection.cs
- SourceFilter.cs
- XMLDiffLoader.cs
- PageCatalogPart.cs
- Int64AnimationBase.cs
- WebPartConnectionsCancelVerb.cs
- ComplexType.cs
- SerialPort.cs
- DataGridAddNewRow.cs
- XmlSchemas.cs
- URLMembershipCondition.cs
- XmlExtensionFunction.cs
- DelegateBodyWriter.cs
- MultiViewDesigner.cs
- TemplateControlParser.cs
- DifferencingCollection.cs
- DataGridViewDataErrorEventArgs.cs
- ProcessStartInfo.cs
- TextSearch.cs
- WebRequest.cs
- HtmlShimManager.cs
- TypeTypeConverter.cs