Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / Tools / System.Activities.Presentation / System / Activities / Presentation / Model / XamlUtilities.cs / 1305376 / XamlUtilities.cs
//---------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. //--------------------------------------------------------------- namespace System.Activities.Presentation.Model { using System; using System.Collections; using System.ComponentModel; using System.Reflection; internal static class XamlUtilities { static Hashtable converterCache; static object converterCacheSyncObject = new object(); public static TypeConverter GetConverter(Type itemType) { TypeConverter converter = TypeDescriptor.GetConverter(itemType); if (converter == null || converter.GetType() == typeof(TypeConverter)) { // We got an invalid converter. WPF will do this if the converter // is internal, but we use internal converters all over the place // at design time. Detect this and build the converter ourselves. if (converterCache != null) { converter = (TypeConverter)converterCache[itemType]; if (converter != null) { return converter; } } AttributeCollection attrs = TypeDescriptor.GetAttributes(itemType); TypeConverterAttribute tca = attrs[typeof(TypeConverterAttribute)] as TypeConverterAttribute; if (tca != null && tca.ConverterTypeName != null) { Type type = Type.GetType(tca.ConverterTypeName); if (type != null && !type.IsPublic && typeof(TypeConverter).IsAssignableFrom(type)) { ConstructorInfo ctor = type.GetConstructor(new Type[] { typeof(Type) }); if (ctor != null) { converter = (TypeConverter)ctor.Invoke(new object[] { itemType }); } else { converter = (TypeConverter)Activator.CreateInstance(type); } lock (converterCacheSyncObject) { if (converterCache == null) { converterCache = new Hashtable(); // Listen to type changes and clear the cache. // This allows new metadata tables to be installed TypeDescriptor.Refreshed += delegate(RefreshEventArgs args) { converterCache.Remove(args.TypeChanged); }; } converterCache[itemType] = converter; } } } } return converter; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //---------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. //--------------------------------------------------------------- namespace System.Activities.Presentation.Model { using System; using System.Collections; using System.ComponentModel; using System.Reflection; internal static class XamlUtilities { static Hashtable converterCache; static object converterCacheSyncObject = new object(); public static TypeConverter GetConverter(Type itemType) { TypeConverter converter = TypeDescriptor.GetConverter(itemType); if (converter == null || converter.GetType() == typeof(TypeConverter)) { // We got an invalid converter. WPF will do this if the converter // is internal, but we use internal converters all over the place // at design time. Detect this and build the converter ourselves. if (converterCache != null) { converter = (TypeConverter)converterCache[itemType]; if (converter != null) { return converter; } } AttributeCollection attrs = TypeDescriptor.GetAttributes(itemType); TypeConverterAttribute tca = attrs[typeof(TypeConverterAttribute)] as TypeConverterAttribute; if (tca != null && tca.ConverterTypeName != null) { Type type = Type.GetType(tca.ConverterTypeName); if (type != null && !type.IsPublic && typeof(TypeConverter).IsAssignableFrom(type)) { ConstructorInfo ctor = type.GetConstructor(new Type[] { typeof(Type) }); if (ctor != null) { converter = (TypeConverter)ctor.Invoke(new object[] { itemType }); } else { converter = (TypeConverter)Activator.CreateInstance(type); } lock (converterCacheSyncObject) { if (converterCache == null) { converterCache = new Hashtable(); // Listen to type changes and clear the cache. // This allows new metadata tables to be installed TypeDescriptor.Refreshed += delegate(RefreshEventArgs args) { converterCache.Remove(args.TypeChanged); }; } converterCache[itemType] = converter; } } } } return converter; } } } // 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
- ResXResourceWriter.cs
- PolicyImporterElement.cs
- __TransparentProxy.cs
- __Error.cs
- XmlNavigatorStack.cs
- BindingSource.cs
- XmlTextEncoder.cs
- GuidTagList.cs
- Vector3DIndependentAnimationStorage.cs
- AdRotator.cs
- PtsContext.cs
- ServicePointManager.cs
- AvTrace.cs
- SqlCommandBuilder.cs
- CommandEventArgs.cs
- MulticastDelegate.cs
- IisNotInstalledException.cs
- ReferenceSchema.cs
- EventTrigger.cs
- CannotUnloadAppDomainException.cs
- LayoutInformation.cs
- TextContainer.cs
- WebPartDisplayModeEventArgs.cs
- ColorConverter.cs
- TTSEngineProxy.cs
- StorageModelBuildProvider.cs
- GridItemPatternIdentifiers.cs
- DelegateTypeInfo.cs
- SecurityContextTokenValidationException.cs
- TemplateNameScope.cs
- WmlMobileTextWriter.cs
- DataChangedEventManager.cs
- BaseConfigurationRecord.cs
- TabPanel.cs
- ParenthesizePropertyNameAttribute.cs
- HashCodeCombiner.cs
- TrustManagerMoreInformation.cs
- SingleConverter.cs
- RotateTransform.cs
- CookielessHelper.cs
- WS2007HttpBindingElement.cs
- SqlFacetAttribute.cs
- CollectionViewGroupInternal.cs
- WindowsRichEdit.cs
- ListContractAdapter.cs
- ClipboardData.cs
- PKCS1MaskGenerationMethod.cs
- AnnotationStore.cs
- XmlArrayAttribute.cs
- XmlMembersMapping.cs
- ManualResetEventSlim.cs
- MemoryFailPoint.cs
- SourceExpressionException.cs
- HttpBindingExtension.cs
- SafeProcessHandle.cs
- CollectionBase.cs
- TemplateXamlTreeBuilder.cs
- TransactionContextManager.cs
- securitymgrsite.cs
- NominalTypeEliminator.cs
- TemplateBuilder.cs
- DataTableReaderListener.cs
- FormParameter.cs
- HwndHostAutomationPeer.cs
- ErrorInfoXmlDocument.cs
- HtmlInputSubmit.cs
- Opcode.cs
- HttpBufferlessInputStream.cs
- TextElement.cs
- DataListItem.cs
- ListViewDesigner.cs
- QueryLifecycle.cs
- ApplicationHost.cs
- DbUpdateCommandTree.cs
- TextSelectionHelper.cs
- ServiceControllerDesigner.cs
- SqlConnectionPoolGroupProviderInfo.cs
- MetadataItem_Static.cs
- ProtocolViolationException.cs
- ThreadAttributes.cs
- Selection.cs
- ValidationErrorEventArgs.cs
- XmlSchemaSimpleContentRestriction.cs
- QueuePathDialog.cs
- CompositionAdorner.cs
- Events.cs
- InheritanceContextChangedEventManager.cs
- HWStack.cs
- SerialStream.cs
- DynamicDocumentPaginator.cs
- KeyboardNavigation.cs
- RSAPKCS1SignatureDeformatter.cs
- CodeExpressionStatement.cs
- Transform3D.cs
- ConfigXmlSignificantWhitespace.cs
- DirectoryNotFoundException.cs
- CroppedBitmap.cs
- AssemblyAttributesGoHere.cs
- OAVariantLib.cs
- Brush.cs