本文整理汇总了C#中IProtocol.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# IProtocol.GetType方法的具体用法?C# IProtocol.GetType怎么用?C# IProtocol.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IProtocol
的用法示例。
在下文中一共展示了IProtocol.GetType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetDefaults
/// <summary>
/// Gets the defaults to use when creating a new connection for a particular protocol.
/// </summary>
/// <param name="protocol">Protocol that we are to retrieve defaults for.</param>
/// <returns>Default connection data to use when creating a new connection for <paramref name="protocol"/>.</returns>
public static IConnection GetDefaults(IProtocol protocol)
{
if (_defaults == null)
InitializeDefaults();
return _defaults.ContainsKey(protocol.GetType())
? _defaults[protocol.GetType()]
: (IConnection) Activator.CreateInstance(_protocols[protocol.GetType()].ConnectionType);
}
示例2: _addBookmarkMenuItem_Click
/// <summary>
/// Handler method that's called when the user clicks a menu item under the "Add bookmark..." menu item. We create a new item in
/// <see cref="_bookmarksListView"/> with the proper icon for the protocol and open its label for editing.
/// </summary>
/// <param name="type">Protocol that the bookmark is being created for.</param>
private void _addBookmarkMenuItem_Click(IProtocol type)
{
// Create a new connection instance by cloning the protocol's default
IConnection connection = (IConnection) ConnectionFactory.GetDefaults(type.GetType()).Clone();
connection.Name = "New Connection";
// Add the bookmark to the current folder
if (_folderTreeNodes[FoldersTreeView.SelectedNode] != (_contextMenuItem as BookmarksFolder))
{
FoldersTreeView.SelectedNode = _folderTreeNodes.Single(n => n.Value == (_contextMenuItem as BookmarksFolder)).Key;
FoldersTreeView.SelectedNode.Expand();
}
_deferSort = true;
(_contextMenuItem as BookmarksFolder).Bookmarks.Add(connection);
_deferSort = false;
// Set the flag so that once the user is finished renaming the connection, we open the options for it
_showOptionsAfterItemLabelEdit = true;
ListViewItem newListItem = _listViewConnections.First(pair => pair.Value == connection).Key;
_bookmarksListView.SelectedIndices.Clear();
SortListView();
Save();
// Start the edit process for the new list item's name
newListItem.Selected = true;
newListItem.BeginEdit();
}