本文整理汇总了C#中StringReader.Peek方法的典型用法代码示例。如果您正苦于以下问题:C# StringReader.Peek方法的具体用法?C# StringReader.Peek怎么用?C# StringReader.Peek使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringReader
的用法示例。
在下文中一共展示了StringReader.Peek方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadNextNumber
int ReadNextNumber(StringReader input)
{
string result = "";
while (input.Peek() >= 0) {
char c = (char)input.Read();
if (c == '\r') {
input.Read();
break;
} else if (c == '\n' || c == ' ' || c == '\t') {
break;
}
result += c;
}
if (result == "") {
return -9999;
} else {
return int.Parse(result);
}
}
示例2: Create
private static void Create()
{
var separators = new char[] { ' ', '\t' };
var textAsset = Selection.activeObject as TextAsset;
var path = AssetDatabase.GetAssetPath(textAsset).Replace(".txt", "");
var names = new string[] { "_LOD2", "_LOD1", "_LOD0" };
var cutoff = new float[] { 4.5f, 5.5f, float.MaxValue };
for (int i = 0; i < names.Length; i++)
{
var vertices = new List<Vector3>();
var normals = new List<Vector3>();
var tangents = new List<Vector4>();
var triangles = new List<int>();
var uv = new List<Vector2>();
var colors = new List<Color>();
using (var reader = new StringReader(textAsset.text))
{
while (reader.Peek() != -1)
{
var line = reader.ReadLine();
var values = line.Split(separators, StringSplitOptions.RemoveEmptyEntries);
if (values.Length != 3) continue;
if (values[0].StartsWith("#")) continue;
float rasc = float.Parse(values[0]);
float decl = float.Parse(values[1]);
float mag = float.Parse(values[2]);
if (mag > cutoff[i]) continue;
var center = Carthesian(rasc, decl);
var normal = -center;
var tangent = Tangent(normal);
float m = Mathf.Pow(2.512f, 1 - mag);
var color = new Color(1, 1, 1, m);
int idx = vertices.Count;
vertices.Add(center);
vertices.Add(center);
vertices.Add(center);
vertices.Add(center);
normals.Add(normal);
normals.Add(normal);
normals.Add(normal);
normals.Add(normal);
tangents.Add(tangent);
tangents.Add(tangent);
tangents.Add(tangent);
tangents.Add(tangent);
colors.Add(color);
colors.Add(color);
colors.Add(color);
colors.Add(color);
uv.Add(new Vector2(0, 0));
uv.Add(new Vector2(1, 0));
uv.Add(new Vector2(0, 1));
uv.Add(new Vector2(1, 1));
triangles.Add(idx);
triangles.Add(idx+1);
triangles.Add(idx+2);
triangles.Add(idx+3);
triangles.Add(idx+2);
triangles.Add(idx+1);
}
}
var name = path + names[i] + ".asset";
var mesh = AssetDatabase.LoadMainAssetAtPath(name) as Mesh;
if (!mesh)
{
mesh = new Mesh() {
vertices = vertices.ToArray(),
colors = colors.ToArray(),
uv = uv.ToArray(),
normals = normals.ToArray(),
tangents = tangents.ToArray(),
triangles = triangles.ToArray(),
};
AssetDatabase.CreateAsset(mesh, name);
}
else
{
mesh.Clear();
//.........这里部分代码省略.........
示例3: LoadQuestion
public void LoadQuestion(int stage)
{
currentStage = stage;
string fileName = "question/tsv/test";
switch (stage){
case 0:
fileName = "question/tsv/0_2keta";
questionText.fontSize = 50;
break;
case 1:
fileName = "question/tsv/1_over100";
questionText.fontSize = 40;
break;
case 2:
fileName = "question/tsv/2_3keta2keta";
questionText.fontSize = 50;
break;
case 3:
fileName = "question/tsv/3_kuku";
questionText.fontSize = 50;
break;
case 4:
fileName = "question/tsv/4_till10000";
questionText.fontSize = 34;
break;
case 5: //all_stage
for (int i = 0; i < 5; i++) {
LoadQuestion(i);
}
questionText.fontSize = 34;
currentStage = 5;
return;
default:
Debug.LogErrorFormat("errorStageNum:{0}", stage);
break;
}
TextAsset csv = Resources.Load(fileName) as TextAsset;
StringReader reader = new StringReader(csv.text);
int line = 0;
while (reader.Peek() > -1) {
string[] values = reader.ReadLine().Split('\t');
if (line > 0){
int difficulty = int.Parse(values[0]) - 1; //csv...1~3 -> data...0~2
questionList[difficulty].Add(values[1]);
var answers = new List<string>();
answers.Add(values[2]);
answers.Add(values[3]);
answers.Add(values[4]);
answers.Add(values[5]);
answerList[difficulty].Add(answers);
}
line++;
}
Debug.LogFormat("QuestionLoaded :" + fileName + " line:{0}", line);
}
示例4: loadCSV
public void loadCSV()
{
DestroyObj des = GetComponent<DestroyObj> ();
des.destroyObj ();
if (GetStage.stage != "") {
TextAsset csv = Resources.Load("CSV/stage"+GetStage.stage) as TextAsset;
StringReader reader = new StringReader(csv.text);
length = 0;
while (reader.Peek() > -1) {
string line = reader.ReadLine();
string[] values = line.Split(',');
for(int i=0;i<values.Length;i++){
strData.Add (values[i]);
length++;
}
}
setMap ();
strData.Clear ();
} else {
TextAsset csv = Resources.Load("CSV/Maker") as TextAsset;
StringReader reader = new StringReader(csv.text);
length = 0;
while (reader.Peek() > -1) {
string line = reader.ReadLine();
string[] values = line.Split(',');
for(int i=0;i<values.Length;i++){
strData.Add (values[i]);
length++;
}
}
setMap ();
strData.Clear ();
}
//StayStage.num = TestNum;
}
示例5: YourMethod
public String YourMethod(String texto, String numero)
{
try
{
int n = int.Parse(numero);
char ch = 'p';
String s = "<p>";
StringReader reader;
reader = new StringReader(texto);
while (reader.Peek() > -1)
{
for (int i = 0; i < n; ++i)
{
if (i == n - 1)
{
if ((char)reader.Peek() != ' ')
{
ch = (char)reader.Read();
s += ch;
}
}
else {
ch = (char)reader.Read();
s += ch;
}
}
if (reader.Peek() > -1 && (char)reader.Peek() != ' ')
{
s += "-";
}
else
{
reader.Read();
}
s += "\n</p><p>";
}
return s;
}
catch (FormatException)
{
}
return "error";
}
示例6: runTest
public bool runTest()
{
Console.WriteLine(s_strTFPath + "\\" + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer);
int iCountErrors = 0;
int iCountTestcases = 0;
String strLoc = "Loc_000oo";
String strValue = String.Empty;
try
{
StringReader sr;
strLoc = "Loc_98yg7";
iCountTestcases++;
try {
sr = new StringReader(null);
String strTemp = sr.ReadToEnd();
iCountErrors++;
printerr( "Error_18syx! StringReader should only hold null");
sr.ReadLine();
sr.Peek();
sr.Read();
sr.Close();
} catch (ArgumentNullException exc) {
printinfo("Expected exception thrown, exc=="+exc.Message);
}catch (Exception exc) {
iCountErrors++;
printerr("Error_109xu! Unexpected exception thrown, exc=="+exc.ToString());
}
strLoc = "Loc_4790s";
sr = new StringReader(String.Empty);
iCountTestcases++;
if(!sr.ReadToEnd().Equals(String.Empty)) {
iCountErrors++;
printerr( "Error_099xa! Incorrect construction");
}
strLoc = "Loc_8388x";
sr = new StringReader("Hello\0World");
iCountTestcases++;
if(!sr.ReadToEnd().Equals("Hello\0World")) {
iCountErrors++;
printerr( "Error_1099f! Incorrect construction");
}
} catch (Exception exc_general ) {
++iCountErrors;
Console.WriteLine (s_strTFAbbrev + " : Error Err_8888yyy! strLoc=="+ strLoc +", exc_general=="+exc_general.ToString());
}
if ( iCountErrors == 0 )
{
Console.WriteLine( "paSs. "+s_strTFName+" ,iCountTestcases=="+iCountTestcases.ToString());
return true;
}
else
{
Console.WriteLine("FAiL! "+s_strTFName+" ,iCountErrors=="+iCountErrors.ToString()+" , BugNums?: "+s_strActiveBugNums );
return false;
}
}
示例7: Awake
void Awake () {
TextAsset csv = Resources.Load("csv/pink") as TextAsset; // データの読み込み
StringReader reader = new StringReader(csv.text);
bpm = int.Parse(reader.ReadLine()); // bpmの読み込み
while (reader.Peek() > -1) {
string line = reader.ReadLine(); // 1行ずつ読み込む
for (int i = 0; i < line.Length - 1; i++) {
scoreData.Add(int.Parse(line[i].ToString())); // 1文字ずつ数字(0, 1)に変換
}
}
}
示例8: Start
// Use this for initialization
void Start()
{
// Resources/data01
data = Resources.Load ("data01") as TextAsset;
StringReader reader = new StringReader (data.text);
//Read Header
string header = reader.ReadLine ();
string[] headersValue = header.Split (',');
Debug.Log (header);
//Read Body
while (reader.Peek()>-1) {
string body = reader.ReadLine ();
string[] values = body.Split (',');
Debug.Log(body);
}
}
示例9: Load
public void Load(string name)
{
//nameはファイル名(.csvはいらない)
TextAsset csv = Resources.Load("CSV/"+name) as TextAsset;
StringReader reader = new StringReader(csv.text);
while (reader.Peek() > -1) { //最後の行を読むまで
//行読み込み
string line = reader.ReadLine();
//カンマで区切られた要素を格納
string[] values = line.Split(',');
for(int i=0;i<values.Length;i++){
strData.Add (values[i]);
}
}
reader.Close ();
}
示例10: Start
void Start()
{
cube = new GameObject ();
// UserData.STAY_WORLD = 1;
// SelectStage.num = 1;
TextAsset csv = Resources.Load("CSV/World_"+UserData.STAY_WORLD+"/stage"+SelectStage.num) as TextAsset;
StringReader reader = new StringReader(csv.text);
length = 0;
while (reader.Peek() > -1) {
string line = reader.ReadLine();
string[] values = line.Split(',');
for(int i=0;i<values.Length;i++){
strData.Add (values[i]);
length++;
}
}
setMap ();
reader.Close ();
}
示例11: LoadKnownFormulas
public static void LoadKnownFormulas()
{
var knownCompounds = Resources.Load<TextAsset>("knowncompounds");
var l = new List<ComplexMoleculeData>();
var s = new StringReader(knownCompounds.text);
while (s.Peek() > 0)
{
var line = s.ReadLine();
var compoundParams = line.Split(';');
if (compoundParams.Length >= 2)
{
var compound = compoundParams[1].Split('+');
KnownFormulas[compoundParams[0]] = compound.Select(c => ComplexMoleculeData.Parse(c)).ToArray();
}
}
}
示例12: Awake
void Awake(){
if (instance == null) {
instance = this;
DontDestroyOnLoad (this.gameObject);
TextAsset csv = Resources.Load("message") as TextAsset;
StringReader reader = new StringReader(csv.text);
while (reader.Peek() > -1) {
string line = reader.ReadLine();
string[] values = line.Split(',');
mes = new string[values.Length];
for (int i = 0; i < values.Length; i++) {
mes [i] = values [i];
Debug.Log (mes[i]);
}
}
} else {
Destroy (this.gameObject);
}
source = GetComponent<AudioSource> ();
}
示例13: fileRead
//**************************************************************
//データを読み込む
public List<scenarioBean> fileRead(TextAsset t)
{
bool isSkip = false;
List<scenarioBean> scenarioLine = new List<scenarioBean>();
StringReader reader = new StringReader(t.text);
while (reader.Peek() > -1) {
string line = reader.ReadLine();
//空白行ブロック
if (line == "")
continue;
string[] values = line.Split(',');
if (line.Substring (0, 2) == "/*") {
isSkip = true;
continue;
}
if (line.Substring (0, 2) == "*/") {
isSkip = false;
continue;
}
if ((isSkip)||(line.Substring (0, 2) == "//")) continue;
scenarioBean data = new scenarioBean ();
data.setTime (int.Parse(values[0]));
data.setCommand (values[1]);
if(values.Length > 2){
data.setParam (new Common().arrayToList(values,2));
}
scenarioLine.Add (data);
}
return scenarioLine;
}
示例14: LoadAtoms
public static void LoadAtoms()
{
var text = Resources.Load<TextAsset>("elements");
var l = new List<AtomData>();
var r = new StringReader(text.text);
while (r.Peek() > 0)
{
var next = r.ReadLine();
var data = next.Split(';');
var atom = new AtomData()
{
index = int.Parse(data[0]),
symbol = data[1],
name = data[2]
};
l.Add(atom);
}
Atoms = l.ToArray();
}
示例15: Start
void Start()
{
//FileInfo theSourceFile = new FileInfo (Application.dataPath+"/Resources/LevelData/"+Application.loadedLevelName+".txt");
TextAsset file = (TextAsset)Resources.Load("LevelData/"+Application.loadedLevelName, typeof(TextAsset));
StringReader reader = new StringReader(file.text);
// get size of grid and word counts
gridSize = new Vector2(int.Parse(reader.ReadLine()), int.Parse(reader.ReadLine()));
SendMessage("GridSize",gridSize);
//position main camera
//Camera.mainCamera.transform.position = new Vector3(gridSize.x/2f-.5f, -gridSize.y/2+.5f, -50f);
//read puzzles words into Word objects
Object wordResource = Resources.Load("Objects/Word");
while(reader.Peek()!=-1){
int wordIndex = int.Parse(reader.ReadLine());
Vector3 wordPosition = new Vector3((int.Parse(reader.ReadLine())+31f-gridSize.x)*24f, (-int.Parse(reader.ReadLine())+gridSize.y-8f)*24f,0f);
string wordDirection = reader.ReadLine();
string wordAnswer = reader.ReadLine();
string wordClue = wordIndex + ". " + reader.ReadLine();
GameObject wordPrefab = Instantiate(wordResource,puzzleGUI.position+wordPosition,Quaternion.identity) as GameObject;
wordPrefab.transform.parent = puzzleGUI;
Word word = wordPrefab.GetComponent<Word>();
word.Init(wordIndex,wordPosition,wordDirection,wordAnswer,wordClue);
//sort clues
if(wordDirection.CompareTo("across")==0)
{
across.Add(word);
for(int i = across.Count-1; i > 0; i --)
{
if(across[i].index< across[i-1].index)
{
Word temp = across[i];
across[i] = across[i-1];
across[i-1] = temp;
}
}
}
else
{
down.Add(word);
for(int i = down.Count-1; i > 0; i --)
{
if(down[i].index< down[i-1].index)
{
Word temp = down[i];
down[i] = down[i-1];
down[i-1] = temp;
}
}
}
}
reader.Close();
//generate clues
float cluePosition = 0;
Object clueResource = Resources.Load("Objects/Clue");
Clue clue;
clue = (Instantiate(clueResource,acrossGUI.position+cluePosition*Vector3.up, Quaternion.identity) as GameObject).GetComponent<Clue>();
clue.transform.parent = puzzleGUI;
cluePosition -= clue.Init("Across",null);
for(int i = 0; i < across.Count; i ++)
{
clue = (Instantiate(clueResource,acrossGUI.position+cluePosition*Vector3.up, Quaternion.identity) as GameObject).GetComponent<Clue>();
float length = clue.Init(across[i].clue,across[i]);
cluePosition -= length;
BoxCollider collider = clue.gameObject.AddComponent<BoxCollider>();
collider.center = new Vector3(3130f,-length*10f+20f,0f)*0.002604167f;
collider.size = new Vector3(6260f,length*20f-40f,1f)*0.002604167f;
clue.transform.parent = across[i].transform;
}
cluePosition = 0;
clue = (Instantiate(clueResource,downGUI.position+cluePosition*Vector3.up, Quaternion.identity) as GameObject).GetComponent<Clue>();
clue.transform.parent = puzzleGUI;
cluePosition -= clue.Init("Down",null);
for(int i = 0; i < down.Count; i ++)
{
clue = (Instantiate(clueResource,downGUI.position+cluePosition*Vector3.up, Quaternion.identity) as GameObject).GetComponent<Clue>();
float length = clue.Init(down[i].clue,down[i]);
cluePosition -= length;
BoxCollider collider = clue.gameObject.AddComponent<BoxCollider>();
collider.center = new Vector3(3130f,-length*10f+20f,0f)*0.002604167f;
collider.size = new Vector3(6260f,length*20f-40f,1f)*0.002604167f;
clue.transform.parent = down[i].transform;
}
}