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
- FilterableAttribute.cs
- ControlCachePolicy.cs
- PartialArray.cs
- Vector3DIndependentAnimationStorage.cs
- basevalidator.cs
- CancellationState.cs
- XamlFigureLengthSerializer.cs
- DecimalStorage.cs
- ButtonBaseAutomationPeer.cs
- ManualResetEventSlim.cs
- SHA256Managed.cs
- Predicate.cs
- EntityModelSchemaGenerator.cs
- HttpRuntimeSection.cs
- WebPartUserCapability.cs
- XmlLoader.cs
- SvcMapFileLoader.cs
- ItemChangedEventArgs.cs
- HyperLink.cs
- SuppressMergeCheckAttribute.cs
- WebPartCollection.cs
- MediaContext.cs
- ColumnHeaderConverter.cs
- DefaultProxySection.cs
- CrossSiteScriptingValidation.cs
- EntityDataSourceColumn.cs
- SplitterCancelEvent.cs
- Button.cs
- DoubleStorage.cs
- FileCodeGroup.cs
- RegexCompilationInfo.cs
- ScriptDescriptor.cs
- ConnectionManagementElement.cs
- ListControlBuilder.cs
- GraphicsContext.cs
- Sentence.cs
- RegionIterator.cs
- RecordBuilder.cs
- MediaElementAutomationPeer.cs
- PathGeometry.cs
- VirtualDirectoryMapping.cs
- InvalidCastException.cs
- ObjectSet.cs
- TcpHostedTransportConfiguration.cs
- DataTablePropertyDescriptor.cs
- ImageConverter.cs
- _SslStream.cs
- CrossContextChannel.cs
- SafeEventLogReadHandle.cs
- RenderDataDrawingContext.cs
- ImageFormat.cs
- XmlSchemaObjectTable.cs
- DataServiceRequest.cs
- FixedPageProcessor.cs
- EventMappingSettingsCollection.cs
- EncodingDataItem.cs
- IPipelineRuntime.cs
- DesignerCapabilities.cs
- MessageContractAttribute.cs
- StatusBar.cs
- RadialGradientBrush.cs
- DataTrigger.cs
- FlowPosition.cs
- DispatchChannelSink.cs
- ExpressionList.cs
- TextElementEditingBehaviorAttribute.cs
- MSG.cs
- CommandID.cs
- DataSourceViewSchemaConverter.cs
- MergeLocalizationDirectives.cs
- StatusBarPanel.cs
- CryptoProvider.cs
- TraceHandler.cs
- TextModifier.cs
- PrintingPermission.cs
- contentDescriptor.cs
- XmlNotation.cs
- TextElementAutomationPeer.cs
- TraceContextEventArgs.cs
- Bezier.cs
- CriticalHandle.cs
- PageThemeParser.cs
- Logging.cs
- InfoCardRSAPKCS1SignatureDeformatter.cs
- GridViewHeaderRowPresenter.cs
- Identity.cs
- DictationGrammar.cs
- ResourceReferenceKeyNotFoundException.cs
- DataFormats.cs
- EncryptedPackageFilter.cs
- TreeNodeMouseHoverEvent.cs
- Vector3DValueSerializer.cs
- SqlErrorCollection.cs
- HttpContextServiceHost.cs
- RSAPKCS1KeyExchangeFormatter.cs
- DesignerSerializerAttribute.cs
- LinearKeyFrames.cs
- ExtentKey.cs
- DataTablePropertyDescriptor.cs
- CommandPlan.cs