Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / Designer / System / data / design / DesignParameter.cs / 1 / DesignParameter.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All Rights Reserved. // Information Contained Herein is Proprietary and Confidential. // //----------------------------------------------------------------------------- namespace System.Data.Design { using System.Diagnostics; using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Data.Common; using System.Text; using System.Globalization; [ DataSourceXmlClass(SchemaName.Parameter) ] internal class DesignParameter: DataSourceComponent, IDbDataParameter, IDataSourceNamedObject, ICloneable { private string parameterName; private string columnName; private string autogeneratedName; // Used while substituting VSDB-generated parameter names (ParamXx) with our, "pretty" names. private DbType dbType; private byte precision; private byte scale; private int size; private string dataTypeServer; private ParameterDirection direction; private string sourceColumn; private DataRowVersion sourceVersion; private string dataSourceName; private bool sourceColumnNullMapping; private bool allowDbNull; private string providerType = null; private static int[] adoDataType2DbType = new int[] { (int) ADODataType.adBSTR, (int) DbType.AnsiString, (int) ADODataType.adBigInt, (int) DbType.Int64, (int) ADODataType.adBinary, (int) DbType.Binary, (int) ADODataType.adBoolean, (int) DbType.Boolean, (int) ADODataType.adChar, (int) DbType.AnsiString, (int) ADODataType.adCurrency, (int) DbType.Currency, (int) ADODataType.adDate, (int) DbType.Date, (int) ADODataType.adDBDate, (int) DbType.Date, (int) ADODataType.adDBTime, (int) DbType.DateTime, (int) ADODataType.adDBTimeStamp, (int) DbType.DateTime, (int) ADODataType.adDecimal, (int) DbType.Decimal, (int) ADODataType.adDouble, (int) DbType.Double, (int) ADODataType.adEmpty, (int) DbType.Object, (int) ADODataType.adError, (int) DbType.Object, (int) ADODataType.adFileTime, (int) DbType.DateTime, (int) ADODataType.adGUID, (int) DbType.Guid, (int) ADODataType.adIDispatch, (int) DbType.Object, (int) ADODataType.adIUnknown, (int) DbType.Object, (int) ADODataType.adInteger, (int) DbType.Int32, (int) ADODataType.adLongVarBinary, (int) DbType.Binary, (int) ADODataType.adLongVarChar, (int) DbType.AnsiString, (int) ADODataType.adLongVarWChar, (int) DbType.String, (int) ADODataType.adNumeric, (int) DbType.Decimal, (int) ADODataType.adPropVariant, (int) DbType.Object, (int) ADODataType.adSingle, (int) DbType.Single, (int) ADODataType.adSmallInt, (int) DbType.Int16, (int) ADODataType.adTinyInt, (int) DbType.SByte, (int) ADODataType.adUnsignedBigInt, (int) DbType.UInt64, (int) ADODataType.adUnsignedInt, (int) DbType.UInt32, (int) ADODataType.adUnsignedSmallInt, (int) DbType.UInt16, (int) ADODataType.adUnsignedTinyInt, (int) DbType.Byte, (int) ADODataType.adVarBinary, (int) DbType.Binary, (int) ADODataType.adVarChar, (int) DbType.AnsiString, (int) ADODataType.adVarNumeric, (int) DbType.VarNumeric, (int) ADODataType.adVarWChar, (int) DbType.String, (int) ADODataType.adVariant, (int) DbType.Object, (int) ADODataType.adWChar, (int) DbType.String }; [ DataSourceXmlAttribute(), DefaultValue(false) ] public bool AllowDbNull { get { return this.allowDbNull; } set { this.allowDbNull = value; } } [ DataSourceXmlAttribute(), MergableProperty(false), DefaultValue(""), ] public string ParameterName { get { return this.parameterName; } set { if (!StringUtil.EqualValue(this.ParameterName, value)) { if (this.CollectionParent != null) { CollectionParent.ValidateUniqueName(this, value); } this.parameterName = value; } } } [ DataSourceXmlAttribute() ] public string ColumnName { get { return this.columnName; } set { this.columnName = value; } } [ DataSourceXmlAttribute(), Browsable(false) ] public string AutogeneratedName { get { return this.autogeneratedName; } set { this.autogeneratedName = value; } } [ DataSourceXmlAttribute() ] public DbType DbType { get { return this.dbType; } set { this.dbType = value; } } [ DataSourceXmlAttribute() ] public string ProviderType { get { return this.providerType; } set { this.providerType = value; } } [ DataSourceXmlAttribute(), DefaultValueAttribute((byte)0) ] public byte Precision { get { return this.precision; } set { this.precision = value; } } [ DataSourceXmlAttribute(), DefaultValueAttribute((byte)0) ] public byte Scale { get { return this.scale; } set { this.scale = value; } } [ DataSourceXmlAttribute(), DefaultValueAttribute((int)0) ] public int Size { get { return this.size; } set { this.size = value; // For BLOBs VSDB will return 0xffffffff; if( this.size < 0 ) { this.size = int.MaxValue; } } } [ DataSourceXmlAttribute(), Browsable(false) ] public string DataTypeServer { get { return this.dataTypeServer; } set { this.dataTypeServer = value; } } [ DataSourceXmlAttribute(), DefaultValue(ParameterDirection.Input) ] public ParameterDirection Direction { get { return this.direction; } set { this.direction = value; } } [ DefaultValue(""), DataSourceXmlAttribute() ] public string SourceColumn { get { return this.sourceColumn; } set { this.sourceColumn = value; } } [ DefaultValue(DataRowVersion.Current), DataSourceXmlAttribute() ] public DataRowVersion SourceVersion { get { return this.sourceVersion; } set { this.sourceVersion = value; } } [ DataSourceXmlAttribute(), Browsable(false) ] public string DataSourceName { get { return this.dataSourceName; } set { this.dataSourceName = value; } } string INamedObject.Name { get { return ParameterName; } set { ParameterName = value; } } string IDataSourceNamedObject.PublicTypeName { get { return "Parameter"; } } [ Browsable(false), DefaultValue(false), DesignOnly(true), EditorBrowsableAttribute(EditorBrowsableState.Never) ] public bool IsNullable { get { return true; } } [Browsable(false), DefaultValue(null)] public object Value { get { return null; } set { // noop } } ////// This is for the object collection editor. Overriding ToString() is not enough in case of DesignParameter because /// it is a component. Because of that TypeConverter will try to use Site.Name when converting to string, this will /// fail and they will fall back to class name. /// If that is not acceptable we should implement a custom type converter for DesignParameter. /// [Browsable(false)] public string Name { get { return this.ParameterName; } } [ DefaultValue(false), DataSourceXmlAttribute() ] public bool SourceColumnNullMapping { get { return this.sourceColumnNullMapping; } set { this.sourceColumnNullMapping = value; } } public override string ToString() { return this.ParameterName; } public const string DEFAULT_RETVAL_NAME = "RETURN_VALUE"; // this constructor is only used by serializor.. public DesignParameter() : this(String.Empty) { } public DesignParameter (string name) { this.parameterName = name; this.autogeneratedName = string.Empty; this.direction = ParameterDirection.Input; this.sourceVersion = DataRowVersion.Current; this.dataSourceName = string.Empty; } public override bool Equals( object o ) { DesignParameter p = o as DesignParameter; if( p == null ) return false; return p.ParameterName.Equals( this.ParameterName ); } // This is just to make compiler happy (because we're overriding Equals( object ) ) public override int GetHashCode() { return this.ParameterName.GetHashCode(); } public object Clone() { DesignParameter p = new DesignParameter( this.ParameterName ); p.ColumnName = ColumnName; p.AutogeneratedName = AutogeneratedName; p.DbType = DbType; p.Precision = Precision; p.Scale = Scale; p.Size = Size; p.DataTypeServer = DataTypeServer; p.Direction = Direction; p.SourceColumn = SourceColumn; p.SourceVersion = SourceVersion; p.SourceColumnNullMapping = SourceColumnNullMapping; return p; } public static DesignParameter GetDefaultRetvalParam() { DesignParameter p = new DesignParameter( DEFAULT_RETVAL_NAME ); p.DbType = DbType.Int32; p.Precision = p.Scale = 0; p.Size = 4; p.Direction = ParameterDirection.ReturnValue; return p; } } } // 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
- StringExpressionSet.cs
- CompilationUtil.cs
- AdRotatorDesigner.cs
- MemberDescriptor.cs
- Validator.cs
- ReceiveMessageRecord.cs
- TakeOrSkipQueryOperator.cs
- Hyperlink.cs
- SmtpException.cs
- SerializableTypeCodeDomSerializer.cs
- IISMapPath.cs
- XmlSchemaIdentityConstraint.cs
- Annotation.cs
- Compress.cs
- SecurityUniqueId.cs
- WmlValidatorAdapter.cs
- panel.cs
- ResourceWriter.cs
- MemoryRecordBuffer.cs
- Utils.cs
- EventBindingService.cs
- CheckBoxPopupAdapter.cs
- QuaternionRotation3D.cs
- ExceptionUtil.cs
- _DigestClient.cs
- WindowsStatusBar.cs
- LayoutManager.cs
- JoinSymbol.cs
- RequestNavigateEventArgs.cs
- DynamicPropertyReader.cs
- DataGridViewColumnHeaderCell.cs
- DocumentOrderComparer.cs
- GenericsInstances.cs
- NumericUpDownAcceleration.cs
- SiteMapDataSourceView.cs
- XmlDocumentSerializer.cs
- xamlnodes.cs
- CodeExpressionCollection.cs
- MatrixConverter.cs
- MainMenu.cs
- IIS7WorkerRequest.cs
- TabletCollection.cs
- Rectangle.cs
- HyperLinkStyle.cs
- RenderingBiasValidation.cs
- FontInfo.cs
- DispatchChannelSink.cs
- FieldToken.cs
- Documentation.cs
- HtmlFormParameterWriter.cs
- Module.cs
- ADMembershipUser.cs
- CRYPTPROTECT_PROMPTSTRUCT.cs
- MenuItem.cs
- SplitContainer.cs
- GlyphElement.cs
- AxImporter.cs
- NumberEdit.cs
- GenericUriParser.cs
- unitconverter.cs
- securitycriticaldata.cs
- CallTemplateAction.cs
- ContentPlaceHolder.cs
- KeysConverter.cs
- FontUnitConverter.cs
- HitTestWithGeometryDrawingContextWalker.cs
- WorkflowOwnerAsyncResult.cs
- Font.cs
- BitmapPalettes.cs
- storepermission.cs
- _NtlmClient.cs
- ScrollBarRenderer.cs
- Exceptions.cs
- CapabilitiesAssignment.cs
- ReceiveActivityValidator.cs
- Stylesheet.cs
- CurrentChangedEventManager.cs
- DynamicPropertyReader.cs
- DPTypeDescriptorContext.cs
- TTSEngineTypes.cs
- ObjectStorage.cs
- SettingsPropertyValueCollection.cs
- DataGridLength.cs
- TrackBar.cs
- WebBrowser.cs
- AbsoluteQuery.cs
- EventsTab.cs
- FileSecurity.cs
- DiffuseMaterial.cs
- TraceLevelHelper.cs
- ReachVisualSerializer.cs
- SafeMemoryMappedViewHandle.cs
- ByteKeyFrameCollection.cs
- Recipient.cs
- HttpModuleActionCollection.cs
- StorageEntityContainerMapping.cs
- KeyboardDevice.cs
- X509Utils.cs
- TableRowCollection.cs
- DataGridViewRowConverter.cs