38 lines
874 B
C#
38 lines
874 B
C#
|
using System;
|
|||
|
using System.Collections;
|
|||
|
using System.Net;
|
|||
|
using System.Linq;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Text;
|
|||
|
using System.Security.Cryptography;
|
|||
|
|
|||
|
namespace SBRL.Utilities
|
|||
|
{
|
|||
|
public static class Utilities
|
|||
|
{
|
|||
|
public static IEnumerable<IPAddress> GetLocalIps()
|
|||
|
{
|
|||
|
IPHostEntry entries = Dns.GetHostEntry(Dns.GetHostName());
|
|||
|
return (from ipAddr in entries.AddressList
|
|||
|
where !IPAddress.IsLoopback(ipAddr)
|
|||
|
select ipAddr).ToList();
|
|||
|
}
|
|||
|
|
|||
|
public static string EscapeString(string str)
|
|||
|
{
|
|||
|
StringBuilder result = new StringBuilder(str);
|
|||
|
foreach(KeyValuePair<string, string> kvp in replacementPairs)
|
|||
|
result.Replace(kvp.Key, kvp.Value);
|
|||
|
|
|||
|
return result.ToString();
|
|||
|
}
|
|||
|
|
|||
|
private static Dictionary<string, string> replacementPairs = new Dictionary<string, string>()
|
|||
|
{
|
|||
|
["\n"] = @"\n",
|
|||
|
["\t"] = @"\t"
|
|||
|
};
|
|||
|
}
|
|||
|
}
|
|||
|
|