Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / Designer / WinForms / System / WinForms / Design / DesignBindingConverter.cs / 1 / DesignBindingConverter.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Windows.Forms.Design { using System; using System.Design; using System.Collections; using System.ComponentModel; using System.Globalization; ////// /// internal class DesignBindingConverter : TypeConverter { public override bool CanConvertTo(ITypeDescriptorContext context, Type sourceType) { return (typeof(string) == sourceType); } public override bool CanConvertFrom(ITypeDescriptorContext context, Type destType) { return (typeof(string) == destType); } public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type sourceType) { DesignBinding designBinding = (DesignBinding) value; if (designBinding.IsNull) { return SR.GetString(SR.DataGridNoneString); } else { string name = ""; if (designBinding.DataSource is IComponent) { IComponent component = (IComponent) designBinding.DataSource; if (component.Site != null) { name = component.Site.Name; } } if (name.Length == 0) { if (designBinding.DataSource is IListSource || designBinding.DataSource is IList || designBinding.DataSource is Array) { name = "(List)"; } else { string typeName = TypeDescriptor.GetClassName(designBinding.DataSource); int lastDot = typeName.LastIndexOf('.'); if (lastDot != -1) { typeName = typeName.Substring(lastDot + 1); } name = string.Format(CultureInfo.CurrentCulture, "({0})", typeName); } } name += " - " + designBinding.DataMember; return name; } } public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { string text = (string) value; if (text == null || text.Length == 0 || String.Compare(text,SR.GetString(SR.DataGridNoneString),true, CultureInfo.CurrentCulture) == 0) { return DesignBinding.Null; } else { int dash = text.IndexOf("-"); if (dash == -1) { throw new ArgumentException(SR.GetString(SR.DesignBindingBadParseString, text)); } string componentName = text.Substring(0,dash - 1).Trim(); string dataMember = text.Substring(dash + 1).Trim(); if (context == null || context.Container == null) { throw new ArgumentException(SR.GetString(SR.DesignBindingContextRequiredWhenParsing, text)); } IContainer container = DesignerUtils.CheckForNestedContainer(context.Container); // ...necessary to support SplitterPanel components IComponent dataSource = container.Components[componentName]; if (dataSource == null) { if (String.Equals(componentName, "(List)", StringComparison.OrdinalIgnoreCase)) { return null; } throw new ArgumentException(SR.GetString(SR.DesignBindingComponentNotFound, componentName)); } return new DesignBinding(dataSource,dataMember); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved./// Converts data bindings for use in the design-time environment. /// ///
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ReliableReplySessionChannel.cs
- SqlProfileProvider.cs
- XamlBrushSerializer.cs
- ObjectManager.cs
- ColorPalette.cs
- filewebresponse.cs
- SerializationObjectManager.cs
- ResourceLoader.cs
- UrlAuthFailedErrorFormatter.cs
- DebuggerAttributes.cs
- CalendarDataBindingHandler.cs
- Input.cs
- FormatSettings.cs
- WebPartZoneBase.cs
- ContextMenu.cs
- HttpConfigurationSystem.cs
- CFGGrammar.cs
- RC2CryptoServiceProvider.cs
- OutKeywords.cs
- DataGridViewRowsRemovedEventArgs.cs
- StringBlob.cs
- DiffuseMaterial.cs
- MimePart.cs
- DefaultSection.cs
- Profiler.cs
- UpdateTranslator.cs
- SqlMethodCallConverter.cs
- Polygon.cs
- StaticResourceExtension.cs
- StreamReader.cs
- CodeNamespaceCollection.cs
- SetUserPreferenceRequest.cs
- SerialPort.cs
- AppDomainCompilerProxy.cs
- MonitoringDescriptionAttribute.cs
- ToolStripItem.cs
- CommonObjectSecurity.cs
- DependencyPropertyAttribute.cs
- ArrayExtension.cs
- HMACMD5.cs
- SkipStoryboardToFill.cs
- MenuItemStyle.cs
- LassoSelectionBehavior.cs
- NonBatchDirectoryCompiler.cs
- Control.cs
- SqlCommand.cs
- SqlGenericUtil.cs
- ButtonColumn.cs
- TextControlDesigner.cs
- MILUtilities.cs
- PhysicalFontFamily.cs
- WebPartVerb.cs
- ListChangedEventArgs.cs
- RepeatInfo.cs
- PropertyItemInternal.cs
- CompiledQuery.cs
- XmlSchemaProviderAttribute.cs
- PackageFilter.cs
- Wrapper.cs
- ContentPlaceHolder.cs
- ContentPathSegment.cs
- xdrvalidator.cs
- ObservableCollection.cs
- BuildResultCache.cs
- InteropTrackingRecord.cs
- DBBindings.cs
- TrackingProfile.cs
- WebPartUserCapability.cs
- ServiceSecurityContext.cs
- ProfileGroupSettings.cs
- AmbientLight.cs
- IPHostEntry.cs
- UserValidatedEventArgs.cs
- CommandDesigner.cs
- Line.cs
- EntityContainerAssociationSet.cs
- ToolStripDropDownButton.cs
- HandlerFactoryWrapper.cs
- PreviewPrintController.cs
- DefaultBindingPropertyAttribute.cs
- NetSectionGroup.cs
- DataTableMapping.cs
- DataGridViewAdvancedBorderStyle.cs
- OlePropertyStructs.cs
- TemplateKey.cs
- InkCanvasFeedbackAdorner.cs
- XmlSchema.cs
- SourceFileBuildProvider.cs
- Style.cs
- LeaseManager.cs
- UrlPath.cs
- PerspectiveCamera.cs
- path.cs
- XPathArrayIterator.cs
- CodeCommentStatement.cs
- ProcessModelSection.cs
- DataGridDefaultColumnWidthTypeConverter.cs
- securitycriticaldata.cs
- RunWorkerCompletedEventArgs.cs
- TypeCodeDomSerializer.cs