Code:
/ DotNET / DotNET / 8.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
- DocumentCollection.cs
- ReflectEventDescriptor.cs
- WithStatement.cs
- SiteMapDataSourceDesigner.cs
- CharAnimationBase.cs
- ParameterCollectionEditorForm.cs
- DataServiceQueryException.cs
- RunWorkerCompletedEventArgs.cs
- _AutoWebProxyScriptWrapper.cs
- Contracts.cs
- BaseDataBoundControlDesigner.cs
- OperationInvokerTrace.cs
- DataServiceExpressionVisitor.cs
- clipboard.cs
- coordinatorscratchpad.cs
- ExpressionBuilderCollection.cs
- cache.cs
- ApplyHostConfigurationBehavior.cs
- SqlUtil.cs
- AggregatePushdown.cs
- latinshape.cs
- WindowsScrollBar.cs
- NonBatchDirectoryCompiler.cs
- Helpers.cs
- TextBoxBase.cs
- SqlCommandBuilder.cs
- XPathAxisIterator.cs
- ControlTemplate.cs
- DocumentScope.cs
- WindowsIPAddress.cs
- WorkflowPageSetupDialog.cs
- JulianCalendar.cs
- ClientOperationFormatterProvider.cs
- CodeParameterDeclarationExpression.cs
- SystemColorTracker.cs
- WizardStepBase.cs
- Faults.cs
- RectAnimation.cs
- BamlVersionHeader.cs
- DataTableExtensions.cs
- CodeSnippetExpression.cs
- StrokeNodeData.cs
- DbDataRecord.cs
- EntityTypeEmitter.cs
- ElementAction.cs
- NativeMethodsCLR.cs
- DefaultTextStoreTextComposition.cs
- OdbcParameter.cs
- XamlLoadErrorInfo.cs
- MappingItemCollection.cs
- SQLUtility.cs
- LinkDesigner.cs
- UnsafeNativeMethods.cs
- ProfileSettings.cs
- ListControlBoundActionList.cs
- Empty.cs
- PresentationAppDomainManager.cs
- RelationshipEnd.cs
- COM2Enum.cs
- TimeoutException.cs
- PauseStoryboard.cs
- ExtensionFile.cs
- FrameworkObject.cs
- RuleSettingsCollection.cs
- FrameAutomationPeer.cs
- TreeViewImageKeyConverter.cs
- TemplateControlCodeDomTreeGenerator.cs
- SecurityContextSecurityTokenParameters.cs
- XmlSchemaComplexType.cs
- CellIdBoolean.cs
- DesignerActionPanel.cs
- HtmlHistory.cs
- TextSelection.cs
- ReachFixedDocumentSerializer.cs
- ObjectQuery.cs
- SocketStream.cs
- PathFigureCollection.cs
- PlanCompilerUtil.cs
- UICuesEvent.cs
- AssociationSetEnd.cs
- ExternalException.cs
- _NetRes.cs
- BoundColumn.cs
- XmlCustomFormatter.cs
- ListControl.cs
- URLMembershipCondition.cs
- CombinedGeometry.cs
- TypedReference.cs
- CustomAttributeSerializer.cs
- path.cs
- NativeMethods.cs
- ObjectDataSource.cs
- AssemblyNameProxy.cs
- TaskScheduler.cs
- KeySpline.cs
- RequestTimeoutManager.cs
- XslVisitor.cs
- AsyncDataRequest.cs
- HostedElements.cs
- _StreamFramer.cs