当前位置: 首页>>代码示例>>C#>>正文


C# Common.Descriptor类代码示例

本文整理汇总了C#中FirebirdSql.Data.Common.Descriptor的典型用法代码示例。如果您正苦于以下问题:C# Descriptor类的具体用法?C# Descriptor怎么用?C# Descriptor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Descriptor类属于FirebirdSql.Data.Common命名空间,在下文中一共展示了Descriptor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MarshalManagedToNative

		public static IntPtr MarshalManagedToNative(Charset charset, Descriptor descriptor)
		{
			// Set up XSQLDA structure
			var xsqlda = new XSQLDA
			{
				version = descriptor.Version,
				sqln = descriptor.Count,
				sqld = descriptor.ActualCount
			};

			var xsqlvar = new XSQLVAR[descriptor.Count];

			for (var i = 0; i < xsqlvar.Length; i++)
			{
				// Create a	new	XSQLVAR	structure and fill it
				xsqlvar[i] = new XSQLVAR
				{
					sqltype = descriptor[i].DataType,
					sqlscale = descriptor[i].NumericScale,
					sqlsubtype = descriptor[i].SubType,
					sqllen = descriptor[i].Length
				};


				// Create a	new	pointer	for	the	xsqlvar	data
				if (descriptor[i].HasDataType() && descriptor[i].DbDataType != DbDataType.Null)
				{
					var buffer = descriptor[i].DbValue.GetBytes();
					xsqlvar[i].sqldata = Marshal.AllocHGlobal(buffer.Length);
					Marshal.Copy(buffer, 0, xsqlvar[i].sqldata, buffer.Length);
				}
				else
				{
					xsqlvar[i].sqldata = Marshal.AllocHGlobal(0);
				}

				// Create a	new	pointer	for	the	sqlind value
				xsqlvar[i].sqlind = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(short)));
				Marshal.WriteInt16(xsqlvar[i].sqlind, descriptor[i].NullFlag);

				// Name
				xsqlvar[i].sqlname = GetStringBuffer(charset, descriptor[i].Name);
				xsqlvar[i].sqlname_length = (short)descriptor[i].Name.Length;

				// Relation	Name
				xsqlvar[i].relname = GetStringBuffer(charset, descriptor[i].Relation);
				xsqlvar[i].relname_length = (short)descriptor[i].Relation.Length;

				// Owner name
				xsqlvar[i].ownername = GetStringBuffer(charset, descriptor[i].Owner);
				xsqlvar[i].ownername_length = (short)descriptor[i].Owner.Length;

				// Alias name
				xsqlvar[i].aliasname = GetStringBuffer(charset, descriptor[i].Alias);
				xsqlvar[i].aliasname_length = (short)descriptor[i].Alias.Length;
			}

			return MarshalManagedToNative(xsqlda, xsqlvar);
		}
开发者ID:mrgleba,项目名称:FirebirdSql.Data.FirebirdClient,代码行数:59,代码来源:XsqldaMarshaler.cs

示例2: Describe

		public override void Describe()
		{
			lock (_db)
			{
				// Clear the status vector
				ClearStatusVector();

				// Update structure
				_fields = new Descriptor(_fields.ActualCount);

				// Marshal structures to pointer


				IntPtr sqlda = XsqldaMarshaler.MarshalManagedToNative(_db.Charset, _fields);
				int stmtHandle = _handle;

				_db.FbClient.isc_dsql_describe(
					_statusVector,
					ref stmtHandle,
					IscCodes.SQLDA_VERSION1,
					sqlda);

				// Marshal Pointer
				Descriptor descriptor = XsqldaMarshaler.MarshalNativeToManaged(_db.Charset, sqlda);

				// Free	memory
				XsqldaMarshaler.CleanUpNativeData(ref sqlda);

				// Parse status	vector
				_db.ParseStatusVector(_statusVector);

				// Update field	descriptor
				_fields = descriptor;
			}
		}
开发者ID:fishcodelib,项目名称:FirebirdSql.Data.FirebirdClient,代码行数:35,代码来源:FesStatement.cs

示例3: BuildParameterDescriptor

        private bool BuildParameterDescriptor(Descriptor descriptor, FbParameter parameter, int index)
        {
            if (!parameter.IsTypeSet)
            {
                return false;
            }

            FbDbType type = parameter.FbDbType;
            Charset charset = this.connection.InnerConnection.Database.Charset;

            // Check the parameter character set
            if (parameter.Charset == FbCharset.Octets && !(parameter.InternalValue is byte[]))
            {
                throw new InvalidOperationException("Value for char octets fields should be a byte array");
            }
            else if (type == FbDbType.Guid)
            {
                charset = Charset.GetCharset("OCTETS");
            }
            else if (parameter.Charset != FbCharset.Default)
            {
                charset = Charset.GetCharset((int)parameter.Charset);
            }

            // Set parameter Data Type
            descriptor[index].DataType = (short)TypeHelper.GetFbType((DbDataType)type, parameter.IsNullable);

            // Set parameter Sub Type
            switch (type)
            {
                case FbDbType.Binary:
                    descriptor[index].SubType = 0;
                    break;

                case FbDbType.Text:
                    descriptor[index].SubType = 1;
                    break;

                case FbDbType.Guid:
                    descriptor[index].SubType = (short)charset.Identifier;
                    break;

                case FbDbType.Char:
                case FbDbType.VarChar:
                    descriptor[index].SubType = (short)charset.Identifier;
                    if (charset.IsOctetsCharset)
                    {
                        descriptor[index].Length = (short)parameter.Size;
                    }
                    else if (parameter.HasSize)
                    {
                        short len = (short)(parameter.Size * charset.BytesPerCharacter);
                        descriptor[index].Length = len;
                    }
                    break;
            }

            // Set parameter length
            if (descriptor[index].Length == 0)
            {
                descriptor[index].Length = TypeHelper.GetSize((DbDataType)type);
            }

            // Verify parameter
            if (descriptor[index].SqlType == 0 || descriptor[index].Length == 0)
            {
                return false;
            }

            return true;
        }
开发者ID:kingpong,项目名称:NETProvider,代码行数:71,代码来源:FbCommand.cs

示例4: MarshalManagedToNative

		public IntPtr MarshalManagedToNative(Charset charset, Descriptor descriptor)
		{
			// Set up XSQLDA structure
			XSQLDA xsqlda = new XSQLDA();

			xsqlda.version  = descriptor.Version;
			xsqlda.sqln     = descriptor.Count;
			xsqlda.sqld     = descriptor.ActualCount;

			XSQLVAR[] xsqlvar = new XSQLVAR[descriptor.Count];

			for (int i = 0; i < xsqlvar.Length; i++)
			{
				// Create a	new	XSQLVAR	structure and fill it
				xsqlvar[i] = new XSQLVAR();

				xsqlvar[i].sqltype      = descriptor[i].DataType;
				xsqlvar[i].sqlscale     = descriptor[i].NumericScale;
				xsqlvar[i].sqlsubtype   = descriptor[i].SubType;
				xsqlvar[i].sqllen       = descriptor[i].Length;

				// Create a	new	pointer	for	the	xsqlvar	data
				byte[] buffer = descriptor[i].DbValue.GetBytes();
				xsqlvar[i].sqldata = Marshal.AllocHGlobal(buffer.Length);
				Marshal.Copy(buffer, 0, xsqlvar[i].sqldata, buffer.Length);

				// Create a	new	pointer	for	the	sqlind value
				xsqlvar[i].sqlind = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(Int16)));
				Marshal.WriteInt16(xsqlvar[i].sqlind, descriptor[i].NullFlag);

				// Name
				xsqlvar[i].sqlname = this.GetStringBuffer(charset, descriptor[i].Name);
				xsqlvar[i].sqlname_length = (short)descriptor[i].Name.Length;

				// Relation	Name
				xsqlvar[i].relname = this.GetStringBuffer(charset, descriptor[i].Relation);
				xsqlvar[i].relname_length = (short)descriptor[i].Relation.Length;

				// Owner name
				xsqlvar[i].ownername = this.GetStringBuffer(charset, descriptor[i].Owner);
				xsqlvar[i].ownername_length = (short)descriptor[i].Owner.Length;

				// Alias name
				xsqlvar[i].aliasname = this.GetStringBuffer(charset, descriptor[i].Alias);
				xsqlvar[i].aliasname_length = (short)descriptor[i].Alias.Length;
			}

			return this.MarshalManagedToNative(xsqlda, xsqlvar);
		}
开发者ID:robsoft,项目名称:FirebirdMonoDroidProvider,代码行数:49,代码来源:XsqldaMarshaler.cs

示例5: Clone

		public object Clone()
		{
			Descriptor descriptor = new Descriptor(this.Count);
			descriptor.Version = this.version;

			for (int i = 0; i < descriptor.Count; i++)
			{
				descriptor[i].DataType	= this.fields[i].DataType;
				descriptor[i].NumericScale = this.fields[i].NumericScale;
				descriptor[i].SubType	= this.fields[i].SubType;
				descriptor[i].Length	= this.fields[i].Length;
				descriptor[i].Value		= this.fields[i].Value;
				descriptor[i].NullFlag	= this.fields[i].NullFlag;
				descriptor[i].Name		= this.fields[i].Name;
				descriptor[i].Relation	= this.fields[i].Relation;
				descriptor[i].Owner		= this.fields[i].Owner;
				descriptor[i].Alias		= this.fields[i].Alias;
			}

			return descriptor;
		}
开发者ID:Outlivier,项目名称:FirebirdSql.Data.FirebirdClient,代码行数:21,代码来源:Descriptor.cs

示例6: ParseSqlInfo

		protected void ParseSqlInfo(byte[] info, byte[] items, ref Descriptor[] rowDescs)
		{
			this.ParseTruncSqlInfo(info, items, ref rowDescs);
		}
开发者ID:cafee,项目名称:NETProvider,代码行数:4,代码来源:GdsStatement.cs

示例7: Write

		public void Write(Descriptor descriptor)
		{
			for (int i = 0; i < descriptor.Count; i++)
			{
				this.Write(descriptor[i]);
			}
		}
开发者ID:antgraf,项目名称:Embedded-DB-.Net-Performance-Test,代码行数:7,代码来源:XdrStream.cs

示例8: ProcessPrepareResponse

		protected void ProcessPrepareResponse(GenericResponse response)
		{
			Descriptor[] descriptors = new Descriptor[] { null, null };
			this.ParseSqlInfo(response.Data, DescribeInfoAndBindInfoItems, ref descriptors);
			this.fields = descriptors[0];
			this.parameters = descriptors[1];
		}
开发者ID:cafee,项目名称:NETProvider,代码行数:7,代码来源:GdsStatement.cs

示例9: DescribeParameters

		public override void DescribeParameters()
		{
			lock (_db)
			{
				// Clear the status vector
				ClearStatusVector();

				// Marshal structures to pointer


				_parameters = new Descriptor(1);

				IntPtr sqlda = XsqldaMarshaler.MarshalManagedToNative(_db.Charset, _parameters);
				int stmtHandle = _handle;

				_db.FbClient.isc_dsql_describe_bind(
					_statusVector,
					ref stmtHandle,
					IscCodes.SQLDA_VERSION1,
					sqlda);

				Descriptor descriptor = XsqldaMarshaler.MarshalNativeToManaged(_db.Charset, sqlda);

				// Parse status	vector
				_db.ParseStatusVector(_statusVector);

				if (descriptor.ActualCount != 0 && descriptor.Count != descriptor.ActualCount)
				{
					short n = descriptor.ActualCount;
					descriptor = new Descriptor(n);

					// Fre memory
					XsqldaMarshaler.CleanUpNativeData(ref sqlda);

					// Marshal new structure
					sqlda = XsqldaMarshaler.MarshalManagedToNative(_db.Charset, descriptor);

					_db.FbClient.isc_dsql_describe_bind(
						_statusVector,
						ref stmtHandle,
						IscCodes.SQLDA_VERSION1,
						sqlda);

					descriptor = XsqldaMarshaler.MarshalNativeToManaged(_db.Charset, sqlda);

					// Free	memory
					XsqldaMarshaler.CleanUpNativeData(ref sqlda);

					// Parse status	vector
					_db.ParseStatusVector(_statusVector);
				}
				else
				{
					if (descriptor.ActualCount == 0)
					{
						descriptor = new Descriptor(0);
					}
				}

				// Free	memory
				if (sqlda != IntPtr.Zero)
				{
					XsqldaMarshaler.CleanUpNativeData(ref sqlda);
				}

				// Update parameter	descriptor
				_parameters = descriptor;
			}
		}
开发者ID:fishcodelib,项目名称:FirebirdSql.Data.FirebirdClient,代码行数:69,代码来源:FesStatement.cs

示例10: ParseTruncSqlInfo

		protected void ParseTruncSqlInfo(byte[] info, byte[] items, ref Descriptor[] rowDescs)
		{
			int currentPosition = 0;
			int currentDescriptorIndex = -1;
			int currentItemIndex = 0;
			while (info[currentPosition] != IscCodes.isc_info_end)
			{
				bool jumpOutOfInnerLoop = false;
				byte item;
				while ((item = info[currentPosition++]) != IscCodes.isc_info_sql_describe_end)
				{
					switch (item)
					{
						case IscCodes.isc_info_truncated:
							currentItemIndex--;

							List<byte> newItems = new List<byte>(items.Length);
							int part = 0;
							int chock = 0;
							for (int i = 0; i < items.Length; i++)
							{
								if (items[i] == IscCodes.isc_info_sql_describe_end)
								{
									newItems.Insert(chock, IscCodes.isc_info_sql_sqlda_start);
									newItems.Insert(chock + 1, 2);

									short processedItems = (rowDescs[part] != null ? rowDescs[part].Count : (short)0);
									newItems.Insert(chock + 2, (byte)((part == currentDescriptorIndex ? currentItemIndex : processedItems) & 255));
									newItems.Insert(chock + 3, (byte)((part == currentDescriptorIndex ? currentItemIndex : processedItems) >> 8));

									part++;
									chock = i + 4 + 1;
								}
								newItems.Add(items[i]);
							}

							info = this.GetSqlInfo(newItems.ToArray(), info.Length);

							currentPosition = 0;
							currentDescriptorIndex = -1;
							jumpOutOfInnerLoop = true;
							break;

						case IscCodes.isc_info_sql_select:
						case IscCodes.isc_info_sql_bind:
							currentDescriptorIndex++;

							if (info[currentPosition] == IscCodes.isc_info_truncated)
								break;

							currentPosition++;
							int len = IscHelper.VaxInteger(info, currentPosition, 2);
							currentPosition += 2;
							if (rowDescs[currentDescriptorIndex] == null)
							{
								int n = IscHelper.VaxInteger(info, currentPosition, len);
								rowDescs[currentDescriptorIndex] = new Descriptor((short)n);
								jumpOutOfInnerLoop = (n == 0);
							}
							currentPosition += len;
							break;

						case IscCodes.isc_info_sql_sqlda_seq:
							len = IscHelper.VaxInteger(info, currentPosition, 2);
							currentPosition += 2;
							currentItemIndex = IscHelper.VaxInteger(info, currentPosition, len);
							currentPosition += len;
							break;

						case IscCodes.isc_info_sql_type:
							len = IscHelper.VaxInteger(info, currentPosition, 2);
							currentPosition += 2;
							rowDescs[currentDescriptorIndex][currentItemIndex - 1].DataType = (short)IscHelper.VaxInteger(info, currentPosition, len);
							currentPosition += len;
							break;

						case IscCodes.isc_info_sql_sub_type:
							len = IscHelper.VaxInteger(info, currentPosition, 2);
							currentPosition += 2;
							rowDescs[currentDescriptorIndex][currentItemIndex - 1].SubType = (short)IscHelper.VaxInteger(info, currentPosition, len);
							currentPosition += len;
							break;

						case IscCodes.isc_info_sql_scale:
							len = IscHelper.VaxInteger(info, currentPosition, 2);
							currentPosition += 2;
							rowDescs[currentDescriptorIndex][currentItemIndex - 1].NumericScale = (short)IscHelper.VaxInteger(info, currentPosition, len);
							currentPosition += len;
							break;

						case IscCodes.isc_info_sql_length:
							len = IscHelper.VaxInteger(info, currentPosition, 2);
							currentPosition += 2;
							rowDescs[currentDescriptorIndex][currentItemIndex - 1].Length = (short)IscHelper.VaxInteger(info, currentPosition, len);
							currentPosition += len;
							break;

						case IscCodes.isc_info_sql_field:
							len = IscHelper.VaxInteger(info, currentPosition, 2);
							currentPosition += 2;
//.........这里部分代码省略.........
开发者ID:cafee,项目名称:NETProvider,代码行数:101,代码来源:GdsStatement.cs

示例11: FbCursor

		public FbCursor(FbCommand command)
		{
			this.command	= command;
			this.fields		= this.command.GetFieldsDescriptor();
		}
开发者ID:cafee,项目名称:NETProvider,代码行数:5,代码来源:FbCursor.cs

示例12: Describe

        public override void Describe()
        {
            lock (this.db)
            {
                // Update structure
                this.fields = new Descriptor(this.fields.ActualCount);

                // Marshal structures to pointer
                XsqldaMarshaler marshaler = XsqldaMarshaler.Instance;

                IntPtr sqlda = marshaler.MarshalManagedToNative(this.db.Charset, fields);

                int[] statusVector = ExtConnection.GetNewStatusVector();
                int stmtHandle = this.handle;

                SafeNativeMethods.isc_dsql_describe(
                    statusVector,
                    ref	stmtHandle,
                    IscCodes.SQLDA_VERSION1,
                    sqlda);

                // Marshal Pointer
                Descriptor descriptor = marshaler.MarshalNativeToManaged(this.db.Charset, sqlda);

                // Free	memory
                marshaler.CleanUpNativeData(ref	sqlda);

                // Parse status	vector
                this.db.ParseStatusVector(statusVector);

                // Update field	descriptor
                this.fields = descriptor;
            }
        }
开发者ID:kingpong,项目名称:NETProvider,代码行数:34,代码来源:ExtStatement.cs

示例13: Close

		/// <include file='Doc/en_EN/FbDataReader.xml' path='doc/class[@name="FbDataReader"]/method[@name="Close"]/*'/>
		public void Close()
		{
			bool closeConnection = false;

			if (this.IsClosed)
			{
				return;
			}

			this.isClosed = true;
			this.position = STARTPOS;
			
			if (this.connection != null)
			{
				if ((this.behavior & CommandBehavior.CloseConnection) == CommandBehavior.CloseConnection)
				{
					closeConnection = true;
				}
			}

			if (this.command != null && !this.command.IsDisposed)
			{
				if (this.command.CommandType == CommandType.StoredProcedure)
				{
					// Set values of output	parameters
					this.command.SetOutputParameters();
				}

				if (this.command.HasImplicitTransaction)
				{
					// Commit implicit transaction if needed
					this.command.CommitImplicitTransaction();
				}

				// Set null	the	active reader of the command
				this.command.ActiveReader = null;
			}

			if (closeConnection)
			{
				this.connection.Close();
			}

			this.command		= null;
			this.connection		= null;
			this.row			= null;
			this.schemaTable	= null;
			this.fields			= null;
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:50,代码来源:FbDataReader.cs

示例14: Release

		public int Release()
		{
			this.command.CommitImplicitTransaction();
			this.command.Close();
			this.fields		= null;
			this.row		= null;
			this.lastError	= null;
			this.isReleased	= true;
			this.eof		= true;

			return 0;
		}
开发者ID:cafee,项目名称:NETProvider,代码行数:12,代码来源:FbCursor.cs

示例15: DoFreePacket

		protected void DoFreePacket(int option)
		{
			try
			{
				SendFreeToBuffer(option);

				// Reset statement information
				if (option == IscCodes.DSQL_drop)
				{
					this.parameters = null;
					this.fields = null;
				}

				this.Clear();
			}
			catch (IOException)
			{
				this.state = StatementState.Error;
				throw new IscException(IscCodes.isc_net_read_err);
			}
		}
开发者ID:cafee,项目名称:NETProvider,代码行数:21,代码来源:GdsStatement.cs


注:本文中的FirebirdSql.Data.Common.Descriptor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。