Code:
/ 4.0 / 4.0 / 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. 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
- ApplyHostConfigurationBehavior.cs
- DataGridViewControlCollection.cs
- GCHandleCookieTable.cs
- HitTestParameters3D.cs
- RawStylusInputCustomData.cs
- DataRow.cs
- FontWeights.cs
- DetailsViewInsertEventArgs.cs
- ExpressionBinding.cs
- CurrencyWrapper.cs
- ToolStripItem.cs
- MouseButtonEventArgs.cs
- SoapExtensionTypeElement.cs
- HebrewNumber.cs
- ListViewDeleteEventArgs.cs
- RelatedCurrencyManager.cs
- DynamicQueryableWrapper.cs
- DecoderFallbackWithFailureFlag.cs
- ExtendedPropertyDescriptor.cs
- VideoDrawing.cs
- OleDbConnectionFactory.cs
- ValuePattern.cs
- InvalidProgramException.cs
- ApplyImportsAction.cs
- FloaterParaClient.cs
- PeerIPHelper.cs
- PtsHost.cs
- RequestQueryParser.cs
- SqlCommand.cs
- Point4D.cs
- OleCmdHelper.cs
- DataGridItemEventArgs.cs
- ItemDragEvent.cs
- FileSecurity.cs
- UITypeEditor.cs
- PocoPropertyAccessorStrategy.cs
- SqlPersonalizationProvider.cs
- PageParserFilter.cs
- HierarchicalDataBoundControl.cs
- RowUpdatingEventArgs.cs
- QuaternionAnimation.cs
- StateItem.cs
- TextTreeTextNode.cs
- CompatibleComparer.cs
- TextTrailingCharacterEllipsis.cs
- MarkupCompilePass2.cs
- TemplateAction.cs
- MarkupCompilePass2.cs
- ObjectTypeMapping.cs
- DataGridViewRowPrePaintEventArgs.cs
- ExtendedPropertyDescriptor.cs
- LinqDataSourceInsertEventArgs.cs
- dbenumerator.cs
- Axis.cs
- WebPartEventArgs.cs
- PropertyValueUIItem.cs
- RunClient.cs
- FontDialog.cs
- ScrollViewerAutomationPeer.cs
- MetaModel.cs
- ExpressionEditorAttribute.cs
- PeerChannelListener.cs
- VerificationException.cs
- OpCopier.cs
- GeneralTransform2DTo3DTo2D.cs
- precedingsibling.cs
- ObjectQueryProvider.cs
- UnmanagedBitmapWrapper.cs
- ManagementObjectSearcher.cs
- NativeMethods.cs
- rsa.cs
- SByte.cs
- UserMapPath.cs
- ReadOnlyPermissionSet.cs
- PropertyGeneratedEventArgs.cs
- LookupBindingPropertiesAttribute.cs
- AdapterUtil.cs
- ResourceDictionaryCollection.cs
- DelayDesigner.cs
- StackSpiller.Bindings.cs
- Evidence.cs
- PrimitiveSchema.cs
- autovalidator.cs
- DataControlCommands.cs
- EventMap.cs
- XmlSerializerOperationGenerator.cs
- DataComponentGenerator.cs
- HtmlInputText.cs
- DataGridViewRowPostPaintEventArgs.cs
- DrawingAttributesDefaultValueFactory.cs
- Model3DGroup.cs
- IconBitmapDecoder.cs
- TitleStyle.cs
- QuarticEase.cs
- DateTimePicker.cs
- ClickablePoint.cs
- OdbcException.cs
- contentDescriptor.cs
- WriteableBitmap.cs
- JpegBitmapDecoder.cs