Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Services / Messaging / System / Messaging / Design / MessageQueueConverter.cs / 1305376 / MessageQueueConverter.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Messaging.Design { using System.Messaging; using System.Threading; using System.ComponentModel; using System.ComponentModel.Design; using System.Diagnostics; using System; using System.Drawing; using System.Windows.Forms; using System.Windows.Forms.Design; using System.Windows.Forms.ComponentModel; using System.ComponentModel.Design.Serialization; using System.Reflection; using System.Messaging.Interop; using System.Collections; using System.Collections.Specialized; using System.Globalization; ////// internal class MessageQueueConverter : TypeConverter { private static Hashtable componentsCreated = new Hashtable(StringComparer.InvariantCultureIgnoreCase); /// /// public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { if (sourceType == typeof(string)) { return true; } return base.CanConvertFrom(context, sourceType); } internal static void AddToCache(MessageQueue queue) { componentsCreated[queue.Path] = queue; } /// /// public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { if (value != null && value is string) { string text = ((string)value).Trim(); if (text == String.Empty) return null; if (text.CompareTo(Res.GetString(Res.NotSet)) != 0) { MessageQueue newQueue = GetFromCache(text); if (newQueue != null) return newQueue; else { newQueue = new MessageQueue(text); AddToCache(newQueue); if (context != null) context.Container.Add(newQueue); return newQueue; } } } return null; } /// /// public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (destinationType != null && destinationType == typeof(string)) { if (value != null) return((MessageQueue)value).Path; else return Res.GetString(Res.NotSet); } return base.ConvertTo(context, culture, value, destinationType); } internal static MessageQueue GetFromCache(string path) { if (componentsCreated.ContainsKey(path)) { MessageQueue existingComponent = (MessageQueue)componentsCreated[path]; if (existingComponent.Site == null) componentsCreated.Remove(path); else { if (existingComponent.Path == path) return existingComponent; else componentsCreated.Remove(path); } } return null; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ // // Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Messaging.Design { using System.Messaging; using System.Threading; using System.ComponentModel; using System.ComponentModel.Design; using System.Diagnostics; using System; using System.Drawing; using System.Windows.Forms; using System.Windows.Forms.Design; using System.Windows.Forms.ComponentModel; using System.ComponentModel.Design.Serialization; using System.Reflection; using System.Messaging.Interop; using System.Collections; using System.Collections.Specialized; using System.Globalization; ////// internal class MessageQueueConverter : TypeConverter { private static Hashtable componentsCreated = new Hashtable(StringComparer.InvariantCultureIgnoreCase); /// /// public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { if (sourceType == typeof(string)) { return true; } return base.CanConvertFrom(context, sourceType); } internal static void AddToCache(MessageQueue queue) { componentsCreated[queue.Path] = queue; } /// /// public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { if (value != null && value is string) { string text = ((string)value).Trim(); if (text == String.Empty) return null; if (text.CompareTo(Res.GetString(Res.NotSet)) != 0) { MessageQueue newQueue = GetFromCache(text); if (newQueue != null) return newQueue; else { newQueue = new MessageQueue(text); AddToCache(newQueue); if (context != null) context.Container.Add(newQueue); return newQueue; } } } return null; } /// /// public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (destinationType != null && destinationType == typeof(string)) { if (value != null) return((MessageQueue)value).Path; else return Res.GetString(Res.NotSet); } return base.ConvertTo(context, culture, value, destinationType); } internal static MessageQueue GetFromCache(string path) { if (componentsCreated.ContainsKey(path)) { MessageQueue existingComponent = (MessageQueue)componentsCreated[path]; if (existingComponent.Site == null) componentsCreated.Remove(path); else { if (existingComponent.Path == path) return existingComponent; else componentsCreated.Remove(path); } } return null; } } } // 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
- CharEntityEncoderFallback.cs
- DESCryptoServiceProvider.cs
- DoubleIndependentAnimationStorage.cs
- Int64.cs
- DataGridViewComboBoxEditingControl.cs
- TemplateInstanceAttribute.cs
- TypeResolver.cs
- LambdaCompiler.Binary.cs
- SubstitutionDesigner.cs
- RouteItem.cs
- TextBoxBase.cs
- ExtendedPropertyCollection.cs
- Models.cs
- LayoutExceptionEventArgs.cs
- TableStyle.cs
- PolicyVersion.cs
- SQLInt16.cs
- X500Name.cs
- SchemaMerger.cs
- AdornerHitTestResult.cs
- EventDescriptorCollection.cs
- HttpStreamMessageEncoderFactory.cs
- RequiredAttributeAttribute.cs
- FieldBuilder.cs
- GradientBrush.cs
- HttpDictionary.cs
- OracleCommandBuilder.cs
- ResourcePool.cs
- CorrelationManager.cs
- AppLevelCompilationSectionCache.cs
- EpmSourcePathSegment.cs
- InkCanvasInnerCanvas.cs
- ReadOnlyHierarchicalDataSource.cs
- Psha1DerivedKeyGenerator.cs
- EntityContainerAssociationSetEnd.cs
- DocumentationServerProtocol.cs
- ObjectStorage.cs
- WizardForm.cs
- Bidi.cs
- DetailsViewAutoFormat.cs
- ADRoleFactoryConfiguration.cs
- ObjectDisposedException.cs
- DynamicMethod.cs
- SecurityMode.cs
- QueryOutputWriter.cs
- ResourceReferenceExpressionConverter.cs
- StopStoryboard.cs
- SQLInt64Storage.cs
- HatchBrush.cs
- TaskSchedulerException.cs
- EntityDataSourceColumn.cs
- PeerCollaboration.cs
- TrackPointCollection.cs
- PageAdapter.cs
- InternalConfigEventArgs.cs
- WebBrowserBase.cs
- FtpCachePolicyElement.cs
- ObjectDataSourceChooseMethodsPanel.cs
- NamespaceEmitter.cs
- ExpressionBuilderContext.cs
- EntityDesignerBuildProvider.cs
- ActivityBindForm.cs
- TextEditorContextMenu.cs
- LineServicesCallbacks.cs
- StrokeNodeData.cs
- ConvertersCollection.cs
- _ProxyRegBlob.cs
- NotSupportedException.cs
- XmlMapping.cs
- WorkflowServiceNamespace.cs
- DecimalConstantAttribute.cs
- SimpleLine.cs
- GeneratedCodeAttribute.cs
- ApplicationFileCodeDomTreeGenerator.cs
- SAPIEngineTypes.cs
- HexParser.cs
- TextEvent.cs
- WSTrustFeb2005.cs
- WebPartDisplayModeEventArgs.cs
- TextChangedEventArgs.cs
- BamlResourceDeserializer.cs
- InfoCardTrace.cs
- ClientSettingsStore.cs
- EntityTypeEmitter.cs
- RewritingProcessor.cs
- ContainsRowNumberChecker.cs
- HttpHandlerAction.cs
- ObjectViewEntityCollectionData.cs
- ExpressionEditorAttribute.cs
- BitVector32.cs
- HostingEnvironmentSection.cs
- DocumentApplication.cs
- XmlSchemaCompilationSettings.cs
- TextBlock.cs
- DomainConstraint.cs
- EditorZoneBase.cs
- BulletChrome.cs
- Speller.cs
- XmlNamedNodeMap.cs
- DefaultProxySection.cs