本文整理汇总了C#中Protocol.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Protocol.ToString方法的具体用法?C# Protocol.ToString怎么用?C# Protocol.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Protocol
的用法示例。
在下文中一共展示了Protocol.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OpenPort
/// <summary>
/// Opens a port with the UPnP protocol.
/// </summary>
/// <param name="PortNumber">The number of the port to add.</param>
/// <param name="protocol">The protocol used for the port.</param>
public static void OpenPort(int PortNumber, Protocol protocol)
{
NATUPNPLib.UPnPNATClass upnpnat = new NATUPNPLib.UPnPNATClass();
NATUPNPLib.IStaticPortMappingCollection mappings = upnpnat.StaticPortMappingCollection;
if (mappings != null)
{
mappings.Add(PortNumber, protocol.ToString(), PortNumber, Global.GetMyLocalIP(), true, "iKiwi");
Utilities.Log.Write("Opened the port " + PortNumber + " with the UPnP protocol", Utilities.Log.LogCategory.Info);
}
}
示例2: RemoveMapping
public bool RemoveMapping(int iExternalPort, Protocol eProtocol)
{
bool bResult = false;
mappings.Remove(iExternalPort, eProtocol.ToString());
return bResult;
}
示例3: EnsureProtocol
///<summary>
///Assesses a url and returns a url that is guaranteed to begin with the specified protocol
///</summary>
///<param name="url">The url to be checked for the protocol</param>
///<returns>A url that is guaranteed to begin with the specified protocol</returns>
///<remarks></remarks>
public static string EnsureProtocol(string url, Protocol protocol)
{
string output = url;
if (!string.IsNullOrEmpty(output) && !output.StartsWith(protocol + "://", StringComparison.OrdinalIgnoreCase))
output = string.Format("{0}://{1}", protocol.ToString().ToLower(), url);
return output;
}
示例4: AddMapping
public bool AddMapping(int iExternalPort, Protocol eProtocol, int iInternalPort, string sInternalClientIP, string sDescription)
{
bool bResult = false;
IStaticPortMapping oPortMapping = null;
oPortMapping = mappings.Add(iExternalPort, eProtocol.ToString(), iInternalPort, sInternalClientIP, true, sDescription);
if (oPortMapping != null)
{
}
return bResult;
}
示例5: ClosePort
/// <summary>
/// Closes a port with the UPnP protocol.
/// </summary>
/// <param name="PortNumber">The number of the port to close.</param>
/// <param name="protocol">The protocol used for the port.</param>
public static void ClosePort(int PortNumber, Protocol protocol)
{
NATUPNPLib.UPnPNATClass upnpnat = new NATUPNPLib.UPnPNATClass();
NATUPNPLib.IStaticPortMappingCollection mappings = upnpnat.StaticPortMappingCollection;
if (mappings != null)
{
mappings.Remove(PortNumber, protocol.ToString());
Utilities.Log.Write("Closed the port " + PortNumber + " with the UPnP protocol", Utilities.Log.LogCategory.Info);
}
}
示例6: HrdRequest
/// <summary>
/// Constructs HrdRequest
/// </summary>
/// <param name="issuer">The issuer url</param>
/// <param name="realm">Realm of the relying party</param>
/// <param name="protocol">Relying party protocol</param>
/// <param name="replyTo">Optional reply_to for the relying party</param>
/// <param name="context">Optional context for the request</param>
/// <param name="callback">Optional callback method. When specified the response will include java script to call this method.</param>
public HrdRequest(string issuer,
string realm,
Protocol protocol = Protocol.wsfederation,
string replyTo = null,
string context = null,
string callback = null)
{
uriBuilder = new UriBuilder(issuer);
parameters["protocol"] = protocol.ToString();
parameters["realm"] = realm;
parameters["version"] = Version;
AddParameterIfNotNull("reply_to", replyTo);
AddParameterIfNotNull("context", context);
AddParameterIfNotNull("callback", callback);
}
示例7: BuildRawMsg
public static string BuildRawMsg(Protocol p, string[] contents)
{
StringBuilder sb = new StringBuilder(MSG_START);
sb.Append(MSG_DELIMITER).Append(AppSetting.PROTOCOL_VERSION);
sb.Append(MSG_DELIMITER).Append(p.ToString());
int count = 0;
StringBuilder content = new StringBuilder();
foreach (string s in contents)
{
if (!string.IsNullOrEmpty(s))
{
content.Append(MSG_DELIMITER).Append(s);
count += 1;
}
}
sb.Append(MSG_DELIMITER).Append(count.ToString());
if (!string.IsNullOrEmpty(content.ToString()))
sb.Append(content.ToString());
sb.Append(MSG_DELIMITER);
return sb.ToString();
}
示例8: Imposter
public Imposter(int port, Protocol protocol, string name)
{
Port = port;
Protocol = protocol.ToString().ToLower();
Name = name;
}
示例9: GenerateResourcePath
/// <summary>
/// Returns the resource path for the given distribution, object, and protocol.
/// </summary>
private static string GenerateResourcePath(Protocol protocol,
string distributionDomain,
string path)
{
if (protocol == Protocol.http || protocol == Protocol.https)
{
return protocol.ToString() + "://" + distributionDomain + "/" + path;
}
else
{
return path;
}
}
示例10: javaEditor_OperationStarted
void javaEditor_OperationStarted(object sender, Protocol.Request e)
{
if (Root != null)
{
Root.Dispatcher.Invoke((Action)delegate()
{
Root.BusyProgressBar = true;
Root.BusyProgressMessage = e.ToString();
});
}
}
示例11: Exists
/// <summary>
/// Checks to see if a port exists in the mapping.
/// </summary>
/// <param name="port">The port to check.</param>
/// <param name="protocol">The protocol of the port [TCP/UDP]</param>
/// <exception cref="ApplicationException">This exception is thrown when UPnP is disabled.</exception>
/// <exception cref="ObjectDisposedException">This exception is thrown when this class has been disposed.</exception>
/// <exception cref="ArgumentException">This exception is thrown when the port [or protocol] is invalid.</exception>
/// <remarks></remarks>
public bool Exists(long port, Protocol protocol)
{
try
{
// Final check!
if (!_staticEnabled)
throw new ApplicationException(
"UPnP is not enabled, or there was an error with UPnP Initialization.");
Logger.Log(LogLevel.Info, "uPnP", "Checking if port is in use...");
// Begin checking
foreach (IStaticPortMapping mapping in _staticMapping)
{
// Compare
if (mapping.ExternalPort == port && mapping.Protocol.ToLower().Equals(protocol.ToString().ToLower()))
return true;
}
Logger.Log(LogLevel.Info, "uPnP", "ok: Port is not in use", port + ":" + protocol);
//Nothing!
return false;
}
catch (Exception ex)
{
Logger.Log(LogLevel.Warning, "uPnP", "Couldn't check if port mapping exists", ex.Message);
throw new Exception("Couldn't check if mapping exists!", ex);
}
}
示例12: Remove
/// <summary>
/// Removes a port mapping from the UPnP enabled device.
/// </summary>
/// <param name="port">The port to remove.</param>
/// <param name="protocol">The protocol of the port [TCP/UDP]</param>
/// <exception cref="ApplicationException">This exception is thrown when UPnP is disabled.</exception>
/// <exception cref="ObjectDisposedException">This exception is thrown when this class has been disposed.</exception>
/// <exception cref="ArgumentException">This exception is thrown when the port [or protocol] is invalid.</exception>
/// <remarks></remarks>
public static void Remove(int port, Protocol protocol)
{
if (_lastInstance == null) _lastInstance = new UPnP();
if (!UpnpEnabled)
throw new ApplicationException("UPnP is not enabled, or there was an error with UPnP Initialization.");
// Begin utilizing
if (!_lastInstance.Exists(port, protocol))
throw new ArgumentException("This mapping doesn't exist!", port + " : " + protocol);
// Okay, continue on
_lastInstance._staticMapping.Remove(port, protocol.ToString());
GetMapping(); //refresh
}
示例13: Add
/// <summary>
/// Adds a port mapping to the UPnP enabled device.
/// </summary>
/// <param name="localIp">The local IP address to map to.</param>
/// <param name="port">The port to forward.</param>
/// <param name="protocol">The protocol of the port [TCP/UDP]</param>
/// <param name="desc">A small description of the port.</param>
/// <exception cref="ApplicationException">This exception is thrown when UPnP is disabled.</exception>
/// <exception cref="ObjectDisposedException">This exception is thrown when this class has been disposed.</exception>
/// <exception cref="ArgumentException">This exception is thrown when any of the supplied arguments are invalid.</exception>
/// <remarks></remarks>
private void Add(string localIp, uint port, Protocol protocol, string desc)
{
// Begin utilizing
if (Exists(port, protocol))
throw new ArgumentException("This mapping aLocale.Tready exists!", port + " : " + protocol);
// Check
if (!IsPrivateIp(localIp))
throw new ArgumentException("This is not a local IP address!", "localIp");
// Final check!
if (!_staticEnabled)
throw new ApplicationException("UPnP is not enabled, or there was an error with UPnP Initialization.");
// Okay, continue on
_staticMapping.Add(Convert.ToInt32(port), protocol.ToString(), Convert.ToInt32(port), localIp, true, desc);
}
示例14: UpdatePorts
private void UpdatePorts(int port, Protocol protocol)
{
if (txtPorts.Text == "")
txtPorts.Text = protocol.ToString().ToUpper() + "/" + port.ToString() + ":\tMay be a hidden port.";
else
txtPorts.Text += Environment.NewLine + protocol.ToString().ToUpper() + "/" + port.ToString() + ":\tMay be a hidden port.";
}
示例15: UpdatePortLabel
private void UpdatePortLabel(int port, Protocol protocol)
{
lblPort.Text = "Port: " + protocol.ToString().ToUpper() + "/" + port.ToString();
}