本文整理汇总了C#中System.IO.StreamReader.Split方法的典型用法代码示例。如果您正苦于以下问题:C# System.IO.StreamReader.Split方法的具体用法?C# System.IO.StreamReader.Split怎么用?C# System.IO.StreamReader.Split使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.StreamReader
的用法示例。
在下文中一共展示了System.IO.StreamReader.Split方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Cook
public ActionResult Cook(int id)
{
// Return the input stream to 0 as it has already been read
this.HttpContext.Request.InputStream.Position = 0;
var result = new System.IO.StreamReader(this.HttpContext.Request.InputStream).ReadToEnd();
// Manually remove unnessesary chars. No need for another lib for just that, is there
var selectedItems = result.Split(new char[] { '/', '"', '[', ']', ',' }, StringSplitOptions.RemoveEmptyEntries)
.Select(int.Parse)
.ToList();
var trainingId = int.Parse(this.Request.UrlReferrer.Segments[3]);
var userId = this.User.Identity.GetUserId();
int matches = this.userTrainings.Cook(userId, trainingId, id, selectedItems);
return this.Join(trainingId);
}
示例2: OnLoad
public override void OnLoad(ConfigNode config)
{
var oldPath = KSPUtil.ApplicationRootPath + "saves/" + HighLogic.SaveFolder + "/kethane.cfg";
var oldConfig = ConfigNode.Load(oldPath);
if (oldConfig != null)
{
config = oldConfig;
System.IO.File.Delete(oldPath);
}
if (!config.HasValue("Version") && (config.CountNodes > 0 || config.CountValues > 2))
{
try
{
config = upgradeConfig(config);
}
catch (Exception e)
{
Debug.LogError("[Kethane] Error upgrading legacy data: " + e);
config = new ConfigNode();
}
}
var timer = System.Diagnostics.Stopwatch.StartNew();
PlanetDeposits.Clear();
Scans.Clear();
var resourceNodes = config.GetNodes("Resource");
foreach (var resource in KethaneController.ResourceDefinitions)
{
var resourceName = resource.Resource;
var resourceNode = resourceNodes.SingleOrDefault(n => n.GetValue("Resource") == resourceName) ?? new ConfigNode();
PlanetDeposits[resourceName] = new Dictionary<string, IBodyResources>();
Scans[resourceName] = new Dictionary<string, Cell.Set>();
generatorNodes[resourceName] = resourceNode.GetNode("Generator") ?? resource.Generator;
var generator = createGenerator(generatorNodes[resourceName].CreateCopy());
if (generator == null)
{
Debug.LogWarning("[Kethane] Defaulting to empty generator for " + resourceName);
generator = new EmptyResourceGenerator();
}
generators[resourceName] = generator;
var bodyNodes = resourceNode.GetNodes("Body");
foreach (var body in FlightGlobals.Bodies)
{
var bodyNode = bodyNodes.SingleOrDefault(n => n.GetValue("Name") == body.name) ?? new ConfigNode();
PlanetDeposits[resourceName][body.name] = generator.Load(body, bodyNode.GetNode("GeneratorData"));
Scans[resourceName][body.name] = new Cell.Set(MapOverlay.GridLevel);
var scanMask = bodyNode.GetValue("ScanMask");
if (scanMask != null)
{
try
{
Scans[resourceName][body.name] = new Cell.Set(MapOverlay.GridLevel, Convert.FromBase64String(scanMask.Replace('.', '/').Replace('%', '=')));
}
catch (FormatException e)
{
Debug.LogError(String.Format("[Kethane] Failed to parse {0}/{1} scan string, resetting ({2})", body.name, resourceName, e.Message));
}
}
}
}
if (!config.HasValue("Version") || config.GetValue("Version") == "0.8")
{
var str = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("Kethane.Resources.GridIndices.txt")).ReadToEnd();
var map = str.Split(',').Select(s => new Cell(uint.Parse(s))).ToArray();
foreach (var resource in KethaneController.ResourceDefinitions)
{
foreach (var body in FlightGlobals.Bodies)
{
var old = Scans[resource.Resource][body.name];
var set = new Cell.Set(MapOverlay.GridLevel);
foreach (var cell in Cell.AtLevel(MapOverlay.GridLevel))
{
set[cell] = old[map[cell.Index]];
}
Scans[resource.Resource][body.name] = set;
}
}
}
timer.Stop();
Debug.LogWarning(String.Format("Kethane deposits loaded ({0}ms)", timer.ElapsedMilliseconds));
}