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
- EmptyReadOnlyDictionaryInternal.cs
- Binding.cs
- WebPartVerbCollection.cs
- HwndSourceKeyboardInputSite.cs
- MouseButton.cs
- SQLInt64.cs
- RepeaterItemCollection.cs
- SevenBitStream.cs
- DataRecordInfo.cs
- MsmqPoisonMessageException.cs
- TemplatePagerField.cs
- MimeTypePropertyAttribute.cs
- PageSetupDialog.cs
- FrameSecurityDescriptor.cs
- SrgsElementFactoryCompiler.cs
- HttpStaticObjectsCollectionWrapper.cs
- RenderContext.cs
- ProxyManager.cs
- DataSourceXmlElementAttribute.cs
- XmlSchemaComplexContentExtension.cs
- HashStream.cs
- WorkflowApplicationAbortedException.cs
- ClientSideProviderDescription.cs
- ThemeDirectoryCompiler.cs
- IList.cs
- ConcurrentStack.cs
- SmtpAuthenticationManager.cs
- DataContractSerializerOperationBehavior.cs
- EntityRecordInfo.cs
- TableRowCollection.cs
- RoutedPropertyChangedEventArgs.cs
- InternalMappingException.cs
- ProfilePropertySettings.cs
- ProfessionalColors.cs
- AudioDeviceOut.cs
- DelegateBodyWriter.cs
- CodeDirectiveCollection.cs
- SecureConversationDriver.cs
- TemplateBamlTreeBuilder.cs
- Buffer.cs
- TryExpression.cs
- DataBindingExpressionBuilder.cs
- ImageAutomationPeer.cs
- DictionaryContent.cs
- WindowsRebar.cs
- ArrangedElementCollection.cs
- XamlTreeBuilderBamlRecordWriter.cs
- DoubleAnimationUsingKeyFrames.cs
- StackBuilderSink.cs
- SqlInternalConnection.cs
- ObjectDisposedException.cs
- ScrollContentPresenter.cs
- EntityCommandCompilationException.cs
- TrackingServices.cs
- TypeDelegator.cs
- NetMsmqSecurityMode.cs
- SimplePropertyEntry.cs
- PrintPreviewDialog.cs
- DebugView.cs
- FormViewActionList.cs
- SoapExtensionImporter.cs
- TreeNodeMouseHoverEvent.cs
- ParseChildrenAsPropertiesAttribute.cs
- DomNameTable.cs
- ClockGroup.cs
- TemplateControlParser.cs
- ToolStripRenderEventArgs.cs
- ScrollBarAutomationPeer.cs
- WebBrowserPermission.cs
- _ChunkParse.cs
- DynamicResourceExtensionConverter.cs
- Translator.cs
- ProxyWebPart.cs
- ReadOnlyMetadataCollection.cs
- XmlTextReader.cs
- Operator.cs
- HelpInfo.cs
- DeflateEmulationStream.cs
- EntityStoreSchemaGenerator.cs
- SymbolPair.cs
- ScrollEvent.cs
- AlphaSortedEnumConverter.cs
- SizeAnimationClockResource.cs
- ValidationErrorCollection.cs
- DbConnectionPoolIdentity.cs
- EntityReference.cs
- VSWCFServiceContractGenerator.cs
- BinaryWriter.cs
- LayoutTableCell.cs
- LineGeometry.cs
- ZipIOFileItemStream.cs
- Propagator.JoinPropagator.SubstitutingCloneVisitor.cs
- SmtpNtlmAuthenticationModule.cs
- ObjectStateEntryBaseUpdatableDataRecord.cs
- HashMembershipCondition.cs
- EntityDataSourceChangingEventArgs.cs
- CachedPathData.cs
- RoutedPropertyChangedEventArgs.cs
- MembershipSection.cs
- autovalidator.cs