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
- SortFieldComparer.cs
- XsltContext.cs
- externdll.cs
- EmptyStringExpandableObjectConverter.cs
- ActivityBindForm.cs
- SelectionProcessor.cs
- BamlResourceSerializer.cs
- SessionStateSection.cs
- CommonDialog.cs
- Accessible.cs
- SqlCharStream.cs
- TypefaceCollection.cs
- ReflectTypeDescriptionProvider.cs
- ActivityCompletionCallbackWrapper.cs
- SqlVisitor.cs
- TagPrefixInfo.cs
- CompoundFileIOPermission.cs
- FrameSecurityDescriptor.cs
- DataGridViewCellLinkedList.cs
- BoolExpressionVisitors.cs
- BatchParser.cs
- TouchFrameEventArgs.cs
- SQLByteStorage.cs
- UnionCqlBlock.cs
- InputMethod.cs
- RadioButton.cs
- DbXmlEnabledProviderManifest.cs
- SelectionListComponentEditor.cs
- TimeSpanMinutesOrInfiniteConverter.cs
- DataService.cs
- LinkedResource.cs
- ServerIdentity.cs
- SspiSecurityTokenParameters.cs
- DBSqlParser.cs
- MeshGeometry3D.cs
- UserValidatedEventArgs.cs
- DependencyObjectPropertyDescriptor.cs
- ToolBar.cs
- _ProxyRegBlob.cs
- CodeDomDesignerLoader.cs
- TextCharacters.cs
- FormViewPageEventArgs.cs
- CatalogPartCollection.cs
- DataGridViewColumnCollectionDialog.cs
- ChannelEndpointElementCollection.cs
- Brushes.cs
- GridItemCollection.cs
- RegexRunnerFactory.cs
- MdiWindowListStrip.cs
- AudienceUriMode.cs
- SystemInformation.cs
- TypeBuilderInstantiation.cs
- Vector3DAnimation.cs
- XComponentModel.cs
- ListItemConverter.cs
- TextContainerChangeEventArgs.cs
- LessThan.cs
- XmlSchemaAnnotated.cs
- ResourceDisplayNameAttribute.cs
- BrowserInteropHelper.cs
- TextElement.cs
- GroupDescription.cs
- CommandLibraryHelper.cs
- SkinBuilder.cs
- Substitution.cs
- WebPartEventArgs.cs
- Optimizer.cs
- BatchParser.cs
- IUnknownConstantAttribute.cs
- WindowsIdentity.cs
- InheritanceContextChangedEventManager.cs
- AccessorTable.cs
- Stroke.cs
- SiteOfOriginPart.cs
- ProcessModelSection.cs
- RSAPKCS1SignatureFormatter.cs
- ContractSearchPattern.cs
- ProtocolsConfiguration.cs
- CustomErrorCollection.cs
- OdbcErrorCollection.cs
- LeaseManager.cs
- StatusBarItem.cs
- SchemaImporterExtensionElementCollection.cs
- CompilationPass2Task.cs
- RadioButton.cs
- ArgumentException.cs
- DesignerTextWriter.cs
- Registry.cs
- XPathNodePointer.cs
- AutomationProperties.cs
- ToolStripScrollButton.cs
- VideoDrawing.cs
- ComponentResourceManager.cs
- FlowchartStart.xaml.cs
- TextWriter.cs
- EntityDataSourceChangingEventArgs.cs
- FixedDSBuilder.cs
- AuditLog.cs
- FormViewUpdateEventArgs.cs
- InputScopeAttribute.cs