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
- LineBreakRecord.cs
- MaterializeFromAtom.cs
- InvalidFilterCriteriaException.cs
- StaticExtensionConverter.cs
- IntSecurity.cs
- ObfuscationAttribute.cs
- AppDomainGrammarProxy.cs
- IssuedSecurityTokenProvider.cs
- EnumBuilder.cs
- MasterPageParser.cs
- XhtmlBasicLabelAdapter.cs
- KeyInstance.cs
- DiscoveryInnerClientManaged11.cs
- DrawListViewSubItemEventArgs.cs
- DataServiceStreamProviderWrapper.cs
- QilStrConcatenator.cs
- ConsoleTraceListener.cs
- ResolveMatchesApril2005.cs
- EventDescriptorCollection.cs
- ObjectRef.cs
- EventLogTraceListener.cs
- EntityDataSourceView.cs
- DiscardableAttribute.cs
- TrackingProfileDeserializationException.cs
- DbCommandTree.cs
- ImageFormatConverter.cs
- Timeline.cs
- DiagnosticTrace.cs
- MulticastIPAddressInformationCollection.cs
- EntityChangedParams.cs
- TemplateBindingExpression.cs
- NGCSerializationManager.cs
- Input.cs
- ScrollItemProviderWrapper.cs
- TdsParser.cs
- DBSchemaTable.cs
- ValidationResults.cs
- InvalidPrinterException.cs
- HtmlTextViewAdapter.cs
- IpcManager.cs
- ProofTokenCryptoHandle.cs
- IsolatedStorageFileStream.cs
- UntypedNullExpression.cs
- WorkflowTraceTransfer.cs
- ClientFormsAuthenticationCredentials.cs
- OdbcConnectionString.cs
- FormViewInsertedEventArgs.cs
- EntityDataSourceReferenceGroup.cs
- AspNetHostingPermission.cs
- CodeDomSerializationProvider.cs
- TemplateBamlTreeBuilder.cs
- PathSegmentCollection.cs
- COAUTHIDENTITY.cs
- SqlTypeConverter.cs
- PrePrepareMethodAttribute.cs
- IndexedSelectQueryOperator.cs
- LostFocusEventManager.cs
- AssociationTypeEmitter.cs
- TextServicesCompartmentContext.cs
- ResourceDictionary.cs
- HttpNamespaceReservationInstallComponent.cs
- BoolExpression.cs
- ThrowHelper.cs
- LiteralLink.cs
- Scripts.cs
- CopyAction.cs
- WindowsEditBox.cs
- XsltContext.cs
- XmlSchemaAttribute.cs
- TagPrefixCollection.cs
- wgx_commands.cs
- ClientSideProviderDescription.cs
- ListComponentEditor.cs
- CodeGen.cs
- OracleCommand.cs
- IIS7WorkerRequest.cs
- EventSetter.cs
- TreeNodeCollection.cs
- SchemaImporterExtensionElement.cs
- xdrvalidator.cs
- CheckableControlBaseAdapter.cs
- ByteStorage.cs
- WindowsAuthenticationModule.cs
- TextBoxLine.cs
- DropShadowEffect.cs
- VisualBasicSettings.cs
- HttpProcessUtility.cs
- SafePEFileHandle.cs
- FormsIdentity.cs
- ContextMenu.cs
- ZipIOExtraField.cs
- UITypeEditor.cs
- MobileCategoryAttribute.cs
- PathGeometry.cs
- LogEntry.cs
- UnsafeNativeMethods.cs
- LinqDataSourceUpdateEventArgs.cs
- XPathAncestorQuery.cs
- LazyLoadBehavior.cs
- SQLBytes.cs