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
- Version.cs
- VirtualDirectoryMappingCollection.cs
- WpfKnownType.cs
- KeyNameIdentifierClause.cs
- BitConverter.cs
- ToolStripDesignerUtils.cs
- PrePrepareMethodAttribute.cs
- CriticalFinalizerObject.cs
- DiagnosticsConfiguration.cs
- ExpressionBinding.cs
- DataControlImageButton.cs
- XPathAncestorIterator.cs
- ContainerUtilities.cs
- GraphicsPath.cs
- SolidBrush.cs
- Model3D.cs
- ViewValidator.cs
- KeyGestureConverter.cs
- SerialPinChanges.cs
- WasNotInstalledException.cs
- DataGrid.cs
- DataControlFieldHeaderCell.cs
- XXXOnTypeBuilderInstantiation.cs
- ListenerConnectionDemuxer.cs
- Label.cs
- TemplateContent.cs
- QilValidationVisitor.cs
- WorkflowLayouts.cs
- ItemContainerProviderWrapper.cs
- DeploymentSection.cs
- WebPartConnectionsCancelVerb.cs
- GuidelineSet.cs
- ActivityTypeDesigner.xaml.cs
- SortKey.cs
- XmlNavigatorFilter.cs
- Page.cs
- NumericUpDown.cs
- ValidatingReaderNodeData.cs
- LogicalExpr.cs
- FormatException.cs
- StylusPointProperty.cs
- SqlSelectStatement.cs
- Configuration.cs
- UnaryNode.cs
- AdapterDictionary.cs
- RequestValidator.cs
- OleDbReferenceCollection.cs
- AutoResetEvent.cs
- DependencyPropertyKind.cs
- AssemblyHash.cs
- WhitespaceRuleReader.cs
- BinaryQueryOperator.cs
- DefaultHttpHandler.cs
- wgx_sdk_version.cs
- Roles.cs
- WebPartConnectionsCancelEventArgs.cs
- SocketException.cs
- DispatcherProcessingDisabled.cs
- DbDataSourceEnumerator.cs
- AssemblyAssociatedContentFileAttribute.cs
- Int16AnimationBase.cs
- NetDataContractSerializer.cs
- GlobalDataBindingHandler.cs
- ContainerSelectorGlyph.cs
- UrlPropertyAttribute.cs
- __Error.cs
- EncryptedKey.cs
- SqlClientWrapperSmiStreamChars.cs
- GridViewRow.cs
- DataControlFieldCollection.cs
- RefType.cs
- BamlVersionHeader.cs
- GifBitmapDecoder.cs
- DrawingContextWalker.cs
- TemplateXamlParser.cs
- Trace.cs
- ExternalException.cs
- ContentPropertyAttribute.cs
- ConfigurationManagerHelperFactory.cs
- RightsManagementEncryptionTransform.cs
- QEncodedStream.cs
- DependencyPropertyConverter.cs
- CodeRemoveEventStatement.cs
- SqlErrorCollection.cs
- DiscreteKeyFrames.cs
- TextDecorations.cs
- XamlBrushSerializer.cs
- TextBoxDesigner.cs
- RestClientProxyHandler.cs
- ContextQuery.cs
- SecurityProtocol.cs
- SelectionRange.cs
- Brush.cs
- HashHelpers.cs
- PackageRelationshipCollection.cs
- VersionedStream.cs
- ControlValuePropertyAttribute.cs
- DeflateEmulationStream.cs
- ResourceExpressionEditorSheet.cs
- OpCodes.cs