using System;using System.Collections.Generic;using System.IO ;namespace 指令碼產生程式{ static public class ProcessASourceFile { static private bool IsSpaceChar(char c) { return c == ' ' || c == '\t'; } static private string GetNextWord(string aLine, ref int startIndex) { string word = ""; while (startIndex != aLine.Length) { if (IsSpaceChar(aLine[startIndex])) { if (word == "") ; else { ++startIndex; break; } } else word += aLine[startIndex]; ++startIndex; } return word; } static private bool IsTheEndOfFile(string aLine) { if (aLine == null || aLine == "\n") return true; else return false; } static public StreamReader OpenASourceFile(FileInfo fileInfo) { StreamReader reader = fileInfo.OpenText(); return reader; } static public void LeapfrogExplanation(StreamReader reader) { reader.ReadLine(); } static public bool ReadADataCellSuccessfully(StreamReader reader, ref DataCell sourceDataCell) { string aLine = reader.ReadLine(); if (IsTheEndOfFile(aLine)) return false; int indexOfKeyInfo = 0; int i = 0; while (i != aLine.Length) { sourceDataCell.SetKeyInfo(indexOfKeyInfo, GetNextWord(aLine, ref i)); ++indexOfKeyInfo; } return true; } static public void CloseASourceFile(StreamReader reader) { reader.Close(); } }}