Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / WinForms / Managed / System / WinForms / ComponentModel / COM2Interop / COM2IDispatchConverter.cs / 1 / COM2IDispatchConverter.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Windows.Forms.ComponentModel.Com2Interop { using System.Diagnostics; using System; using System.ComponentModel; using System.Collections; using Microsoft.Win32; using System.Globalization; internal class Com2IDispatchConverter : Com2ExtendedTypeConverter{ Com2PropertyDescriptor propDesc; ////// /// What we return textually for null. /// protected static readonly string none = SR.GetString(SR.toStringNone); private bool allowExpand; public Com2IDispatchConverter(Com2PropertyDescriptor propDesc, bool allowExpand, TypeConverter baseConverter) : base(baseConverter){ this.propDesc = propDesc; this.allowExpand = allowExpand; } public Com2IDispatchConverter(Com2PropertyDescriptor propDesc, bool allowExpand) : base(propDesc.PropertyType){ this.propDesc = propDesc; this.allowExpand = allowExpand; } ////// /// Determines if this converter can convert an object in the given source /// type to the native type of the converter. /// public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { return false; } ////// /// Determines if this converter can convert an object to the given destination /// type. /// public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) { return destinationType == typeof(string); } ////// /// Converts the given object to another type. The most common types to convert /// are to and from a string object. The default implementation will make a call /// to ToString on the object if the object is valid and if the destination /// type is string. If this cannot convert to the desitnation type, this will /// throw a NotSupportedException. /// public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(string)){ if (value == null){ return none; } string text = ComNativeDescriptor.Instance.GetName(value); if (text == null || text.Length == 0){ text = ComNativeDescriptor.Instance.GetClassName(value); } if (text == null){ return "(Object)"; } return text; } return base.ConvertTo(context, culture, value, destinationType); } public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) { return TypeDescriptor.GetProperties(value, attributes); } ////// /// Determines if this object supports properties. By default, this /// is false. /// public override bool GetPropertiesSupported(ITypeDescriptorContext context) { return this.allowExpand; } // no dropdown, please! // public override bool GetStandardValuesSupported(ITypeDescriptorContext context) { return false; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- XmlPropertyBag.cs
- Panel.cs
- HttpCapabilitiesEvaluator.cs
- CompressEmulationStream.cs
- DataGrid.cs
- BamlLocalizableResource.cs
- ContentPresenter.cs
- HttpResponseWrapper.cs
- HttpRuntimeSection.cs
- TextBoxAutoCompleteSourceConverter.cs
- XmlSchemaComplexContent.cs
- MdiWindowListStrip.cs
- ISFTagAndGuidCache.cs
- TextRangeEdit.cs
- rsa.cs
- SqlCacheDependencyDatabase.cs
- ParagraphVisual.cs
- IdentityNotMappedException.cs
- ContainerTracking.cs
- ContentElement.cs
- ModelFactory.cs
- MethodImplAttribute.cs
- TypedTableGenerator.cs
- TypeSystem.cs
- MetafileHeaderEmf.cs
- UriTemplateVariablePathSegment.cs
- HTTPNotFoundHandler.cs
- TextTreeRootTextBlock.cs
- TargetControlTypeAttribute.cs
- DependencyPropertyConverter.cs
- EntityDataSourceContainerNameItem.cs
- XPathParser.cs
- WebBrowserEvent.cs
- MarkupCompilePass2.cs
- PartialCachingControl.cs
- AnimationException.cs
- FunctionImportMapping.cs
- DataGridViewRowHeaderCell.cs
- TextRangeEdit.cs
- CodeAttributeArgument.cs
- TextEditorSpelling.cs
- Native.cs
- MaskedTextBox.cs
- ObjectParameter.cs
- X500Name.cs
- ClickablePoint.cs
- Grant.cs
- ErrorFormatterPage.cs
- ZoneIdentityPermission.cs
- CircleHotSpot.cs
- FrameworkReadOnlyPropertyMetadata.cs
- OdbcRowUpdatingEvent.cs
- XPathDescendantIterator.cs
- MessageRpc.cs
- ListBox.cs
- ScalarType.cs
- XmlDataLoader.cs
- TileModeValidation.cs
- SecurityManager.cs
- ConfigXmlCDataSection.cs
- ColumnMapCopier.cs
- ServerIdentity.cs
- handlecollector.cs
- MembershipAdapter.cs
- WindowsPen.cs
- ColorBuilder.cs
- NavigatorOutput.cs
- SortQuery.cs
- KnownBoxes.cs
- IdnElement.cs
- TemplatingOptionsDialog.cs
- NonVisualControlAttribute.cs
- DbParameterHelper.cs
- AssemblyNameProxy.cs
- XmlSchemaCollection.cs
- XhtmlBasicFormAdapter.cs
- CdpEqualityComparer.cs
- FreezableCollection.cs
- CodeTypeReference.cs
- CompositeActivityCodeGenerator.cs
- Point3D.cs
- PersonalizablePropertyEntry.cs
- ProjectionPlanCompiler.cs
- SerializerDescriptor.cs
- RawContentTypeMapper.cs
- TiffBitmapEncoder.cs
- OleDbEnumerator.cs
- OleDbMetaDataFactory.cs
- SoapAttributeOverrides.cs
- SerializationEventsCache.cs
- ECDiffieHellmanCng.cs
- StringConverter.cs
- ExpandableObjectConverter.cs
- ShaperBuffers.cs
- GenericAuthenticationEventArgs.cs
- SynchronizationFilter.cs
- ComboBox.cs
- EpmCustomContentWriterNodeData.cs
- TextDecoration.cs
- HybridDictionary.cs