本文整理汇总了C#中ConnectionMode类的典型用法代码示例。如果您正苦于以下问题:C# ConnectionMode类的具体用法?C# ConnectionMode怎么用?C# ConnectionMode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConnectionMode类属于命名空间,在下文中一共展示了ConnectionMode类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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");
}
}
开发者ID:SpectralCoding,项目名称:boobox-client,代码行数:29,代码来源:CommStream.cs
示例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;
}
开发者ID:wireclub,项目名称:mongo-csharp-driver,代码行数:34,代码来源:MongoUrlBuilder.cs
示例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;
}
开发者ID:Teun,项目名称:mongo-csharp-driver,代码行数:32,代码来源:MongoServerSettings.cs
示例4: Connector
public Connector(ConnectionMode mode, Direction dir, Vector2 position)
{
enabled = false;
this.mode = mode;
this.dir = dir;
this.position = position;
}
开发者ID:Baratock,项目名称:SynCLK,代码行数:7,代码来源:Connector.cs
示例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
}
开发者ID:tkellogg,项目名称:mongo-csharp-driver,代码行数:29,代码来源:MongoServerSettings.cs
示例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;
}
开发者ID:CloudMetal,项目名称:mongo-csharp-driver,代码行数:32,代码来源:MongoUrlBuilder.cs
示例7: CreateConnectionPolicy
static ConnectionPolicy CreateConnectionPolicy(ConnectionMode connectionMode, Protocol protocol)
{
return new ConnectionPolicy
{
ConnectionMode = connectionMode,
ConnectionProtocol = protocol
};
}
开发者ID:beachside-project,项目名称:Azure-DocumentDB-Client-Sample,代码行数:8,代码来源:DdbClinetFactory.cs
示例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();
}
开发者ID:SpectralCoding,项目名称:boobox-client,代码行数:14,代码来源:ServerInfo.cs
示例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();
}
开发者ID:cssack,项目名称:CsGlobals,代码行数:12,代码来源:WlanConnectionNotificationEventArgs.cs
示例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();
}
开发者ID:mfidemraizer,项目名称:mongo-csharp-driver,代码行数:52,代码来源:ClusterKey.cs
示例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;
}
开发者ID:kenegozi,项目名称:mongo-csharp-driver,代码行数:14,代码来源:MongoUrl.cs
示例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");
}
}
开发者ID:rezafouladian,项目名称:Emby,代码行数:14,代码来源:ServerInfo.cs
示例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;
}
开发者ID:ebix,项目名称:mongo-csharp-driver,代码行数:20,代码来源:MongoServerSettings.cs
示例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;
}
开发者ID:skyquery,项目名称:graywulf,代码行数:25,代码来源:ContextManager.cs
示例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;
}
开发者ID:purplecow,项目名称:mongo-csharp-driver,代码行数:23,代码来源:MongoServerSettings.cs
示例16: 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;
readPreference = ReadPreference.Primary;
socketTimeout = MongoDefaults.SocketTimeout;
waitQueueSize = MongoDefaults.ComputedWaitQueueSize;
waitQueueTimeout = MongoDefaults.WaitQueueTimeout;
}
开发者ID:kamaradclimber,项目名称:mongo-csharp-driver,代码行数:24,代码来源:MongoServerSettings.cs
示例17: Retrieve
/// <summary>
/// Function to retrieve registration repository.
/// </summary>
/// <param name="connectionMode">The connection mode.</param>
/// <returns>
/// Object of type IRegistrationRepository
/// </returns>
public static IRepository Retrieve(ConnectionMode connectionMode)
{
Workstation workstation = DIContainer.Instance.Resolve<Workstation>();
if (connectionMode == ConnectionMode.Offline)
{
workstation.LastConnectionMode = ConnectionMode.Offline;
return DIContainer.Instance.Resolve<IRepository>(OfflineRepository.InstanceName);
}
workstation.LastConnectionMode = ConnectionMode.Online;
if (string.IsNullOrEmpty(workstation.GangwayServiceBaseAddress))
{
// Retrieve configuration settings for on line mode.
Messenger.Instance.Notify(MessengerMessage.RetrieveConfigurationSettings);
}
return DIContainer.Instance.Resolve<IRepository>(OnlineRepository.InstanceName);
}
开发者ID:JaipurAnkita,项目名称:mastercode,代码行数:27,代码来源:GangwayRepositoryFactory.cs
示例18: 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;
_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;
_safeMode = MongoDefaults.SafeMode;
_servers = new List<MongoServerAddress> { new MongoServerAddress("localhost") };
_serversReadOnly = new ReadOnlyCollection<MongoServerAddress>(_servers);
_socketTimeout = MongoDefaults.SocketTimeout;
_waitQueueSize = MongoDefaults.ComputedWaitQueueSize;
_waitQueueTimeout = MongoDefaults.WaitQueueTimeout;
}
开发者ID:yfann,项目名称:mongo-csharp-driver,代码行数:25,代码来源:MongoServerSettings.cs
示例19: ConnectToServer
/// <summary>
/// Connect to a server.
/// </summary>
/// <param name="ConnectionInfo">ConnectionInfo object containing connection information</param>
/// <param name="ConnectionMode">Mode describing the type of connection</param>
/// <param name="Params">Optional params to be passed to the ServerInfo object</param>
public static void ConnectToServer(ConnectionInfo ConnectionInfo, ConnectionMode ConnectionMode, String[] Params)
{
if ((ConnectionMode != ConnectionMode.FirstConnect) && (ConnectionMode != ConnectionMode.SongRequest)) {
Forms.MainFrm.UpdateStatusLabel("Connecting to \"" + ConnectionInfo.Description + "\" (" + ConnectionMode.ToString() + " mode).");
}
Log.AddStatusText("Connecting to server (" + ConnectionMode.ToString() + " mode): " + ConnectionInfo.Description);
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.InfoPort);
try {
serverConnection.Connect(connectionEndpoint);
} catch (SocketException Se) {
if (Se.ErrorCode == 10061) {
ServerManager.SetOffline(ConnectionInfo.InternalGUID);
Log.AddStatusText("Info server @ " + ConnectionInfo.IPAddress + ":" + ConnectionInfo.InfoPort + " refused connection.");
if ((ConnectionMode != ConnectionMode.FirstConnect) && (ConnectionMode != ConnectionMode.OnlineTest) && (ConnectionMode != ConnectionMode.SongRequest)) {
MessageBox.Show("The Info Server refused connection. Is the server running? Are ports forwarded?");
}
if (ConnectionMode == ConnectionMode.OnlineTest) {
Forms.MainFrm.UpdateStatusLabel("Server \"" + ConnectionInfo.Description + "\" is offline. Song skipped.");
}
}
}
if (serverConnection.Connected) {
ServerInfo tempServerInfo = new ServerInfo(serverConnection, SocketCounter, ConnectionInfo, ConnectionMode);
if (Params.Length > 0) { tempServerInfo.ConnectionParams = Params; }
ServerInfoList.Add(tempServerInfo);
WaitForData(tempServerInfo);
Interlocked.Increment(ref SocketCounter);
} else {
Forms.MainFrm.UpdateStatusLabel("Ready");
}
}
开发者ID:SpectralCoding,项目名称:boobox-client,代码行数:46,代码来源:CommInfo.cs
示例20: Connect
public static bool Connect(ConnectionMode mode = ConnectionMode.Client)
{
if (IsConnected)
return true;
if (Server.ServerStartAttempts > 20 && Client.ConnectionAttempts > 20)
{
Log.Info("Failed to Connect too many times, Disabling Plugin");
AutoFollow.DisablePlugin();
}
if (ConnectionMode == ConnectionMode.Client)
{
Client.ClientInitialize();
}
else
{
Server.ServerInitialize();
}
return IsConnected;
}
开发者ID:dachidahu,项目名称:AutoFollow,代码行数:22,代码来源:Service.cs
注:本文中的ConnectionMode类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论