Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / Tools / System.Activities.Presentation / System / Activities / Presentation / Base / Core / Internal / Metadata / AttributeData.cs / 1305376 / AttributeData.cs
//---------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. //--------------------------------------------------------------- namespace System.Activities.Presentation.Internal.Metadata { using System; using System.Collections.Generic; using System.Text; using System.Diagnostics; using System.Runtime; // This class groups Attribute with its AttributeUsageAttributes that we care about. // Basically, each Attribute has characteristics that are useful to know about, // such as whether it can be inherited and whether there can be more than // one instance of that attribute extending whatever it is the attribute // is extending (class, method, property, or event). Those characteristics // are stored as attributes themselves and, as such, are costly to retrieve. // This class retrieves that information exactly once, on demand, and caches it for // further use. internal class AttributeData { private Type _attributeType; private bool? _isInheritable; private bool? _allowsMultiple; //// Creates an AttributeData wrapper around Attribute type to expose its // Inherit and AllowMultiple characteristics // // Attribute type to wrap around internal AttributeData(Type attributeType) { Fx.Assert(attributeType != null, "attributeType parameter should not be null"); _attributeType = attributeType; } //// Gets the contained attribute type // internal Type AttributeType { get { return _attributeType; } } //// Gets the AllowMultiple characteristic of the // contained attribute and caches the result for subsequent // calls to this property. // internal bool AllowsMultiple { get { if (_allowsMultiple == null) { ParseUsageAttributes(); } return (bool)_allowsMultiple; } } //// Gets the Inherit characteristic of the // contained attribute and caches the result for subsequent // calls to this property. // internal bool IsInheritable { get { if (_isInheritable == null) { ParseUsageAttributes(); } return (bool)_isInheritable; } } private void ParseUsageAttributes() { _isInheritable = false; _allowsMultiple = false; object[] usageAttributes = _attributeType.GetCustomAttributes(typeof(AttributeUsageAttribute), true); if (usageAttributes != null && usageAttributes.Length > 0) { for (int i = 0; i < usageAttributes.Length; i++) { Fx.Assert(usageAttributes[i] is AttributeUsageAttribute, "usageAttributes should be of type AttributeUsageAttribute"); AttributeUsageAttribute usageAttribute = (AttributeUsageAttribute)usageAttributes[i]; _isInheritable = usageAttribute.Inherited; _allowsMultiple = usageAttribute.AllowMultiple; } } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ComponentConverter.cs
- DataBoundControlHelper.cs
- SHA256Managed.cs
- PartialArray.cs
- TextBoxDesigner.cs
- URLEditor.cs
- AsmxEndpointPickerExtension.cs
- Atom10FeedFormatter.cs
- EllipseGeometry.cs
- FrameworkPropertyMetadata.cs
- InvalidCastException.cs
- OdbcEnvironment.cs
- SafeHandles.cs
- WebPartPersonalization.cs
- CustomCategoryAttribute.cs
- ZipIOExtraFieldZip64Element.cs
- SingleConverter.cs
- storagemappingitemcollection.viewdictionary.cs
- StrokeNode.cs
- ModelItemCollection.cs
- StateMachine.cs
- ObjectItemCollectionAssemblyCacheEntry.cs
- WebPartMovingEventArgs.cs
- CounterSet.cs
- KeyboardNavigation.cs
- ContextStaticAttribute.cs
- MemberRestriction.cs
- LongValidatorAttribute.cs
- BaseValidator.cs
- HtmlControlAdapter.cs
- LongMinMaxAggregationOperator.cs
- CompilationUtil.cs
- DoubleAnimationUsingKeyFrames.cs
- CatalogZoneBase.cs
- InternalControlCollection.cs
- SqlDataSourceEnumerator.cs
- BooleanFunctions.cs
- XmlSubtreeReader.cs
- MinMaxParagraphWidth.cs
- InkCanvasSelection.cs
- StrokeFIndices.cs
- XDRSchema.cs
- DiscoveryInnerClientAdhocCD1.cs
- JsonWriterDelegator.cs
- AnnotationObservableCollection.cs
- PackageFilter.cs
- QueryExecutionOption.cs
- WindowsListViewGroupHelper.cs
- SqlTriggerAttribute.cs
- SiteOfOriginContainer.cs
- GeneralTransformGroup.cs
- PropertyCollection.cs
- SmiContext.cs
- SqlDataSourceCache.cs
- EncodingDataItem.cs
- RootBuilder.cs
- Table.cs
- HttpCapabilitiesSectionHandler.cs
- ScrollProperties.cs
- ADRoleFactory.cs
- MdImport.cs
- HttpModuleAction.cs
- NotCondition.cs
- SettingsProperty.cs
- XomlCompiler.cs
- EntryPointNotFoundException.cs
- XmlNodeChangedEventArgs.cs
- InternalsVisibleToAttribute.cs
- ExpressionEvaluator.cs
- RelationshipType.cs
- MarshalByValueComponent.cs
- MDIControlStrip.cs
- Stack.cs
- SimpleTextLine.cs
- XmlQueryTypeFactory.cs
- MembershipValidatePasswordEventArgs.cs
- _ContextAwareResult.cs
- GregorianCalendar.cs
- CharacterShapingProperties.cs
- MediaElementAutomationPeer.cs
- HttpFormatExtensions.cs
- DbConnectionClosed.cs
- InvalidContentTypeException.cs
- NavigationPropertyAccessor.cs
- NonParentingControl.cs
- RenderData.cs
- ToolBarTray.cs
- EmissiveMaterial.cs
- ThemeableAttribute.cs
- ValueType.cs
- RegexBoyerMoore.cs
- XmlHierarchicalDataSourceView.cs
- XmlExpressionDumper.cs
- ColorTranslator.cs
- TemplateXamlTreeBuilder.cs
- FillErrorEventArgs.cs
- QueueNameHelper.cs
- AdvancedBindingEditor.cs
- DataGridItemCollection.cs
- ImageFormatConverter.cs