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
- SystemThemeKey.cs
- SoapHeaders.cs
- GridEntry.cs
- MessageBox.cs
- Queue.cs
- DataAccessException.cs
- AspCompat.cs
- MemberInfoSerializationHolder.cs
- SchemaCollectionCompiler.cs
- Random.cs
- XmlObjectSerializerReadContextComplexJson.cs
- UnicodeEncoding.cs
- FormsAuthenticationConfiguration.cs
- SoapExtensionTypeElementCollection.cs
- InvalidCastException.cs
- ActivityDesignerHighlighter.cs
- HttpResponseInternalWrapper.cs
- KeyValueConfigurationCollection.cs
- DbConnectionHelper.cs
- ContextProperty.cs
- TabItem.cs
- ReferenceConverter.cs
- WebDescriptionAttribute.cs
- Subtree.cs
- TypeDescriptionProvider.cs
- ConnectorMovedEventArgs.cs
- RectAnimationBase.cs
- WebPartChrome.cs
- FunctionQuery.cs
- AvTraceFormat.cs
- SqlMethodCallConverter.cs
- DataSourceGroupCollection.cs
- FilteredSchemaElementLookUpTable.cs
- TableItemStyle.cs
- ClientSettings.cs
- RegexStringValidator.cs
- SafeEventLogWriteHandle.cs
- StrongNameKeyPair.cs
- TreeIterators.cs
- PartDesigner.cs
- Style.cs
- ObjectAnimationBase.cs
- GroupDescription.cs
- DataControlFieldHeaderCell.cs
- SelectedDatesCollection.cs
- ByteConverter.cs
- FloaterBaseParaClient.cs
- MergeLocalizationDirectives.cs
- PageThemeCodeDomTreeGenerator.cs
- ProjectedSlot.cs
- SqlCacheDependencyDatabaseCollection.cs
- TableRow.cs
- LinkedResource.cs
- RawKeyboardInputReport.cs
- BamlResourceContent.cs
- CursorConverter.cs
- RoleService.cs
- AddInAttribute.cs
- SoapHelper.cs
- DispatcherHookEventArgs.cs
- DataBindingHandlerAttribute.cs
- RefExpr.cs
- HwndKeyboardInputProvider.cs
- SqlBulkCopyColumnMapping.cs
- Attributes.cs
- X509SecurityTokenProvider.cs
- HierarchicalDataBoundControlAdapter.cs
- PointValueSerializer.cs
- ItemAutomationPeer.cs
- ImageBrush.cs
- PartialArray.cs
- ObjectQueryState.cs
- AvTrace.cs
- SymmetricAlgorithm.cs
- HwndHostAutomationPeer.cs
- ButtonChrome.cs
- TextInfo.cs
- InfoCardSymmetricAlgorithm.cs
- BmpBitmapEncoder.cs
- UriTemplateTrieLocation.cs
- WSHttpBinding.cs
- KeyInterop.cs
- XsltCompileContext.cs
- CoTaskMemHandle.cs
- CommandLibraryHelper.cs
- RestHandlerFactory.cs
- StrongNameUtility.cs
- ResponseStream.cs
- FontInfo.cs
- ProviderBase.cs
- XmlSchemaAll.cs
- HtmlDocument.cs
- AutoScrollHelper.cs
- BufferedStream.cs
- sqlnorm.cs
- Literal.cs
- PeerApplication.cs
- DynamicILGenerator.cs
- Vector3D.cs
- UncommonField.cs