public static string ToSqlString(this ConnectFlags flag) { switch (flag) { case ConnectFlags.And: return(" AND "); case ConnectFlags.Or: return(" OR "); case ConnectFlags.Group: return(" ("); case ConnectFlags.EndGroup: return(") "); case ConnectFlags.AndGroup: return(" AND ("); case ConnectFlags.OrGroup: return(" OR ("); default: return(string.Empty); } }
public ulong Connect(string signalSpec, Func <object[], object> callback, ConnectFlags flags = default(ConnectFlags)) { if (callback == null) { throw new ArgumentNullException(nameof(callback)); } using (var closure = new Closure(callback)) { return(Connect(signalSpec, closure, flags)); } }
ulong Connect(string signalSpec, Closure closure, ConnectFlags flags) { if (signalSpec == null) { throw new ArgumentNullException(nameof(signalSpec)); } if (closure == null) { throw new ArgumentNullException(nameof(closure)); } var signalSpecPtr = GMarshal.StringToUtf8Ptr(signalSpec); var ret = g_signal_connect_closure(Handle, signalSpecPtr, closure.Handle, flags); GMarshal.Free(signalSpecPtr); return(ret); }
/// <summary> /// Expand a hostname and parameters into a host string that ws3270 understands. /// </summary> /// <param name="host">Hostname, can be symbolic or numeric.</param> /// <param name="port">TCP port number.</param> /// <param name="lus">Set of LU names to try to connect to.</param> /// <param name="flags">Connection flags (SSL, etc.).</param> /// <returns>Encoded host string.</returns> /// <remarks>This method is public for unit testing purposes only.</remarks> public string ExpandHostName(string host, string port = null, IEnumerable <string> lus = null, ConnectFlags flags = ConnectFlags.None) { string hostString = string.Empty; // Map the symbolic flags onto options. ConnectFlags thisConnectFlags = (flags != ConnectFlags.None) ? flags : this.Config.DefaultConnectFlags; for (int i = 0; i < FlagsTranslate.Length; i++) { if ((thisConnectFlags & (ConnectFlags)(1 << i)) != 0) { hostString += FlagsTranslate.Substring(i, 1) + ":"; } } // Add the LUs. if (lus != null) { foreach (string lu in lus) { this.CheckName(lu, ":"); } hostString += string.Join(",", lus) + "@"; } // Now the host name. this.CheckName(host); if (host.Contains(':')) { hostString += "[" + host + "]"; } else { hostString += host; } // Add the port. if (!string.IsNullOrEmpty(port)) { this.CheckName(port, ":."); hostString += ":" + port; } return(QuoteString(hostString)); }
public void Serializes_Connect(ConnectFlags flags) { ushort keepAlive = BitConverter.ToUInt16(Guid.NewGuid().ToByteArray(), 0); string clientId = Guid.NewGuid().ToString(); var packet = new Connect { Flags = flags, KeepAlive = keepAlive, ClientId = clientId }; var expected = CreateConnectHeader(packet); SetRemainingLength(expected); MqttSerializer.Serialize(bufferWriter, packet); VerifySerialization(expected.ToArray()); }
public static PhpResource mysql_connect(Context ctx, string server = null, string username = null, string password = null, bool new_link = false, ConnectFlags client_flags = ConnectFlags.None) { var config = ctx.Configuration.Get <MySqlConfiguration>(); Debug.Assert(config != null); var connection_string = config.ConnectionString ?? BuildConnectionString(config, ref server, config.Port, username, password, client_flags).ToString(); bool success; var connection = MySqlConnectionManager.GetInstance(ctx) .CreateConnection(connection_string, new_link, -1, out success); if (success) { connection.Server = server; } else { connection = null; } // return(connection); }
static extern NativeULong g_signal_connect_closure(IntPtr obj, IntPtr detailedSignal, IntPtr closure, ConnectFlags flags);
public ConnectAttribute(string nodePath, string signal, Godot.Collections.Array binds, ConnectFlags flags) { path = nodePath; sig = signal; f = (uint)flags; b = binds; }
protected void WriteConnectFlags(Stream stream) { ConnectFlags.WriteTo(stream); }
private void ConnectOneShotCallback(string callbackMethod, Godot.Collections.Array args = null, ConnectFlags flags = 0) { uint uIntFlags = (uint)(ConnectFlags.Oneshot | flags); fadeAnimationPlayer.Connect("animation_finished", this, callbackMethod, args, uIntFlags); }
public static PhpResource Connect(string server, string user, string password, bool newLink, ConnectFlags flags) { return Connect(server, user, password, newLink, flags, false); }
private static PhpResource Connect(string server, string user, string password, bool newLink, ConnectFlags flags, bool persistent) { //// MYSQL_CLIENT_IGNORE_SPACE is not supported, throw a warning: //if ((flags & ConnectFlags.IgnoreSpace) != 0) PhpException.ArgumentValueNotSupported("flags"); // persistent connections are treated as transient, a warning is issued: if (persistent) PhpException.FunctionNotSupported(PhpError.Notice); MySqlLocalConfig local = MySqlConfiguration.Local; MySqlGlobalConfig global = MySqlConfiguration.Global; string connection_string = BuildConnectionString(local, global, server, user, password, flags); bool success; PhpMyDbConnection connection = (PhpMyDbConnection)manager.OpenConnection(connection_string, newLink, global.MaxConnections, out success); if (!success) { if (connection != null) { UpdateConnectErrorInfo(connection); connection = null; } return null; } connection.SetServer(server); return connection; }
private static string BuildConnectionString(MySqlLocalConfig local, MySqlGlobalConfig global, string server, string user, string password, ConnectFlags flags) { // connection strings: if (server == null && user == null && password == null && flags == ConnectFlags.None && !string.IsNullOrEmpty(local.ConnectionString)) return local.ConnectionString; // TODO: local.ConnectionStringName // build connection string: string pipe_name = null; int port = -1; if (server != null) ParseServerName(ref server, out port, out pipe_name); else server = local.Server; if (port == -1) port = local.Port; if (user == null) user = local.User; if (password == null) password = local.Password; // build the connection string to be used with MySQL Connector/.NET // see http://dev.mysql.com/doc/refman/5.5/en/connector-net-connection-options.html return PhpMyDbConnection.BuildConnectionString( server, user, password, String.Format("allowzerodatetime=true;allow user variables=true;connect timeout={0};Port={1};SSL Mode={2};Use Compression={3}{4}{5};Max Pool Size={6}", (local.ConnectTimeout > 0) ? local.ConnectTimeout : Int32.MaxValue, port, (flags & ConnectFlags.SSL) != 0 ? "Preferred" : "None", // (since Connector 6.2.1.) ssl mode={None|Preferred|Required|VerifyCA|VerifyFull} // (Jakub) use ssl={true|false} has been deprecated (flags & ConnectFlags.Compress) != 0 ? "true" : "false", // Use Compression={true|false} (pipe_name != null) ? ";Pipe=" + pipe_name : null, // Pipe={...} (flags & ConnectFlags.Interactive) != 0 ? ";Interactive=true" : null, // Interactive={true|false} global.MaxPoolSize // Max Pool Size=100 ) ); }
public static PhpResource PersistentConnect(string server, string user, string password, bool newLink, ConnectFlags flags) { return Connect(server, user, password, newLink, flags, true); }
public static PhpResource mysql_pconnect(Context ctx, string server = null, string username = null, string password = null, bool new_link = false, ConnectFlags client_flags = ConnectFlags.None) { return(mysql_connect(ctx, server, username, password, new_link, client_flags | ConnectFlags.Pooling)); }
/// <summary> /// Connect to a host. Asynchronous version. /// </summary> /// <param name="host">Host name.</param> /// <param name="port">Optional TCP port number or service name.</param> /// <param name="lu">Optional set of LU names to try to connect to.</param> /// <param name="flags">Connection flags (SSL, etc.).</param> /// <returns>Task returning success/failure and failure text.</returns> /// <exception cref="InvalidOperationException">Session is not started.</exception> /// <exception cref="X3270ifCommandException"><see cref="ExceptionMode"/> is enabled and the command fails.</exception> /// <exception cref="ArgumentNullException"><paramref name="host"/> is null.</exception> /// <exception cref="ArgumentException"><paramref name="host"/>, <paramref name="port"/> or <paramref name="lu"/> contain invalid characters.</exception> public async Task <IoResult> ConnectAsync(string host, string port = null, IEnumerable <string> lu = null, ConnectFlags flags = ConnectFlags.None) { if (host == null) { throw new ArgumentNullException("host"); } if (string.IsNullOrEmpty(host)) { throw new ArgumentException("host"); } return(await this.IoAsync("Connect(" + this.ExpandHostName(host, port, lu, flags) + ")").ConfigureAwait(continueOnCapturedContext: false)); }
internal static MySqlConnectionStringBuilder BuildConnectionString(MySqlConfiguration config, ref string server, int defaultport = 3306, string user = null, string password = null, ConnectFlags flags = ConnectFlags.None) { // build connection string: string pipe_name = null; int port = -1; if (server != null) { ParseServerName(ref server, out port, out pipe_name); } else { server = config.Server; } if (port == -1) { port = defaultport > 0 ? defaultport : config.Port; } if (user == null) { user = config.User; } if (password == null) { password = config.Password; } // var builder = new MySqlConnectionStringBuilder() { Server = server, UserID = user, Password = password, //Database = dbname, AllowZeroDateTime = true, AllowUserVariables = true, AllowPublicKeyRetrieval = true, Port = (uint)port, SslMode = (flags & ConnectFlags.SSL) != 0 ? MySqlSslMode.Preferred : MySqlSslMode.None, UseCompression = (flags & ConnectFlags.Compress) != 0, MaximumPoolSize = (uint)config.MaxPoolSize, Pooling = (flags & ConnectFlags.Pooling) != 0, }; // optional: if (pipe_name != null) { builder.PipeName = pipe_name; } if ((flags & ConnectFlags.Interactive) != 0) { builder.InteractiveSession = true; } if (config.ConnectTimeout > 0) { builder.ConnectionTimeout = (uint)config.ConnectTimeout; } if (config.DefaultCommandTimeout >= 0) { builder.DefaultCommandTimeout = (uint)config.DefaultCommandTimeout; } // return(builder); }
/// <summary> /// Connect to a host. /// </summary> /// <param name="host">Host name.</param> /// <param name="port">Optional TCP port number or service name.</param> /// <param name="lu">Optional set of LU names to try to connect to.</param> /// <param name="flags">Connection flags (SSL, etc.).</param> /// <returns>Success/failure and failure text.</returns> /// <exception cref="InvalidOperationException">Session is not started.</exception> /// <exception cref="X3270ifCommandException"><see cref="ExceptionMode"/> is enabled and the command fails.</exception> /// <exception cref="ArgumentNullException"><paramref name="host"/> is null.</exception> /// <exception cref="ArgumentException"><paramref name="host"/>, <paramref name="port"/> or <paramref name="lu"/> contain invalid characters.</exception> public IoResult Connect(string host, string port = null, IEnumerable <string> lu = null, ConnectFlags flags = ConnectFlags.None) { try { return(this.ConnectAsync(host, port, lu, flags).Result); } catch (AggregateException e) { throw e.InnerException; } }
internal static string BuildConnectionString(MySqlConfiguration config, ref string server, string user, string password, ConnectFlags flags, int connectiontimeout = 0) { // connection strings: if (server == null && user == null && password == null && flags == ConnectFlags.None && !string.IsNullOrEmpty(config.ConnectionString)) { return(config.ConnectionString); } // TODO: local.ConnectionStringName // build connection string: string pipe_name = null; int port = -1; if (server != null) { ParseServerName(ref server, out port, out pipe_name); } else { server = config.Server; } if (port == -1) { port = config.Port; } if (user == null) { user = config.User; } if (password == null) { password = config.Password; } // build the connection string to be used with MySqlConnector // see https://mysql-net.github.io/MySqlConnector/connection-options/ and http://dev.mysql.com/doc/refman/5.5/en/connector-net-connection-options.html return(BuildConnectionString( server, user, password, string.Format("allowzerodatetime=true;allow user variables=true;connect timeout={0};Port={1};SSL Mode={2};Use Compression={3}{4}{5};Max Pool Size={6}{7}", (connectiontimeout > 0) ? connectiontimeout : (config.ConnectTimeout > 0) ? config.ConnectTimeout : 15, port, (flags & ConnectFlags.SSL) != 0 ? "Preferred" : "None", // (since Connector 6.2.1.) ssl mode={None|Preferred|Required|VerifyCA|VerifyFull} // (Jakub) use ssl={true|false} has been deprecated (flags & ConnectFlags.Compress) != 0 ? "true" : "false", // Use Compression={true|false} (pipe_name != null) ? ";Pipe=" + pipe_name : null, // Pipe={...} (flags & ConnectFlags.Interactive) != 0 ? ";Interactive=true" : null, // Interactive={true|false} config.MaxPoolSize, // Max Pool Size=100 (config.DefaultCommandTimeout >= 0) ? ";DefaultCommandTimeout=" + config.DefaultCommandTimeout : null ) )); }
public ConnectAttribute(string nodePath, string signal, ConnectFlags flags) { path = nodePath; sig = signal; f = (uint)flags; }