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
- ErrorWebPart.cs
- IgnoreFileBuildProvider.cs
- ProfileSettingsCollection.cs
- AttachedPropertyBrowsableForTypeAttribute.cs
- WindowsButton.cs
- ParameterToken.cs
- ObjectDataSourceFilteringEventArgs.cs
- ProxyWebPartConnectionCollection.cs
- OracleConnectionFactory.cs
- HtmlShimManager.cs
- UserValidatedEventArgs.cs
- ServerType.cs
- BitmapFrameDecode.cs
- IntSecurity.cs
- PlatformCulture.cs
- TextRenderer.cs
- SpeakCompletedEventArgs.cs
- SystemSounds.cs
- TargetParameterCountException.cs
- XPathParser.cs
- EditableTreeList.cs
- ExtendLockCommand.cs
- ArrowControl.xaml.cs
- SslStream.cs
- ProjectionQueryOptionExpression.cs
- AssemblyLoader.cs
- _HeaderInfo.cs
- NavigationPropertyEmitter.cs
- UnsafeNetInfoNativeMethods.cs
- ChtmlPageAdapter.cs
- PartialClassGenerationTaskInternal.cs
- GetCardDetailsRequest.cs
- Exceptions.cs
- StackSpiller.Generated.cs
- ToolStripDropDownItem.cs
- SignatureResourceHelper.cs
- AutoCompleteStringCollection.cs
- ScrollItemProviderWrapper.cs
- StaticContext.cs
- EntityViewContainer.cs
- DBSchemaTable.cs
- Repeater.cs
- DataContractSerializerSection.cs
- OdbcParameter.cs
- ItemsControlAutomationPeer.cs
- SizeAnimationUsingKeyFrames.cs
- TextTreeFixupNode.cs
- ListBindableAttribute.cs
- EntityDataSourceContextCreatedEventArgs.cs
- TextSimpleMarkerProperties.cs
- HostingEnvironmentSection.cs
- ZeroOpNode.cs
- COM2Properties.cs
- ITreeGenerator.cs
- ActivityBuilderHelper.cs
- QueryGeneratorBase.cs
- TargetControlTypeCache.cs
- LineServicesCallbacks.cs
- TraceSection.cs
- ListDictionary.cs
- MDIControlStrip.cs
- AutomationPropertyInfo.cs
- DataGridViewColumnConverter.cs
- DragDeltaEventArgs.cs
- SqlInfoMessageEvent.cs
- BooleanFunctions.cs
- ToolboxItemLoader.cs
- CodeStatement.cs
- FontCacheUtil.cs
- DataReceivedEventArgs.cs
- CounterSetInstanceCounterDataSet.cs
- DataSourceProvider.cs
- TraversalRequest.cs
- EventLogInternal.cs
- ControlBindingsCollection.cs
- FixedDocumentPaginator.cs
- HttpCookiesSection.cs
- XmlSchemaAppInfo.cs
- HtmlElementEventArgs.cs
- PropertyGridEditorPart.cs
- BaseProcessor.cs
- CallbackHandler.cs
- ScopeElement.cs
- StreamWriter.cs
- XmlDataImplementation.cs
- Command.cs
- UpdateException.cs
- unsafenativemethodstextservices.cs
- InfoCardTraceRecord.cs
- XmlSchemaCollection.cs
- querybuilder.cs
- EncoderParameter.cs
- TextTreeObjectNode.cs
- PropertyStore.cs
- AccessibleObject.cs
- ExpressionBuilderContext.cs
- StretchValidation.cs
- TextEditorMouse.cs
- Path.cs
- StylusPlugin.cs