本文整理汇总了C#中FirebirdSql.Data.Common.Charset类的典型用法代码示例。如果您正苦于以下问题:C# Charset类的具体用法?C# Charset怎么用?C# Charset使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Charset类属于FirebirdSql.Data.Common命名空间,在下文中一共展示了Charset类的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);
}
示例2: GdsConnection
public GdsConnection(string dataSource, int portNumber, int packetSize, Charset characterSet)
{
this.dataSource = dataSource;
this.portNumber = portNumber;
this.packetSize = packetSize;
this.characterSet = characterSet;
GC.SuppressFinalize(this);
}
示例3: ExtDatabase
public ExtDatabase()
{
this.charset = Charset.DefaultCharset;
this.dialect = 3;
this.packetSize = 8192;
this.statusVector = new int[IscCodes.ISC_STATUS_LENGTH];
GC.SuppressFinalize(this);
}
示例4: XdrStream
public XdrStream(Stream innerStream, Charset charset)
: base()
{
this.innerStream = innerStream;
this.charset = charset;
this.ResetOperation();
GC.SuppressFinalize(innerStream);
}
示例5: FesDatabase
public FesDatabase(string dllName, Charset charset)
{
this.fbClient = FbClientFactory.GetFbClient(dllName);
this.charset = (charset != null ? charset : Charset.DefaultCharset);
this.dialect = 3;
this.packetSize = 8192;
this.statusVector = new IntPtr[IscCodes.ISC_STATUS_LENGTH];
GC.SuppressFinalize(this);
}
示例6: Connect
public void Connect(string dataSource, int port, int packetSize, Charset charset)
{
try
{
IPAddress hostadd = Dns.Resolve(dataSource).AddressList[0];
IPEndPoint EPhost = new IPEndPoint(hostadd, port);
this.socket = new Socket(
AddressFamily.InterNetwork,
SocketType.Stream,
ProtocolType.Tcp);
#if (!NETCF)
// Set Receive Buffer size.
this.socket.SetSocketOption(
SocketOptionLevel.Socket,
SocketOptionName.ReceiveBuffer,
packetSize);
// Set Send Buffer size.
this.socket.SetSocketOption(
SocketOptionLevel.Socket,
SocketOptionName.SendBuffer,
packetSize);
#endif
// Disables the Nagle algorithm for send coalescing.
this.socket.SetSocketOption(
SocketOptionLevel.Tcp,
SocketOptionName.NoDelay,
1);
// Make the socket to connect to the Server
this.socket.Connect(EPhost);
this.networkStream = new NetworkStream(this.socket, true);
#if (NETCF)
this.send = new XdrStream(this.networkStream, charset);
this.receive = new XdrStream(this.networkStream, charset);
#else
this.send = new XdrStream(new BufferedStream(this.networkStream), charset);
this.receive = new XdrStream(new BufferedStream(this.networkStream), charset);
#endif
GC.SuppressFinalize(this.socket);
GC.SuppressFinalize(this.networkStream);
GC.SuppressFinalize(this.send);
GC.SuppressFinalize(this.receive);
}
catch (SocketException)
{
throw new IscException(IscCodes.isc_arg_gds, IscCodes.isc_network_error, dataSource);
}
}
示例7: GdsDatabase
public GdsDatabase(GdsConnection connection)
{
this.connection = connection;
this.charset = Charset.DefaultCharset;
this.dialect = 3;
this.packetSize = 8192;
this.inputStream = this.connection.CreateXdrStream();
this.outputStream = this.connection.CreateXdrStream();
GC.SuppressFinalize(this);
}
示例8: Add
internal Charset Add(
int id,
string charset,
int bytesPerCharacter,
string systemCharset)
{
Charset charSet = new Charset(
id, charset, bytesPerCharacter, systemCharset);
return this.Add(charSet);
}
示例9: MarshalManagedToNative
public IntPtr MarshalManagedToNative(Charset charset, object value)
{
DbField field = new DbField();
ParamDsc descriptor = this.BuildDescriptor(charset, value);
DbDataType type = TypeHelper.GetTypeFromDsc(descriptor.Type, descriptor.Scale, descriptor.SubType);
field.DataType = (short)TypeHelper.GetFbType(type, true);
field.SubType = descriptor.SubType;
field.DbValue.Value = value;
field.Length = descriptor.Length;
byte[] buffer = field.DbValue.GetBytes();
descriptor.Data = Marshal.AllocHGlobal(buffer.Length);
Marshal.Copy(buffer, 0, descriptor.Data, buffer.Length);
return this.MarshalManagedToNative(descriptor);
}
示例10: FesDatabase
public FesDatabase(string dllName, Charset charset)
{
_fbClient = FbClientFactory.GetFbClient(dllName);
_charset = (charset != null ? charset : Charset.DefaultCharset);
_dialect = 3;
_packetSize = 8192;
_statusVector = new IntPtr[IscCodes.ISC_STATUS_LENGTH];
}
示例11: 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);
}
示例12: ReadString
public string ReadString(Charset charset)
{
return this.ReadString(charset, this.ReadInt32());
}
示例13: MarshalNativeToManaged
public static Descriptor MarshalNativeToManaged(Charset charset, IntPtr pNativeData, bool fetching)
{
// Obtain XSQLDA information
var xsqlda = (XSQLDA)Marshal.PtrToStructure(pNativeData, typeof(XSQLDA));
// Create a new Descriptor
var descriptor = new Descriptor(xsqlda.sqln) { ActualCount = xsqlda.sqld };
// Obtain XSQLVAR members information
var xsqlvar = new XSQLVAR();
for (var i = 0; i < xsqlda.sqln; i++)
{
var ptr = GetIntPtr(pNativeData, ComputeLength(i));
MarshalXSQLVARNativeToManaged(ptr, xsqlvar);
// Map XSQLVAR information to Descriptor
descriptor[i].DataType = xsqlvar.sqltype;
descriptor[i].NumericScale = xsqlvar.sqlscale;
descriptor[i].SubType = xsqlvar.sqlsubtype;
descriptor[i].Length = xsqlvar.sqllen;
// Decode sqlind value
descriptor[i].NullFlag = xsqlvar.sqlind == IntPtr.Zero
? (short)0
: Marshal.ReadInt16(xsqlvar.sqlind);
// Set value
if (fetching)
{
if (descriptor[i].NullFlag != -1)
{
descriptor[i].SetValue(GetBytes(xsqlvar));
}
}
descriptor[i].Name = GetString(charset, xsqlvar.sqlname, xsqlvar.sqlname_length);
descriptor[i].Relation = GetString(charset, xsqlvar.relname, xsqlvar.relname_length);
descriptor[i].Owner = GetString(charset, xsqlvar.ownername, xsqlvar.ownername_length);
descriptor[i].Alias = GetString(charset, xsqlvar.aliasname, xsqlvar.aliasname_length);
}
return descriptor;
}
示例14: GetStringBuffer
private byte[] GetStringBuffer(Charset charset, string value)
{
byte[] buffer = new byte[32];
charset.GetBytes(value, 0, value.Length, buffer, 0);
return buffer;
}
示例15: BuildDescriptor
private ParamDsc BuildDescriptor(Charset charset, object value)
{
ParamDsc descriptor = new ParamDsc();
if (value == null || value == DBNull.Value)
{
descriptor.Flags |= IscCodes.DSC_null;
}
else
{
this.SetDscType(ref descriptor, value);
}
if (descriptor.Type == IscCodes.dtype_cstring || descriptor.Type == IscCodes.dtype_varying)
{
descriptor.SubType = (short)charset.Identifier;
}
return descriptor;
}