Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / DynamicData / DynamicData / Util / AttributeExtensions.cs / 1305376 / AttributeExtensions.cs
namespace System.Web.DynamicData.Util { using System; using System.Collections.Generic; using System.Linq; internal static class AttributeExtensions { ////// Gets the first attribute of a given time on the target AttributeCollection, or null. /// ///The attribute type /// The AttributeCollection object ///internal static TAttribute FirstOrDefault (this System.ComponentModel.AttributeCollection attributes) where TAttribute : Attribute { return attributes.OfType ().FirstOrDefault(); } internal static TResult GetAttributePropertyValue (this System.ComponentModel.AttributeCollection attributes, Func propertyGetter) where TResult : class where TAttribute : Attribute { return attributes.GetAttributePropertyValue(propertyGetter, null); } internal static TResult GetAttributePropertyValue (this System.ComponentModel.AttributeCollection attributes, Func propertyGetter, TResult defaultValue) where TAttribute : Attribute { var attribute = attributes.FirstOrDefault (); return attribute.GetPropertyValue (propertyGetter, defaultValue); } /// /// Gets the property for a given attribute reference or returns null if the reference is null. /// ///The attribute type ///The type of the attribute's property /// The attribute reference /// The function to evaluate on the attribute ///internal static TResult GetPropertyValue (this TAttribute attribute, Func propertyGetter) where TResult : class where TAttribute : Attribute { return attribute.GetPropertyValue(propertyGetter, null); } /// /// Gets the property for a given attribute reference or returns the default value if the reference is null. /// ///The attribute type ///The type of the attribute's property /// The attribute reference /// The function to evaluate on the attribute /// The default value to return if the attribute is null ///internal static TResult GetPropertyValue (this TAttribute attribute, Func propertyGetter, TResult defaultValue) where TAttribute : Attribute { if (attribute != null) { return propertyGetter(attribute); } else { return defaultValue; } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- LinqToSqlWrapper.cs
- ActivityValidator.cs
- DataGridTextBox.cs
- DesignTimeParseData.cs
- PrimitiveXmlSerializers.cs
- Geometry.cs
- GrammarBuilderPhrase.cs
- ScrollBarAutomationPeer.cs
- Mapping.cs
- ResXFileRef.cs
- CultureTableRecord.cs
- AttachmentService.cs
- WebPartDeleteVerb.cs
- XmlDesignerDataSourceView.cs
- ComponentSerializationService.cs
- EditorPart.cs
- ZipIOZip64EndOfCentralDirectoryBlock.cs
- InitializationEventAttribute.cs
- ToolStripSeparator.cs
- DriveInfo.cs
- ResourcePool.cs
- XmlNodeChangedEventArgs.cs
- SimpleApplicationHost.cs
- EventLogger.cs
- StateDesigner.CommentLayoutGlyph.cs
- dataprotectionpermission.cs
- FindCriteriaApril2005.cs
- TimeManager.cs
- Button.cs
- LayoutEditorPart.cs
- ListViewItem.cs
- EventArgs.cs
- FixedPageProcessor.cs
- ToolboxDataAttribute.cs
- TimeoutHelper.cs
- TransportContext.cs
- FixedSOMPage.cs
- IpcServerChannel.cs
- BrowserDefinitionCollection.cs
- ListBox.cs
- AutomationEvent.cs
- TableRowCollection.cs
- dtdvalidator.cs
- RelatedCurrencyManager.cs
- PathFigureCollection.cs
- SafeMarshalContext.cs
- TextBox.cs
- ErrorWebPart.cs
- Mouse.cs
- RegistryConfigurationProvider.cs
- Lease.cs
- RSAProtectedConfigurationProvider.cs
- DataPagerField.cs
- ChameleonKey.cs
- DrawingServices.cs
- AnyAllSearchOperator.cs
- DataGridItemAutomationPeer.cs
- Image.cs
- QuotedPrintableStream.cs
- EpmSyndicationContentSerializer.cs
- HttpCookieCollection.cs
- TemplateInstanceAttribute.cs
- HashCodeCombiner.cs
- PointConverter.cs
- PathFigure.cs
- ChineseLunisolarCalendar.cs
- UnsafeNativeMethods.cs
- Int32Rect.cs
- ContextProperty.cs
- BasePropertyDescriptor.cs
- ICollection.cs
- ChangeNode.cs
- DataKeyCollection.cs
- BamlMapTable.cs
- LabelEditEvent.cs
- JournalEntryStack.cs
- DragEvent.cs
- XmlNavigatorStack.cs
- RepeaterCommandEventArgs.cs
- InfoCardRSAOAEPKeyExchangeFormatter.cs
- DataStreamFromComStream.cs
- ConstructorBuilder.cs
- SamlAction.cs
- WebPartTracker.cs
- PolicyException.cs
- DoubleCollectionConverter.cs
- Pair.cs
- WorkflowServiceBehavior.cs
- DataPagerFieldCommandEventArgs.cs
- DataSourceUtil.cs
- FontWeights.cs
- ComponentCommands.cs
- CompositionTarget.cs
- WebPartCatalogCloseVerb.cs
- HtmlImage.cs
- SqlClientMetaDataCollectionNames.cs
- CatalogPart.cs
- ProjectionCamera.cs
- BlockUIContainer.cs
- AssociationSetEnd.cs