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
- __Filters.cs
- Int32Storage.cs
- FamilyCollection.cs
- FixedSOMLineCollection.cs
- SystemThemeKey.cs
- ProtectedConfiguration.cs
- DataGrid.cs
- HtmlHistory.cs
- ObjectTag.cs
- DocComment.cs
- XmlWrappingWriter.cs
- RoleService.cs
- BackStopAuthenticationModule.cs
- IncrementalReadDecoders.cs
- TextTreeTextBlock.cs
- SiblingIterators.cs
- SqlMethodTransformer.cs
- ExtendedProperty.cs
- UnsafeNativeMethodsTablet.cs
- OpCodes.cs
- EndpointAddress10.cs
- ReadWriteSpinLock.cs
- SimpleLine.cs
- ExtensibleClassFactory.cs
- LinqDataSourceDeleteEventArgs.cs
- TextElementEditingBehaviorAttribute.cs
- MsmqBindingFilter.cs
- Freezable.cs
- SnapshotChangeTrackingStrategy.cs
- ConfigXmlText.cs
- ConfigDefinitionUpdates.cs
- ErrorFormatterPage.cs
- ScrollContentPresenter.cs
- XPathSingletonIterator.cs
- SourceFileBuildProvider.cs
- SaveFileDialog.cs
- ReferenceList.cs
- ResourceProviderFactory.cs
- CodeTryCatchFinallyStatement.cs
- EntityReference.cs
- SessionEndedEventArgs.cs
- CodeArgumentReferenceExpression.cs
- RuntimeConfig.cs
- DatePicker.cs
- SQLDecimal.cs
- DynamicValidatorEventArgs.cs
- MsmqChannelFactoryBase.cs
- DataGridCellsPanel.cs
- Base64Decoder.cs
- CompilationPass2Task.cs
- NullReferenceException.cs
- FormsAuthenticationEventArgs.cs
- SafeNativeMethods.cs
- CacheMemory.cs
- FormsAuthenticationModule.cs
- SecurityTokenRequirement.cs
- TextFormatterImp.cs
- QueryActivatableWorkflowsCommand.cs
- StylusPointProperties.cs
- RowSpanVector.cs
- MutexSecurity.cs
- WebPartDescriptionCollection.cs
- Rijndael.cs
- BufferedGraphicsContext.cs
- WorkflowRuntimeSection.cs
- httpstaticobjectscollection.cs
- ProfileSettings.cs
- ColumnMapVisitor.cs
- DataBoundLiteralControl.cs
- IDispatchConstantAttribute.cs
- TemplateContainer.cs
- CopyEncoder.cs
- PrinterSettings.cs
- DataBindingHandlerAttribute.cs
- ControlCachePolicy.cs
- UserControlParser.cs
- ApplicationSecurityInfo.cs
- ItemsChangedEventArgs.cs
- CodeIdentifiers.cs
- TreeWalkHelper.cs
- Point3DCollection.cs
- UnsafeNativeMethods.cs
- TransactionManagerProxy.cs
- GCHandleCookieTable.cs
- ObjectDataSourceDisposingEventArgs.cs
- HtmlInputReset.cs
- LightweightEntityWrapper.cs
- MappingMetadataHelper.cs
- GridViewEditEventArgs.cs
- GenericPrincipal.cs
- OleDbInfoMessageEvent.cs
- FormViewRow.cs
- FacetDescription.cs
- ActivityDesignerHelper.cs
- TokenBasedSet.cs
- TypeInitializationException.cs
- RowType.cs
- SizeValueSerializer.cs
- WhitespaceRuleReader.cs
- DecimalStorage.cs