Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / Data / System / Data / ConstraintConverter.cs / 1 / ConstraintConverter.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //[....] //[....] //[....] //----------------------------------------------------------------------------- namespace System.Data { using System; using System.ComponentModel; using System.ComponentModel.Design.Serialization; using System.Globalization; ////// sealed internal class ConstraintConverter : ExpandableObjectConverter { // converter classes should have public ctor public ConstraintConverter() { } ////// public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) { if (destinationType == typeof(InstanceDescriptor)) { return true; } return base.CanConvertTo(context, destinationType); } ///Gets a value indicating whether this converter can /// convert an object to the given destination type using the context. ////// 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 == null) { throw new ArgumentNullException("destinationType"); } if (destinationType == typeof(InstanceDescriptor) && value is Constraint) { if (value is UniqueConstraint) { UniqueConstraint constr = (UniqueConstraint)value; System.Reflection.ConstructorInfo ctor = typeof(UniqueConstraint).GetConstructor(new Type[] { typeof(string), typeof(string[]), typeof(bool) } ); if (ctor != null) return new InstanceDescriptor(ctor, new object[] { constr.ConstraintName, constr.ColumnNames, constr.IsPrimaryKey }); } else { ForeignKeyConstraint constr = (ForeignKeyConstraint)value; System.Reflection.ConstructorInfo ctor = typeof(ForeignKeyConstraint).GetConstructor(new Type[] { typeof(string), typeof(string), typeof(string[]), typeof(string[]), typeof(AcceptRejectRule), typeof(Rule), typeof(Rule) } ); if (ctor != null) return new InstanceDescriptor(ctor, new object[] { constr.ConstraintName, constr.ParentKey.Table.TableName, constr.ParentColumnNames, constr.ChildColumnNames, constr.AcceptRejectRule, constr.DeleteRule, constr.UpdateRule }); } } return base.ConvertTo(context, culture, value, destinationType); } } } // 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
- AsymmetricKeyExchangeDeformatter.cs
- DependencyPropertyConverter.cs
- UIElementParaClient.cs
- ProxyWebPartManager.cs
- MultipleCopiesCollection.cs
- EventPropertyMap.cs
- DbProviderManifest.cs
- DocumentOrderQuery.cs
- WorkflowRuntimeServiceElementCollection.cs
- QueryStringParameter.cs
- WebEventTraceProvider.cs
- Version.cs
- SiteOfOriginPart.cs
- SrgsElementList.cs
- GridViewDeletedEventArgs.cs
- ChangePasswordAutoFormat.cs
- RequestCachingSection.cs
- StopStoryboard.cs
- HMACMD5.cs
- PagesChangedEventArgs.cs
- GB18030Encoding.cs
- LateBoundBitmapDecoder.cs
- ColumnHeaderConverter.cs
- DependencyPropertyAttribute.cs
- Binding.cs
- Misc.cs
- UIElementCollection.cs
- IndexedEnumerable.cs
- InsufficientMemoryException.cs
- WebOperationContext.cs
- DynamicPropertyHolder.cs
- InstancePersistenceCommandException.cs
- ServicePointManagerElement.cs
- GridViewColumnHeaderAutomationPeer.cs
- SQLConvert.cs
- SqlDataSourceConfigureSelectPanel.cs
- WsdlParser.cs
- IconBitmapDecoder.cs
- Executor.cs
- ParserOptions.cs
- PixelShader.cs
- FieldCollectionEditor.cs
- SmtpTransport.cs
- ImageIndexConverter.cs
- XmlElementList.cs
- TextElementCollection.cs
- ReferenceService.cs
- DataGridSortingEventArgs.cs
- UriTemplateClientFormatter.cs
- RadioButtonRenderer.cs
- ThreadExceptionEvent.cs
- SemaphoreSecurity.cs
- EndpointAddressMessageFilter.cs
- Freezable.cs
- QueryValue.cs
- TextEncodedRawTextWriter.cs
- TypeInfo.cs
- ThreadSafeMessageFilterTable.cs
- PartialTrustVisibleAssembly.cs
- XmlSchemaSimpleTypeRestriction.cs
- Page.cs
- GradientStop.cs
- Underline.cs
- RemotingSurrogateSelector.cs
- CookieHandler.cs
- EventDescriptor.cs
- UnsafeNativeMethods.cs
- LayoutInformation.cs
- ConditionalBranch.cs
- ImageIndexEditor.cs
- DataFormat.cs
- SafeRegistryHandle.cs
- MessageDecoder.cs
- FrameAutomationPeer.cs
- PartitionResolver.cs
- DesignerForm.cs
- StructuralCache.cs
- RequestTimeoutManager.cs
- ChineseLunisolarCalendar.cs
- SqlReferenceCollection.cs
- ToolStripSystemRenderer.cs
- BamlResourceDeserializer.cs
- CaseInsensitiveOrdinalStringComparer.cs
- ECDsa.cs
- DataGridViewButtonColumn.cs
- ImageKeyConverter.cs
- TextMessageEncodingBindingElement.cs
- CodeCatchClauseCollection.cs
- ReadOnlyObservableCollection.cs
- XmlElement.cs
- Duration.cs
- DeclaredTypeElement.cs
- TimeSpanMinutesOrInfiniteConverter.cs
- GlobalProxySelection.cs
- DataGridViewTextBoxColumn.cs
- CfgSemanticTag.cs
- TextDocumentView.cs
- AttributeCollection.cs
- XmlSchemaInclude.cs
- TemplateBindingExpressionConverter.cs