当前位置: 首页>>代码示例>>C#>>正文


C# StringReader.ReadLine方法代码示例

本文整理汇总了C#中StringReader.ReadLine方法的典型用法代码示例。如果您正苦于以下问题:C# StringReader.ReadLine方法的具体用法?C# StringReader.ReadLine怎么用?C# StringReader.ReadLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在StringReader的用法示例。


在下文中一共展示了StringReader.ReadLine方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReadFile

	// Use this for initialization
	/*void Start () {
		
	}*/
	
	// Update is called once per frame
	/*void Update () {
		
	}*/

	public void ReadFile (string filename)
	{
		TextAsset textAsset = Resources.Load (filename) as TextAsset;
		StringReader reader = new StringReader (textAsset.text);
		waveInfo = new List<WaveInformation[]> ();
		string s;
		int monsterNum;
		WaveInformation[] wave;
		while (true) {
			s = reader.ReadLine ();
			if (s == null)
				break;
			monsterNum = int.Parse (s);
			wave = new WaveInformation[monsterNum];
			for (int i = 0; i < monsterNum; i++) {
				s = reader.ReadLine ();
				string[] sp = s.Split (new char[] { ' ' });
				wave [i] = new WaveInformation();
				wave [i].bornTime = float.Parse (sp [0]);
				wave [i].monster = monster [int.Parse (sp [1])];
				wave [i].waveItemType = int.Parse (sp [1]);
				wave [i].bornPos = new IntVector2 (int.Parse (sp [2]), int.Parse (sp [3]));
			}
			waveInfo.Add (wave);
		}
		nowWave = 0;
	}
开发者ID:meatybobby,项目名称:TotemGame,代码行数:37,代码来源:WaveController.cs

示例2: Read

    public TileType[,] Read(TextAsset file, int xSize, int ySize)
    {
        StringReader reader = new StringReader(file.text);

        TileType[,] ttmap = new TileType[xSize, ySize];

        if (reader == null)
        {
            print ("read failed");
            return null;
        }
        else
        {
            int x = 0;
            int y = ySize - 1;
            for (string line = reader.ReadLine(); line != null; line = reader.ReadLine())
            {
                //PrintMapLine(line, row);
                x = 0;
                foreach(char c in line)
                {
                    //print ("" + x + " " + y);
                    ttmap[x,y] = ConvertToTileTypeFromChar(c, x, y);
                    x++;
                }

                y--;
            }
            return ttmap;
        }
    }
开发者ID:seanarooni,项目名称:Unity-common-scripts,代码行数:31,代码来源:LoadMapFromTextFile.cs

示例3: GetMapSize

    public Vector2 GetMapSize(TextAsset file)
    {
        //returns the size of the map as a Vector 2, needs to be converted (shown below).
        StringReader reader = new StringReader(file.text);

        int xSize = 0;
        int ySize = 0;

        if (reader == null)
        {
            print ("read failed");
        }
        else
        {
            for (string line = reader.ReadLine(); line != null; line = reader.ReadLine())
            {
                if (xSize == 0)
                {
                    foreach (char c in line)
                    {
                        xSize++;
                    }
                }
                ySize++;
            }
        }
        return new Vector2(xSize, ySize);
    }
开发者ID:seanarooni,项目名称:Unity-common-scripts,代码行数:28,代码来源:LoadMapFromTextFile.cs

示例4: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        // CUSTOMIZE THIS: This is the seller's Payment Data Transfer authorization token.
        // Replace this with the PDT token in "Website Payment Preferences" under your account.
        string authToken = "Dc7P6f0ZadXW-U1X8oxf8_vUK09EHBMD7_53IiTT-CfTpfzkN0nipFKUPYy";
        string txToken = Request.QueryString["tx"];
        string query = "cmd=_notify-synch&tx=" + txToken + "&at=" + authToken;

        //Post back to either sandbox or live
        string strSandbox = "https://www.sandbox.paypal.com/cgi-bin/webscr";
        string strLive = "https://www.paypal.com/cgi-bin/webscr";
        HttpWebRequest req = (HttpWebRequest)WebRequest.Create(strSandbox);

        //Set values for the request back
        req.Method = "POST";
        req.ContentType = "application/x-www-form-urlencoded";
        req.ContentLength = query.Length;

        //Send the request to PayPal and get the response
        StreamWriter streamOut = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII);
        streamOut.Write(query);
        streamOut.Close();
        StreamReader streamIn = new StreamReader(req.GetResponse().GetResponseStream());
        string strResponse = streamIn.ReadToEnd();
        streamIn.Close();

        Dictionary<string,string> results = new Dictionary<string,string>();
        if(strResponse != "")
        {
            StringReader reader = new StringReader(strResponse);
            string line=reader.ReadLine();

            if(line == "SUCCESS")
            {

                while ((line = reader.ReadLine()) != null)
                {
                    results.Add(line.Split('=')[0], line.Split('=')[1]);

                        }
                Response.Write("<p><h3>Your order has been received.</h3></p>");
                Response.Write("<b>Details</b><br>");
                Response.Write("<li>Name: " + results["first_name"] + " " + results["last_name"] + "</li>");
                Response.Write("<li>Item: " + results["item_name"] + "</li>");
                Response.Write("<li>Amount: " + results["payment_gross"] + "</li>");
                Response.Write("<hr>");
            }
            else if(line == "FAIL")
            {
                // Log for manual investigation
                Response.Write("Unable to retrive transaction detail");
            }
        }
        else
        {
            //unknown error
            Response.Write("ERROR");
        }
    }
开发者ID:jmichaelll,项目名称:pdt-code-samples,代码行数:59,代码来源:paypal_pdt.cs

示例5: createPointsFromString

 private void createPointsFromString(string content, int sectorId)
 {
     StringReader input = new StringReader(content);
     string line = input.ReadLine();
     float bestTime = float.Parse(line);
     line = input.ReadLine();
     Sector sector = new Sector(bestTime,line);
     points.Add(sectorId,sector);
     input.Close();
 }
开发者ID:jacek-kurlit,项目名称:cars,代码行数:10,代码来源:PointsCointerner.cs

示例6: Parse

    public R Parse(string reqAsStr)
    {
        var textReader = new StringReader(reqAsStr);
        var firstLine = textReader.ReadLine();
        var requestObject = CreateRequest(firstLine);

        string line;
        while ((line = textReader.ReadLine()) != null)
        {
            this.AddHeaderToRequest(requestObject, line);
        }
        return requestObject;
    }
开发者ID:exploitx3,项目名称:HighQualityCode,代码行数:13,代码来源:HttpRequest.cs

示例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)に変換
            }
        }
	}
开发者ID:Ayaminn,项目名称:InteractiveArt,代码行数:13,代码来源:RedManager.cs

示例8: createWorld

    //Will create all of the tiles and the representation of the word
    public void createWorld(string fileName)
    {
        currentMap = fileName;
        int bigHeight, bigWidth;
        bool[,] bigConnections = null;
        currentGraph = new Graph ();
        try {
            string line;
            TextAsset theTextFile = Resources.Load<TextAsset>(fileName);
            StringReader theReader = new StringReader(theTextFile.text);
            theReader.ReadLine();//This reads the graph type line (not needed)
            bigHeight = extractNumber(theReader.ReadLine());//This reads the height of the graph
            bigWidth = extractNumber (theReader.ReadLine());//This reads the width of the graph
            theReader.ReadLine();//This read the word map (not needed)
            bigConnections = new bool[bigHeight, bigWidth];
            int currentHeight = 0;
            int currentWidth = 0;

            List<string> lines = new List<string>();

            line = theReader.ReadLine();

            while (line != null) {
                lines.Add(line);
                line = theReader.ReadLine();
            }

            theReader.Close();

            for (int i = lines.Count - 1; i >=0; i--) {
                line = lines[i];
                if (line != null) {
                    foreach (char c in line) {
                        bigConnections[currentHeight, currentWidth] = (c == '.');//Set the value to 1 if the terrain is walkable and 0 otherwise
                        currentWidth++;
                    }
                }
                currentWidth = 0;
                currentHeight++;
            }
        }
        catch (Exception e)
        {
            Debug.Log("An error has occured while parsing the file:" + e.Message);
        }
        shrinkify(bigConnections);
        createPoints ();
        createGraph ();
        resetGraph ();
    }
开发者ID:charder,项目名称:GameAIUnity,代码行数:51,代码来源:WorldCreator.cs

示例9: LoadMusic

    public static void LoadMusic()
    {
        TextAsset musicList = Resources.Load("music") as TextAsset;
        List<string> musicLocs = new List<string>();
        using (StringReader sr = new StringReader(musicList.ToString())) {
            string newLine = sr.ReadLine();

            while (newLine != null) {
                musicLocs.Add(newLine);
                newLine = sr.ReadLine();
            }
        }

        musicLocations = musicLocs.ToArray();
    }
开发者ID:Arafo,项目名称:Syncopia,代码行数:15,代码来源:AudioSettings.cs

示例10: parseQusData

    void parseQusData(string str)
    {
        TextReader reader = new StringReader(str);
        string line; 

        while ((line = reader.ReadLine()) != null)
        {

            if (line == string.Empty)
                continue;

            string[] values = line.Split('=');
            if (values.Length < 2)
                continue;

            if (values[0].Contains("Question"))
            {
                Question que = new Question();
                que.title = values[1].Trim().Replace("\\n", "\n");
                for (int i = 0; i < 5; i++)
                {
                    line = reader.ReadLine();
                    if (line != null)
                    {
                        string[] strs = line.Split('=');
                        if (strs.Length==1)
                        { 
                            que.anss.Add(line.Trim().Replace("\\n", "\n"));
                        }else
                        {
                            if(strs[0].Contains("RightAns"))
                            {
                                que.rightAns = Convert.ToInt32(strs[1]) - 1;
                            }
                        }
                    }
                }
                quesList.Add(que);
                //Debug.LogError( "que.title  "+ que.title);
                //Debug.LogError(que.anss[0]);
                //Debug.LogError(que.anss[1]);
                //Debug.LogError(que.anss[2]);
                //Debug.LogError(que.anss[3]);
                //Debug.LogError(que.rightAns);
            }
        } 
        reader.Close();
    }
开发者ID:czzcz,项目名称:StarryNight,代码行数:48,代码来源:DataManager.cs

示例11: Compile

    public static bool Compile(ref string code, string scriptFile, bool IsPrimaryScript, Hashtable context)
    {
        var hashDefs = new Dictionary<string, string>();

        var content = new StringBuilder();

        string line;
        using (var sr = new StringReader(code))
            while ((line = sr.ReadLine()) != null)
            {
                if (line.Trim().StartsWith("#define ")) //#define <pattern> <replacement>
                {
                    string[] tokens = line.Split(" ".ToCharArray(), 3, StringSplitOptions.RemoveEmptyEntries);
                    hashDefs.Add(tokens[1], tokens[2]);

                    content.AppendLine("//" + line);
                }
                else
                    content.AppendLine(line);
            }

        code = content.ToString();
        foreach(string key in hashDefs.Keys)
            code = code.Replace(key, hashDefs[key]);

        return true;
    }
开发者ID:Diullei,项目名称:Storm,代码行数:27,代码来源:hashdef.cs

示例12: getConfigMuret

    public Dictionary<string, float> getConfigMuret(string index)
    {
        Dictionary<string, float> conf = new Dictionary<string, float>();
        string fullpath = "shaders/configs/muret/" + index/* + ".txt"*/; // the file is actually ".txt" in the end

        TextAsset textAsset = (TextAsset) Resources.Load(fullpath, typeof(TextAsset));

        if(textAsset != null){
            StringReader reader = new StringReader(textAsset.text);

            if(reader != null)
            {
                string floatString = "";

                do
                {
                    floatString = reader.ReadLine();

                    if(floatString != null)
                    {
                        string szkey = floatString.Substring(0, floatString.IndexOf("="));
                        float fvalue = float.Parse(floatString.Substring(floatString.IndexOf("=") + 1));
                        conf.Add(szkey,fvalue);

                    }

                }while(floatString != null);

                reader.Close();
            }
            return conf;
        }else{
            return null;
        }
    }
开发者ID:gviaud,项目名称:OS-unity-5,代码行数:35,代码来源:LoadShaderPresets.cs

示例13: 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);
    }
开发者ID:nmrtkhs,项目名称:teacherHunting,代码行数:60,代码来源:QuestionManager.cs

示例14: CleanStackTrace

    public static string CleanStackTrace(string stackTrace)
    {
        if (stackTrace == null)
        {
            return string.Empty;
        }
        using (var stringReader = new StringReader(stackTrace))
        {
            var stringBuilder = new StringBuilder();
            while (true)
            {
                var line = stringReader.ReadLine();
                if (line == null)
                {
                    break;
                }

                stringBuilder.AppendLine(line.Split(new[]
                {
                    " in "
                }, StringSplitOptions.RemoveEmptyEntries).First());
            }
            return stringBuilder.ToString().Trim();
        }
    }
开发者ID:cdnico,项目名称:docs.particular.net,代码行数:25,代码来源:StackTraceCleaner.cs

示例15: load

    private bool load(string text)
    {
        // Handle any problems that might arise when reading the text
        try
        {
            using (var theReader = new StringReader(text))
            {
                string line;
                do
                {
                    line = theReader.ReadLine();

                    if (string.IsNullOrEmpty(line) || string.IsNullOrEmpty(line.Trim()) || line.StartsWith("#"))
                        continue;

                    var entries = line.Trim().Split(new[] { '=' }, 2);
                    if (entries.Length == 2)
                        addKeyValue(entries);
                    else
                    {
                        Debug.LogErrorFormat("Neplatná řádka: {0}", line);
                    }
                }
                while (line != null);

                theReader.Close();
            }
        }
        catch (Exception e)
        {
            Debug.LogException(e);
            return false;
        }
        return true;
    }
开发者ID:halbich,项目名称:TimeLapsus,代码行数:35,代码来源:TextController.cs


注:本文中的StringReader.ReadLine方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。