本文整理汇总了C#中IConnection.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# IConnection.GetType方法的具体用法?C# IConnection.GetType怎么用?C# IConnection.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IConnection
的用法示例。
在下文中一共展示了IConnection.GetType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Build
public IConnectionWriter Build(IConnection connection)
{
Type connectionType = connection.GetType();
lock (connectionToWriterTypeMap)
{
if (!connectionToWriterTypeMap.ContainsKey(connectionType))
{
logger.Log(LogLevels.Warning, "Connection type {0} does not have an associated ConnectionWriter. Using Default Writer", connectionType.Name);
return new DefaultConnectionWriter(connection);
}
Type writerType = connectionToWriterTypeMap[connectionType];
return Activator.CreateInstance(writerType, connection) as IConnectionWriter;
}
}
示例2: SetDefaults
/// <summary>
/// Sets the defaults to use when creating a new connection for a particular protocol.
/// </summary>
/// <param name="defaults">Default connection data to use when creating a new connection for the protocol.</param>
public static void SetDefaults(IConnection defaults)
{
if (_defaults == null)
InitializeDefaults();
// Get the protocol for this connection type
IProtocol protocol = _protocols.First(pair => pair.Value.ConnectionType == defaults.GetType()).Value;
_defaults[protocol.GetType()] = defaults;
SaveDefaults();
}
示例3: CreateOptionsForm
/// <summary>
/// Opens the UI to enter data for establishing <paramref name="connection"/> (i.e. host, username, password, etc.).
/// </summary>
/// <param name="connection">Connection that we want the options UI for.</param>
/// <returns>The UI to enter data for establishing <paramref name="connection"/> (i.e. host, username, password, etc.).</returns>
public static Form CreateOptionsForm(IConnection connection)
{
return _protocols.First(pair => pair.Value.ConnectionType.Name == connection.GetType().Name).Value.GetOptionsForm(connection);
}
示例4: GetProtocol
/// <summary>
/// Gets the protocol for a particular <paramref name="connection"/>.
/// </summary>
/// <param name="connection">Connection that we want the protocol for.</param>
/// <returns>Protocol associated with <paramref name="connection"/>.</returns>
public static IProtocol GetProtocol(IConnection connection)
{
return _protocols.FirstOrDefault(p => p.Value.ConnectionType == connection.GetType()).Value;
}
示例5: CreateConnectionForm
/// <summary>
/// Opens the UI to use to establish the <paramref name="connection"/>.
/// </summary>
/// <param name="connection">Connection that we want the UI for.</param>
/// <param name="containerPanel">Container panel that will house the <paramref name="connection"/>'s UI.</param>
/// <returns>The UI form to use to establish the <paramref name="connection"/>.</returns>
public static BaseConnectionForm CreateConnectionForm(IConnection connection, Panel containerPanel)
{
return _protocols.First(pair => pair.Value.ConnectionType.Name == connection.GetType().Name).Value.CreateConnectionForm(connection, containerPanel);
}