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
- MdImport.cs
- ThemeInfoAttribute.cs
- IPipelineRuntime.cs
- TemplateApplicationHelper.cs
- TokenBasedSetEnumerator.cs
- WinEventWrap.cs
- X509Certificate2Collection.cs
- WebServiceClientProxyGenerator.cs
- SHA512.cs
- _RequestCacheProtocol.cs
- SendingRequestEventArgs.cs
- ListBox.cs
- RadioButton.cs
- httpserverutility.cs
- XmlSchemaExporter.cs
- HGlobalSafeHandle.cs
- StubHelpers.cs
- ExtensionSimplifierMarkupObject.cs
- ThemeableAttribute.cs
- XmlIgnoreAttribute.cs
- BaseCollection.cs
- Simplifier.cs
- Rect3D.cs
- BitmapCodecInfoInternal.cs
- RijndaelManagedTransform.cs
- ToolStripStatusLabel.cs
- HttpRuntime.cs
- SHA384.cs
- OracleFactory.cs
- Italic.cs
- GridViewColumnCollection.cs
- BinaryCommonClasses.cs
- ISFClipboardData.cs
- ParallelTimeline.cs
- Attachment.cs
- CodePageUtils.cs
- CodeVariableDeclarationStatement.cs
- BackStopAuthenticationModule.cs
- BindingContext.cs
- HttpCachePolicyElement.cs
- WebPartTracker.cs
- TimelineGroup.cs
- TextSchema.cs
- FormatException.cs
- InstanceNotFoundException.cs
- ThreadExceptionDialog.cs
- FixUp.cs
- Speller.cs
- ToolStripDropDownMenu.cs
- GroupBox.cs
- AlphabeticalEnumConverter.cs
- ItemAutomationPeer.cs
- Types.cs
- SymbolType.cs
- DataGridViewCell.cs
- GuidConverter.cs
- OdbcTransaction.cs
- ImageButton.cs
- Pen.cs
- EffectiveValueEntry.cs
- SqlRowUpdatedEvent.cs
- XmlQualifiedName.cs
- TogglePattern.cs
- RowsCopiedEventArgs.cs
- Table.cs
- DiagnosticsConfiguration.cs
- ListViewDesigner.cs
- Operator.cs
- QueryModel.cs
- DPTypeDescriptorContext.cs
- XsltQilFactory.cs
- COM2IDispatchConverter.cs
- UrlRoutingHandler.cs
- XamlReaderHelper.cs
- ColorContextHelper.cs
- ProvidePropertyAttribute.cs
- SubclassTypeValidatorAttribute.cs
- TypeInformation.cs
- UrlAuthFailureHandler.cs
- NamespaceMapping.cs
- MailHeaderInfo.cs
- DataGridViewCellValidatingEventArgs.cs
- GrammarBuilderRuleRef.cs
- HttpRuntime.cs
- oledbmetadatacollectionnames.cs
- SettingsPropertyValueCollection.cs
- CodeLinePragma.cs
- _AcceptOverlappedAsyncResult.cs
- Configuration.cs
- PointHitTestResult.cs
- Formatter.cs
- MergeFilterQuery.cs
- PageFunction.cs
- DataGridViewRowConverter.cs
- FormViewUpdateEventArgs.cs
- PropertyKey.cs
- CaretElement.cs
- GridViewPageEventArgs.cs
- CancellationTokenRegistration.cs
- TagElement.cs