Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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. // //[....] //[....] //[....] //----------------------------------------------------------------------------- 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
- ParameterReplacerVisitor.cs
- PermissionListSet.cs
- ObjectNavigationPropertyMapping.cs
- EdmTypeAttribute.cs
- _ServiceNameStore.cs
- OdbcConnectionHandle.cs
- ThrowHelper.cs
- ArgumentDesigner.xaml.cs
- GenericUriParser.cs
- PropertyGridDesigner.cs
- ObjectTag.cs
- BasicExpressionVisitor.cs
- PageThemeCodeDomTreeGenerator.cs
- NewArray.cs
- ConfigXmlComment.cs
- ApplicationSecurityInfo.cs
- Block.cs
- DrawItemEvent.cs
- DecimalSumAggregationOperator.cs
- UnsafeNativeMethods.cs
- BinaryConverter.cs
- ReferencedAssembly.cs
- FileRegion.cs
- CodeConditionStatement.cs
- ApplicationException.cs
- NonClientArea.cs
- GridViewSelectEventArgs.cs
- DataGridViewSelectedCellCollection.cs
- TaskExtensions.cs
- OdbcDataReader.cs
- TreeNode.cs
- CryptoKeySecurity.cs
- RegexCapture.cs
- BooleanAnimationBase.cs
- InputLangChangeEvent.cs
- List.cs
- DataTransferEventArgs.cs
- ArraySet.cs
- MediaPlayer.cs
- DataTableMapping.cs
- SqlConnectionPoolProviderInfo.cs
- FlagsAttribute.cs
- XmlNamedNodeMap.cs
- TreeViewImageIndexConverter.cs
- IISMapPath.cs
- CriticalHandle.cs
- DashStyles.cs
- _FtpDataStream.cs
- PropertyBuilder.cs
- DataGridViewRowStateChangedEventArgs.cs
- DataTable.cs
- Geometry3D.cs
- ApplicationFileParser.cs
- SpecularMaterial.cs
- SynchronizationScope.cs
- ApplicationTrust.cs
- ReadOnlyCollection.cs
- SHA1Managed.cs
- TypedElement.cs
- BaseTemplateCodeDomTreeGenerator.cs
- LinkLabelLinkClickedEvent.cs
- TimeManager.cs
- StringValidatorAttribute.cs
- Collection.cs
- ACL.cs
- SqlRowUpdatedEvent.cs
- RepeaterItem.cs
- ConstraintStruct.cs
- SchemaTableColumn.cs
- CompletedAsyncResult.cs
- DrawingCollection.cs
- ChangeConflicts.cs
- DesigntimeLicenseContext.cs
- FixedHyperLink.cs
- TextSelectionHelper.cs
- ListViewItemMouseHoverEvent.cs
- EventProviderTraceListener.cs
- ImageFormatConverter.cs
- Point4D.cs
- GridViewRow.cs
- PeerNodeAddress.cs
- RayHitTestParameters.cs
- Size3DConverter.cs
- PropertyAccessVisitor.cs
- AssemblyNameUtility.cs
- RowVisual.cs
- PageCatalogPart.cs
- Object.cs
- SettingsSection.cs
- WorkflowViewStateService.cs
- RecordBuilder.cs
- ReachFixedDocumentSerializer.cs
- HasRunnableWorkflowEvent.cs
- XmlRootAttribute.cs
- XmlSchemaGroup.cs
- GeneralTransform3D.cs
- Operator.cs
- COM2FontConverter.cs
- TextRangeEdit.cs
- storagemappingitemcollection.viewdictionary.cs