Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Data / System / Data / ConstraintConverter.cs / 1305376 / 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- IIS7WorkerRequest.cs
- RawMouseInputReport.cs
- XmlQueryType.cs
- CacheForPrimitiveTypes.cs
- ZipIOFileItemStream.cs
- InputLanguageSource.cs
- ProjectedSlot.cs
- GetWinFXPath.cs
- TypeDescriptionProvider.cs
- XsltArgumentList.cs
- Helpers.cs
- ListViewGroup.cs
- BamlStream.cs
- CodeIdentifier.cs
- WebPartAuthorizationEventArgs.cs
- StopStoryboard.cs
- CollectionConverter.cs
- DatagridviewDisplayedBandsData.cs
- QueryOperationResponseOfT.cs
- OracleCommand.cs
- CodeAttributeDeclarationCollection.cs
- Crc32.cs
- OledbConnectionStringbuilder.cs
- InvalidOleVariantTypeException.cs
- AndCondition.cs
- FlowDocument.cs
- HtmlShim.cs
- RotateTransform.cs
- HttpRuntimeSection.cs
- XmlCollation.cs
- LinqDataSource.cs
- HighlightComponent.cs
- OracleInternalConnection.cs
- Currency.cs
- DataTableClearEvent.cs
- ConnectionPoint.cs
- BigInt.cs
- HatchBrush.cs
- ConfigurationValues.cs
- GradientBrush.cs
- Tile.cs
- XmlBinaryReader.cs
- ProfileInfo.cs
- DataGridViewHitTestInfo.cs
- UnionCodeGroup.cs
- ToolStripPanelRow.cs
- SqlTypesSchemaImporter.cs
- ValueSerializerAttribute.cs
- MessagePartProtectionMode.cs
- UnitySerializationHolder.cs
- EventLogPermission.cs
- ClientTargetCollection.cs
- CorrelationManager.cs
- HostingEnvironmentException.cs
- IntSecurity.cs
- XmlSchemaProviderAttribute.cs
- CaretElement.cs
- TableCell.cs
- GenericEnumConverter.cs
- FolderBrowserDialog.cs
- ConnectionInterfaceCollection.cs
- WindowsListViewItemCheckBox.cs
- ColumnWidthChangingEvent.cs
- SiteMapHierarchicalDataSourceView.cs
- TransformCollection.cs
- OdbcUtils.cs
- Opcode.cs
- unitconverter.cs
- TagPrefixCollection.cs
- Rect3DConverter.cs
- XmlSchemaImporter.cs
- SpellerStatusTable.cs
- SerializableAttribute.cs
- XmlSchemaValidationException.cs
- As.cs
- WindowsAuthenticationEventArgs.cs
- Drawing.cs
- _FtpControlStream.cs
- FixedSOMTextRun.cs
- UnSafeCharBuffer.cs
- SQLBytes.cs
- ActiveDocumentEvent.cs
- AspProxy.cs
- UpdateManifestForBrowserApplication.cs
- DropDownButton.cs
- SQLInt64.cs
- FontEditor.cs
- IntegerValidator.cs
- JavaScriptObjectDeserializer.cs
- EventHandlersStore.cs
- PackagePartCollection.cs
- SmiRequestExecutor.cs
- ScriptingWebServicesSectionGroup.cs
- QilTargetType.cs
- PixelFormats.cs
- CodeSnippetTypeMember.cs
- XmlSerializerSection.cs
- InterleavedZipPartStream.cs
- DeriveBytes.cs
- UnsafeCollabNativeMethods.cs