本文整理汇总了C#中ConnectionMode类的典型用法代码示例。如果您正苦于以下问题:C# ConnectionMode类的具体用法?C# ConnectionMode怎么用?C# ConnectionMode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConnectionMode类属于命名空间,在下文中一共展示了ConnectionMode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConnectToServer
public static void ConnectToServer(ConnectionInfo ConnectionInfo, ConnectionMode ConnectionMode, String[] Params)
{
if (ConnectionInfo.Hostname != "") {
Log.AddStatusText("Attempting to resolve hostname: " + ConnectionInfo.Hostname);
IPHostEntry hostInfo = Dns.GetHostEntry(ConnectionInfo.Hostname);
if (hostInfo.AddressList.Length > 0) {
ConnectionInfo.IPAddress = hostInfo.AddressList[0].ToString();
Log.AddStatusText("Hostname (" + ConnectionInfo.Hostname + ") resolved to " + ConnectionInfo.IPAddress + ".");
}
}
serverConnection = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
IPEndPoint connectionEndpoint = new IPEndPoint(IPAddress.Parse(ConnectionInfo.IPAddress), ConnectionInfo.StreamPort);
try {
serverConnection.Connect(connectionEndpoint);
} catch (SocketException Se) {
if (Se.ErrorCode == 10061) {
Log.AddStatusText("Stream server @ " + ConnectionInfo.IPAddress + ":" + ConnectionInfo.StreamPort + " refused connection.");
MessageBox.Show("The Stream Server refused connection. Is the server running? Are ports forwarded?");
}
}
if (serverConnection.Connected) {
String tempCreate = Protocol.CreateSTREAMSONG(Params[0]);
Console.WriteLine("To ServerStream:\t" + tempCreate);
serverConnection.Send(Encoding.UTF8.GetBytes(tempCreate + "\x4"));
WaitForData(serverConnection);
} else {
Forms.MainFrm.UpdateStatusLabel("Ready");
}
}
示例2: MongoUrlBuilder
// constructors
/// <summary>
/// Creates a new instance of MongoUrlBuilder.
/// </summary>
public MongoUrlBuilder()
{
_authenticationMechanism = MongoDefaults.AuthenticationMechanism;
_authenticationSource = null;
_connectionMode = ConnectionMode.Automatic;
_connectTimeout = MongoDefaults.ConnectTimeout;
_databaseName = null;
_fsync = null;
_guidRepresentation = MongoDefaults.GuidRepresentation;
_ipv6 = false;
_journal = null;
_maxConnectionIdleTime = MongoDefaults.MaxConnectionIdleTime;
_maxConnectionLifeTime = MongoDefaults.MaxConnectionLifeTime;
_maxConnectionPoolSize = MongoDefaults.MaxConnectionPoolSize;
_minConnectionPoolSize = MongoDefaults.MinConnectionPoolSize;
_password = null;
_readPreference = null;
_replicaSetName = null;
_servers = null;
_slaveOk = null;
_socketTimeout = MongoDefaults.SocketTimeout;
_username = null;
_useSsl = false;
_verifySslCertificate = true;
_w = null;
_waitQueueMultiple = MongoDefaults.WaitQueueMultiple;
_waitQueueSize = MongoDefaults.WaitQueueSize;
_waitQueueTimeout = MongoDefaults.WaitQueueTimeout;
_wTimeout = null;
}
示例3: MongoServerSettings
public MongoServerSettings(
ConnectionMode connectionMode,
TimeSpan connectTimeout,
MongoCredentials defaultCredentials,
TimeSpan maxConnectionIdleTime,
TimeSpan maxConnectionLifeTime,
int maxConnectionPoolSize,
int minConnectionPoolSize,
string replicaSetName,
SafeMode safeMode,
IEnumerable<MongoServerAddress> servers,
bool slaveOk,
TimeSpan socketTimeout,
int waitQueueSize,
TimeSpan waitQueueTimeout
)
{
this.connectionMode = connectionMode;
this.connectTimeout = connectTimeout;
this.defaultCredentials = defaultCredentials;
this.maxConnectionIdleTime = maxConnectionIdleTime;
this.maxConnectionLifeTime = maxConnectionLifeTime;
this.maxConnectionPoolSize = maxConnectionPoolSize;
this.minConnectionPoolSize = minConnectionPoolSize;
this.replicaSetName = replicaSetName;
this.safeMode = safeMode;
this.servers = servers;
this.slaveOk = slaveOk;
this.socketTimeout = socketTimeout;
this.waitQueueSize = waitQueueSize;
this.waitQueueTimeout = waitQueueTimeout;
}
示例4: Connector
public Connector(ConnectionMode mode, Direction dir, Vector2 position)
{
enabled = false;
this.mode = mode;
this.dir = dir;
this.position = position;
}
示例5: MongoServerSettings
// constructors
/// <summary>
/// Creates a new instance of MongoServerSettings. Usually you would use a connection string instead.
/// </summary>
public MongoServerSettings()
{
_connectionMode = ConnectionMode.Automatic;
_connectTimeout = MongoDefaults.ConnectTimeout;
_credentialsStore = new MongoCredentialsStore();
_defaultCredentials = null;
_guidRepresentation = MongoDefaults.GuidRepresentation;
_ipv6 = false;
_maxConnectionIdleTime = MongoDefaults.MaxConnectionIdleTime;
_maxConnectionLifeTime = MongoDefaults.MaxConnectionLifeTime;
_maxConnectionPoolSize = MongoDefaults.MaxConnectionPoolSize;
_minConnectionPoolSize = MongoDefaults.MinConnectionPoolSize;
_readPreference = ReadPreference.Primary;
_replicaSetName = null;
_secondaryAcceptableLatency = MongoDefaults.SecondaryAcceptableLatency;
_servers = new List<MongoServerAddress> { new MongoServerAddress("localhost") };
_socketTimeout = MongoDefaults.SocketTimeout;
_useSsl = false;
_verifySslCertificate = true;
_waitQueueSize = MongoDefaults.ComputedWaitQueueSize;
_waitQueueTimeout = MongoDefaults.WaitQueueTimeout;
#pragma warning disable 612, 618
_writeConcern = MongoDefaults.SafeMode.WriteConcern;
#pragma warning restore
}
示例6: MongoUrlBuilder
// constructors
/// <summary>
/// Creates a new instance of MongoUrlBuilder.
/// </summary>
public MongoUrlBuilder()
{
_connectionMode = ConnectionMode.Automatic;
_connectTimeout = MongoDefaults.ConnectTimeout;
_databaseName = null;
_defaultCredentials = null;
_fsync = null;
_guidRepresentation = MongoDefaults.GuidRepresentation;
_ipv6 = false;
_journal = null;
_maxConnectionIdleTime = MongoDefaults.MaxConnectionIdleTime;
_maxConnectionLifeTime = MongoDefaults.MaxConnectionLifeTime;
_maxConnectionPoolSize = MongoDefaults.MaxConnectionPoolSize;
_minConnectionPoolSize = MongoDefaults.MinConnectionPoolSize;
_readPreference = null;
_replicaSetName = null;
_secondaryAcceptableLatency = MongoDefaults.SecondaryAcceptableLatency;
_servers = null;
_slaveOk = null;
_socketTimeout = MongoDefaults.SocketTimeout;
_useSsl = false;
_verifySslCertificate = true;
_w = null;
_waitQueueMultiple = MongoDefaults.WaitQueueMultiple;
_waitQueueSize = MongoDefaults.WaitQueueSize;
_waitQueueTimeout = MongoDefaults.WaitQueueTimeout;
_wTimeout = null;
}
示例7: CreateConnectionPolicy
static ConnectionPolicy CreateConnectionPolicy(ConnectionMode connectionMode, Protocol protocol)
{
return new ConnectionPolicy
{
ConnectionMode = connectionMode,
ConnectionProtocol = protocol
};
}
示例8: ServerInfo
/// <summary>
/// Public constructor for createing a Server object
/// </summary>
/// <param name="iSocket">Socket associated with Server object</param>
/// <param name="iServerInfoIndex">Index number of the associated Server object</param>
public ServerInfo(Socket iSocket, int iServerInfoIndex, ConnectionInfo iConnectionInfo, ConnectionMode iConnectionMode)
{
Socket = iSocket;
Index = iServerInfoIndex;
ConnectionInfo = iConnectionInfo;
ConnectionMode = iConnectionMode;
ConnectionStatus = ConnectionStatus.Pending;
OnServerConnect();
}
示例9: WlanConnectionNotificationEventArgs
internal WlanConnectionNotificationEventArgs(WlanInternNotificationData data, WlanInternNotificationConnectionData c)
{
Source = data.notificationSource;
Code = data.NotificationCode;
BssType = c.dot11BssType;
ProfileName = c.profileName;
ProfileXml = c.profileXml;
SecurityEnabled = c.securityEnabled;
ConnectionMode = c.ConnectionMode;
ReasonCode = c.wlanReasonCode;
Ssid = c.Dot11Ssid.GetSsid();
}
示例10: ClusterKey
// constructors
public ClusterKey(
string applicationName,
Action<ClusterBuilder> clusterConfigurator,
ConnectionMode connectionMode,
TimeSpan connectTimeout,
IReadOnlyList<MongoCredential> credentials,
TimeSpan heartbeatInterval,
TimeSpan heartbeatTimeout,
bool ipv6,
TimeSpan localThreshold,
TimeSpan maxConnectionIdleTime,
TimeSpan maxConnectionLifeTime,
int maxConnectionPoolSize,
int minConnectionPoolSize,
string replicaSetName,
IReadOnlyList<MongoServerAddress> servers,
TimeSpan serverSelectionTimeout,
TimeSpan socketTimeout,
SslSettings sslSettings,
bool useSsl,
bool verifySslCertificate,
int waitQueueSize,
TimeSpan waitQueueTimeout)
{
_applicationName = applicationName;
_clusterConfigurator = clusterConfigurator;
_connectionMode = connectionMode;
_connectTimeout = connectTimeout;
_credentials = credentials;
_heartbeatInterval = heartbeatInterval;
_heartbeatTimeout = heartbeatTimeout;
_ipv6 = ipv6;
_localThreshold = localThreshold;
_maxConnectionIdleTime = maxConnectionIdleTime;
_maxConnectionLifeTime = maxConnectionLifeTime;
_maxConnectionPoolSize = maxConnectionPoolSize;
_minConnectionPoolSize = minConnectionPoolSize;
_receiveBufferSize = __defaultReceiveBufferSize; // TODO: add ReceiveBufferSize to MongoServerSettings?
_replicaSetName = replicaSetName;
_sendBufferSize = __defaultSendBufferSize; // TODO: add SendBufferSize to MongoServerSettings?
_servers = servers;
_serverSelectionTimeout = serverSelectionTimeout;
_socketTimeout = socketTimeout;
_sslSettings = sslSettings;
_useSsl = useSsl;
_verifySslCertificate = verifySslCertificate;
_waitQueueSize = waitQueueSize;
_waitQueueTimeout = waitQueueTimeout;
_hashCode = CalculateHashCode();
}
示例11: MongoUrl
public MongoUrl(
string url
)
{
var builder = new MongoUrlBuilder(url);
this.url = builder.ToString(); // keep canonical form
this.credentials = builder.Credentials;
this.servers = builder.Servers;
this.databaseName = builder.DatabaseName;
this.connectionMode = builder.ConnectionMode;
this.replicaSetName = builder.ReplicaSetName;
this.safeMode = builder.SafeMode ?? SafeMode.False; // never null
this.slaveOk = builder.SlaveOk;
}
示例12: GetAddress
public string GetAddress(ConnectionMode mode)
{
switch (mode)
{
case ConnectionMode.Local:
return LocalAddress;
case ConnectionMode.Manual:
return ManualAddress;
case ConnectionMode.Remote:
return RemoteAddress;
default:
throw new ArgumentException("Unexpected ConnectionMode");
}
}
示例13: MongoServerSettings
/// <summary>
/// Creates a new instance of MongoServerSettings. Usually you would use a connection string instead.
/// </summary>
public MongoServerSettings() {
connectionMode = ConnectionMode.Direct;
connectTimeout = MongoDefaults.ConnectTimeout;
defaultCredentials = null;
ipv6 = false;
maxConnectionIdleTime = MongoDefaults.MaxConnectionIdleTime;
maxConnectionLifeTime = MongoDefaults.MaxConnectionLifeTime;
maxConnectionPoolSize = MongoDefaults.MaxConnectionPoolSize;
minConnectionPoolSize = MongoDefaults.MinConnectionPoolSize;
replicaSetName = null;
safeMode = MongoDefaults.SafeMode;
servers = null;
slaveOk = false;
socketTimeout = MongoDefaults.SocketTimeout;
waitQueueSize = MongoDefaults.ComputedWaitQueueSize;
waitQueueTimeout = MongoDefaults.WaitQueueTimeout;
}
示例14: CreateContext
/// <summary>
/// Creates a context with an optionally open database and SMTP connection.
/// </summary>
/// <param name="openConnection">True if a database connection should be opened.</param>
/// <param name="beginTransaction">True if a transaction is required.</param>
/// <param name="openSmtp">True if an SMTP connection should be opened.</param>
/// <returns>A valid connection.</returns>
public Context CreateContext(ConnectionMode connectionMode, TransactionMode transactionMode)
{
var context = new Context()
{
ConnectionString = connectionString,
ConnectionMode = connectionMode,
TransactionMode = transactionMode,
UserGuid = userGuid,
UserName = userName,
};
context.ClusterProperty.Name = clusterName;
context.DomainProperty.Name = domainName;
context.FederationProperty.Name = federationName;
return context;
}
示例15: MongoServerSettings
// constructors
/// <summary>
/// Creates a new instance of MongoServerSettings. Usually you would use a connection string instead.
/// </summary>
public MongoServerSettings()
{
_connectionMode = ConnectionMode.Direct;
_connectTimeout = MongoDefaults.ConnectTimeout;
_defaultCredentials = null;
_guidRepresentation = MongoDefaults.GuidRepresentation;
_ipv6 = false;
_maxConnectionIdleTime = MongoDefaults.MaxConnectionIdleTime;
_maxConnectionLifeTime = MongoDefaults.MaxConnectionLifeTime;
_maxConnectionPoolSize = MongoDefaults.MaxConnectionPoolSize;
_minConnectionPoolSize = MongoDefaults.MinConnectionPoolSize;
_replicaSetName = null;
_safeMode = MongoDefaults.SafeMode;
_servers = null;
_slaveOk = false;
_socketTimeout = MongoDefaults.SocketTimeout;
_waitQueueSize = MongoDefaults.ComputedWaitQueueSize;
_waitQueueTimeout = MongoDefaults.WaitQueueTimeout;
}