本文整理汇总了C#中Npgsql.NpgsqlConnector类的典型用法代码示例。如果您正苦于以下问题:C# NpgsqlConnector类的具体用法?C# NpgsqlConnector怎么用?C# NpgsqlConnector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NpgsqlConnector类属于Npgsql命名空间,在下文中一共展示了NpgsqlConnector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Parse
public override void Parse(NpgsqlConnector context, NpgsqlParse parse)
{
NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, "Parse");
BufferedStream stream = new BufferedStream(context.Stream);
parse.WriteToStream(stream, context.Encoding);
stream.Flush();
}
示例2: Authenticate
public override void Authenticate(NpgsqlConnector context, byte[] password)
{
NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, "Authenticate");
NpgsqlPasswordPacket pwpck = new NpgsqlPasswordPacket(password);
pwpck.WriteToStream(context.Stream);
}
示例3: CancelRequest
public override void CancelRequest(NpgsqlConnector context)
{
NpgsqlCancelRequest CancelRequestMessage = new NpgsqlCancelRequest(context.BackEndKeyData);
CancelRequestMessage.WriteToStream(context.Stream);
context.Stream.Flush();
}
示例4: Open
public override void Open(NpgsqlConnector context)
{
NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, "Open");
TcpClient tcpc = new TcpClient();
tcpc.Connect(new IPEndPoint(ResolveIPHost(context.Host), context.Port));
Stream stream = tcpc.GetStream();
// If the PostgreSQL server has SSL connectors enabled Open SslClientStream if (response == 'S') {
if (context.SSL)
{
PGUtil.WriteInt32(stream, 8);
PGUtil.WriteInt32(stream,80877103);
// Receive response
Char response = (Char)stream.ReadByte();
if (response == 'S')
{
stream = new SslClientStream(
tcpc.GetStream(),
context.Host,
true,
Mono.Security.Protocol.Tls.SecurityProtocolType.Default
);
((SslClientStream)stream).ClientCertSelectionDelegate = new CertificateSelectionCallback(context.DefaultCertificateSelectionCallback);
((SslClientStream)stream).ServerCertValidationDelegate = new CertificateValidationCallback(context.DefaultCertificateValidationCallback);
((SslClientStream)stream).PrivateKeyCertSelectionDelegate = new PrivateKeySelectionCallback(context.DefaultPrivateKeySelectionCallback);
}
}
context.Stream = stream;
NpgsqlEventLog.LogMsg(resman, "Log_ConnectedTo", LogLevel.Normal, context.Host, context.Port);
ChangeState(context, NpgsqlConnectedState.Instance);
}
示例5: SyncEnum
public override IEnumerable<IServerResponseObject> SyncEnum(NpgsqlConnector context)
{
NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, "Sync");
_syncMessage.WriteToStream(context.Stream);
context.Stream.Flush();
return ProcessBackendResponsesEnum(context);
}
示例6: Close
public override void Close(NpgsqlConnector context)
{
NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, "Close");
Stream stream = context.Stream;
try
{
stream.WriteByte((byte) FrontEndMessageCode.Termination);
if (context.BackendProtocolVersion >= ProtocolVersion.Version3)
{
PGUtil.WriteInt32(stream, 4);
}
stream.Flush();
}
catch
{
//Error writting termination message to stream, nothing we can do.
}
try
{
stream.Close();
}
catch
{
}
context.Stream = null;
ChangeState(context, NpgsqlClosedState.Instance);
}
示例7: SendCopyData
/// <summary>
/// Sends given packet to server as a CopyData message.
/// Does not check for notifications! Use another thread for that.
/// </summary>
public override void SendCopyData(NpgsqlConnector context, byte[] buf, int off, int len)
{
Stream toServer = context.Stream;
toServer.WriteByte((byte) FrontEndMessageCode.CopyData);
PGUtil.WriteInt32(toServer, len + 4);
toServer.Write(buf, off, len);
}
示例8: Authenticate
public override void Authenticate(NpgsqlConnector context, string password)
{
NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, "Authenticate");
NpgsqlPasswordPacket pwpck = new NpgsqlPasswordPacket(password, context.BackendProtocolVersion);
BufferedStream stream = new BufferedStream(context.Stream);
pwpck.WriteToStream(stream);
stream.Flush();
}
示例9: Parse
public override void Parse(NpgsqlConnector context, NpgsqlParse parse)
{
NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, "Parse");
Stream stream = context.Stream;
parse.WriteToStream(stream);
//stream.Flush();
}
示例10: Startup
public override void Startup(NpgsqlConnector context,NpgsqlConnectionStringBuilder settings)
{
NpgsqlStartupPacket startupPacket = new NpgsqlStartupPacket(context.Database, context.UserName, settings);
startupPacket.WriteToStream(context.Stream);
context.RequireReadyForQuery = false;
ProcessAndDiscardBackendResponses(context);
}
示例11: Bind
public override void Bind(NpgsqlConnector context, NpgsqlBind bind)
{
NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, "Bind");
Stream stream = context.Stream;
bind.WriteToStream(stream);
//stream.Flush();
}
示例12: GetCopyData
/// <summary>
/// Called from NpgsqlOutStream.Read to read copy data from server.
/// </summary>
public override byte[] GetCopyData(NpgsqlConnector context)
{
// polling in COPY would take seconds on Windows
foreach (IServerResponseObject obj in ProcessBackendResponses_Ver_3(context))
{
if (obj is IDisposable)
{
(obj as IDisposable).Dispose();
}
}
return context.Mediator.ReceivedCopyData;
}
示例13: ExecuteBlindSuppressTimeout
internal static void ExecuteBlindSuppressTimeout(NpgsqlConnector connector, NpgsqlQuery query)
{
// Block the notification thread before writing anything to the wire.
using (var blocker = connector.BlockNotificationThread())
{
// Write the Query message to the wire.
connector.Query(query);
// Flush, and wait for and discard all responses.
connector.ProcessAndDiscardBackendResponses();
}
}
示例14: Startup
public override void Startup(NpgsqlConnector context,NpgsqlConnectionStringBuilder settings)
{
NpgsqlStartupPacket startupPacket = NpgsqlStartupPacket.BuildStartupPacket(context.BackendProtocolVersion,
context.Database, context.UserName, settings);
startupPacket.WriteToStream(context.Stream);
context.RequireReadyForQuery = false;
// This still makes part of the connection stablishment handling.
// So we use the connectiontimeout here too.
context.Mediator.CommandTimeout = context.ConnectionTimeout;
ProcessAndDiscardBackendResponses(context);
}
示例15: Startup
public override void Startup(NpgsqlConnector context)
{
NpgsqlStartupPacket startupPacket = new NpgsqlStartupPacket(296, //Not used.
context.BackendProtocolVersion, context.Database,
context.UserName, "", "", "");
startupPacket.WriteToStream(new BufferedStream(context.Stream));
context.RequireReadyForQuery = false;
// This still makes part of the connection stablishment handling.
// So we use the connectiontimeout here too.
context.Mediator.CommandTimeout = context.ConnectionTimeout;
context.Stream.Flush();
ProcessBackendResponses(context);
}