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
- PerfService.cs
- MenuBase.cs
- ResourcePermissionBase.cs
- TemplateBindingExpressionConverter.cs
- BooleanAnimationBase.cs
- KerberosSecurityTokenAuthenticator.cs
- MimeReflector.cs
- TemplatePartAttribute.cs
- FrameworkElementFactory.cs
- RemoteWebConfigurationHostServer.cs
- AccessedThroughPropertyAttribute.cs
- RoutedUICommand.cs
- HtmlControlPersistable.cs
- PenLineJoinValidation.cs
- GetCryptoTransformRequest.cs
- assertwrapper.cs
- IgnoreSectionHandler.cs
- EllipseGeometry.cs
- ThousandthOfEmRealDoubles.cs
- XamlStyleSerializer.cs
- FormsIdentity.cs
- ToolStripSeparatorRenderEventArgs.cs
- DataGridViewCheckBoxCell.cs
- DbProviderFactoriesConfigurationHandler.cs
- BindingsCollection.cs
- SqlRecordBuffer.cs
- RSAOAEPKeyExchangeDeformatter.cs
- TreeNodeSelectionProcessor.cs
- ProfessionalColors.cs
- X509Utils.cs
- SeverityFilter.cs
- ProcessInfo.cs
- OrCondition.cs
- TreeNode.cs
- WindowsListViewGroupSubsetLink.cs
- TextReader.cs
- lengthconverter.cs
- DataGridDefaultColumnWidthTypeConverter.cs
- SurrogateEncoder.cs
- OperatingSystem.cs
- AssertUtility.cs
- RemotingException.cs
- ImageFormatConverter.cs
- linebase.cs
- StreamResourceInfo.cs
- safesecurityhelperavalon.cs
- XmlnsCache.cs
- Main.cs
- ReachVisualSerializer.cs
- InternalSafeNativeMethods.cs
- ListViewUpdateEventArgs.cs
- ToolStripSplitStackLayout.cs
- HandlerFactoryWrapper.cs
- SqlServices.cs
- EmptyElement.cs
- MetabaseServerConfig.cs
- WebEvents.cs
- NullExtension.cs
- PageThemeParser.cs
- HtmlElement.cs
- DecoratedNameAttribute.cs
- DesignTimeParseData.cs
- CompleteWizardStep.cs
- SafeProcessHandle.cs
- UserNameSecurityToken.cs
- Variable.cs
- GlyphCollection.cs
- DataObjectEventArgs.cs
- StateWorkerRequest.cs
- SafeFileMapViewHandle.cs
- DataSet.cs
- RenderingEventArgs.cs
- AuthenticationModulesSection.cs
- RectangleHotSpot.cs
- ImpersonateTokenRef.cs
- ping.cs
- TemplateParser.cs
- IPEndPointCollection.cs
- WebServiceErrorEvent.cs
- TypeHelper.cs
- SecurityAlgorithmSuite.cs
- LambdaCompiler.cs
- Action.cs
- HandlerBase.cs
- TextElementEnumerator.cs
- DiscreteKeyFrames.cs
- ListBoxChrome.cs
- RegisteredScript.cs
- DesignSurfaceCollection.cs
- SchemaNamespaceManager.cs
- EntityTemplateUserControl.cs
- ReadWriteSpinLock.cs
- RawStylusInputCustomData.cs
- FormatterServices.cs
- DataSourceHelper.cs
- OleDbTransaction.cs
- NativeMethods.cs
- DataControlImageButton.cs
- ApplicationBuildProvider.cs
- EdmItemError.cs