Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / 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
- FigureHelper.cs
- ProtocolException.cs
- EdmToObjectNamespaceMap.cs
- filewebresponse.cs
- SmiContext.cs
- ObjectSet.cs
- FrugalList.cs
- ipaddressinformationcollection.cs
- RadioButtonPopupAdapter.cs
- SelectionChangedEventArgs.cs
- WorkflowView.cs
- ComplexBindingPropertiesAttribute.cs
- MemberRelationshipService.cs
- XmlBaseWriter.cs
- QueuedDeliveryRequirementsMode.cs
- MutableAssemblyCacheEntry.cs
- Message.cs
- OrthographicCamera.cs
- IConvertible.cs
- ItemTypeToolStripMenuItem.cs
- XmlConvert.cs
- XmlQualifiedNameTest.cs
- CredentialCache.cs
- XmlNodeChangedEventManager.cs
- TreeWalker.cs
- TypeGeneratedEventArgs.cs
- ReferentialConstraint.cs
- RsaKeyIdentifierClause.cs
- RegistrationServices.cs
- OpenFileDialog.cs
- ModelItemExtensions.cs
- Stack.cs
- XmlDataProvider.cs
- DataGridViewCellStateChangedEventArgs.cs
- TaiwanCalendar.cs
- Compiler.cs
- EventsTab.cs
- SymbolType.cs
- InProcStateClientManager.cs
- LocalBuilder.cs
- StsCommunicationException.cs
- ConfigurationManager.cs
- FilterException.cs
- Vector3DCollectionConverter.cs
- BinaryMethodMessage.cs
- AtomParser.cs
- StructuralType.cs
- MinMaxParagraphWidth.cs
- ObjectDataSourceMethodEventArgs.cs
- SerialStream.cs
- StringValidator.cs
- WebPartCancelEventArgs.cs
- RepeatInfo.cs
- Decorator.cs
- XmlSerializerSection.cs
- SoapElementAttribute.cs
- ListBase.cs
- WriteTimeStream.cs
- Process.cs
- PkcsUtils.cs
- ToolStripPanel.cs
- DataBoundControlAdapter.cs
- DiscreteKeyFrames.cs
- TextOutput.cs
- recordstatefactory.cs
- ProviderUtil.cs
- WebContext.cs
- ConfigXmlComment.cs
- StylusButton.cs
- SqlDataRecord.cs
- Parsers.cs
- CommandExpr.cs
- Assert.cs
- WebPartCollection.cs
- ResourceReferenceExpression.cs
- MouseBinding.cs
- PoisonMessageException.cs
- EnumerableRowCollection.cs
- SqlCrossApplyToCrossJoin.cs
- OdbcHandle.cs
- IDictionary.cs
- RequestStatusBarUpdateEventArgs.cs
- ThrowHelper.cs
- SerializationObjectManager.cs
- TrackingServices.cs
- Message.cs
- ColorMatrix.cs
- ObjectDataSourceMethodEventArgs.cs
- AutomationTextAttribute.cs
- MetadataUtilsSmi.cs
- PhysicalAddress.cs
- CommandPlan.cs
- ExpressionEvaluator.cs
- IntegerValidator.cs
- BaseAsyncResult.cs
- SqlSupersetValidator.cs
- _DomainName.cs
- IntPtr.cs
- OleDbErrorCollection.cs
- UnmanagedMemoryStreamWrapper.cs