本文整理汇总了C#中Column.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Column.Add方法的具体用法?C# Column.Add怎么用?C# Column.Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Column
的用法示例。
在下文中一共展示了Column.Add方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ImportLevel
/// <summary>
/// Imports a level file. You can read the Level file format description on this file header
/// </summary>
/// <param name="path">The path.</param>
/// <returns></returns>
/// <exception cref="System.Exception">Exception Loading level file: + path</exception>
public LevelModel ImportLevel(string path)
{
string line = string.Empty;
BlockTypeEnum blockType = BlockTypeEnum.EMPTY;
LevelModel model = new LevelModel();
try
{
// Read the level file
using (Stream fs = WaveServices.Storage.OpenContentFile(path))
//using (FileStream fs = File.Open(path, FileMode.Open, FileAccess.Read))
using (BufferedStream bs = new BufferedStream(fs, 8388608)) // 8Mb buffer it's a good buffer for files.
using (StreamReader sr = new StreamReader(bs))
{
float blockScaleX = 1.0f;
float blockScaleY = 1.0f;
float blockScaleZ = 1.0f;
// FIRST LINE of the file: Block X scale
if (!sr.EndOfStream)
{
line = sr.ReadLine();
float.TryParse(line, NumberStyles.Number, CultureInfo.InvariantCulture, out blockScaleX);
ModelFactoryService.Instance.Scale.X= blockScaleX;
}
// SECOND LINE of the file: Block Y Scale
if (!sr.EndOfStream)
{
line = sr.ReadLine();
float.TryParse(line, NumberStyles.Number, CultureInfo.InvariantCulture, out blockScaleY);
ModelFactoryService.Instance.Scale.Y = blockScaleY;
}
// THIRD LINE of the file: Block Z Scale
if (!sr.EndOfStream)
{
line = sr.ReadLine();
float.TryParse(line, NumberStyles.Number, CultureInfo.InvariantCulture, out blockScaleZ);
ModelFactoryService.Instance.Scale.Z = blockScaleZ;
}
// The rest of the file is the level
while (!sr.EndOfStream)
{
line = sr.ReadLine();
if(!string.IsNullOrWhiteSpace(line)) // line must be filled with data
{
string[] splitted = line.Split(SEPARATOR); // split the line
if(splitted.Count() > 0)
{
Column column = new Column(); // creates the column
foreach(string value in splitted)
{
blockType = BlockTypeEnum.EMPTY; // default value if reading error or out of block type error
Enum.TryParse<BlockTypeEnum>(value, out blockType);
column.Add(blockType);
}
model.ColumnCollection.Enqueue(column);
}
}
}
}
}
catch (Exception ex)
{
throw new Exception("Exception Loading level file: " + path, ex);
}
return model;
}