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
- PageDeviceFont.cs
- ResourceProperty.cs
- XsltSettings.cs
- ImageClickEventArgs.cs
- OdbcPermission.cs
- CodeTypeReferenceCollection.cs
- AutoScrollExpandMessageFilter.cs
- OpenTypeLayout.cs
- WebResourceAttribute.cs
- GeometryValueSerializer.cs
- HostingEnvironmentSection.cs
- ToolStripContainerDesigner.cs
- WindowsListView.cs
- EntityDataSourceChangingEventArgs.cs
- CommunicationException.cs
- CustomTrackingQuery.cs
- FunctionParameter.cs
- QueryCreatedEventArgs.cs
- SplitterCancelEvent.cs
- SetIterators.cs
- Container.cs
- XmlCharCheckingWriter.cs
- IntermediatePolicyValidator.cs
- DesignerSerializerAttribute.cs
- ItemCollectionEditor.cs
- PeerObject.cs
- WithStatement.cs
- RegionIterator.cs
- VarRemapper.cs
- XmlLinkedNode.cs
- DnsPermission.cs
- TemporaryBitmapFile.cs
- MatcherBuilder.cs
- Publisher.cs
- DBSqlParser.cs
- NotifyInputEventArgs.cs
- RawStylusInputCustomData.cs
- SqlCachedBuffer.cs
- ArraySubsetEnumerator.cs
- CodeExpressionStatement.cs
- SortedList.cs
- PageThemeCodeDomTreeGenerator.cs
- CfgArc.cs
- AutomationEventArgs.cs
- PrintPreviewGraphics.cs
- ElementAction.cs
- FlagsAttribute.cs
- ManipulationDevice.cs
- PointConverter.cs
- ErrorFormatter.cs
- DrawingVisualDrawingContext.cs
- IntegerFacetDescriptionElement.cs
- SqlExpander.cs
- _LocalDataStore.cs
- PostBackOptions.cs
- Grant.cs
- StoragePropertyMapping.cs
- Point3DCollectionConverter.cs
- objectresult_tresulttype.cs
- ProjectionPathSegment.cs
- WebPartTransformer.cs
- ConnectionManagementElement.cs
- ServiceOperationWrapper.cs
- SQLInt32.cs
- HtmlSelect.cs
- EntityConnection.cs
- hebrewshape.cs
- MappingItemCollection.cs
- ArgumentOutOfRangeException.cs
- CustomPopupPlacement.cs
- IdentityModelDictionary.cs
- QilTernary.cs
- Shape.cs
- Int32Animation.cs
- DialogResultConverter.cs
- WebZone.cs
- WebBrowserNavigatedEventHandler.cs
- AppLevelCompilationSectionCache.cs
- MbpInfo.cs
- MaskedTextBoxTextEditor.cs
- FutureFactory.cs
- TextSelectionHighlightLayer.cs
- BamlRecordReader.cs
- MetafileHeader.cs
- CodeNamespaceImportCollection.cs
- ConnectionConsumerAttribute.cs
- IdentityModelStringsVersion1.cs
- BitHelper.cs
- PersonalizationState.cs
- BinaryUtilClasses.cs
- Point.cs
- RuntimeWrappedException.cs
- AttributeCollection.cs
- IItemContainerGenerator.cs
- Size3D.cs
- ListViewGroup.cs
- FormsAuthenticationCredentials.cs
- RectangleGeometry.cs
- HtmlControl.cs
- XmlSchemaSimpleTypeList.cs