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


C# StreamReader.ReadInteger方法代码示例

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


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

示例1: LoadProfile

        /// <summary>
        /// Loads a profile by reading a text document from the stream reader and returns it
        /// </summary>
        /// <param name="sr">StreamReader</param>
        /// <returns>Profile</returns>
        public Profile LoadProfile(StreamReader sr)
        {
            Profile user = new Profile("temp", "temp");

            user.Name = sr.ReadLine();
            user.Desc = sr.ReadLine();
            user.Exp = sr.ReadInteger();
            user.ExpReq = sr.ReadInteger();
            user.Level = sr.ReadInteger();
            int taskCount = sr.ReadInteger();
            int shortCount = sr.ReadInteger();
            int longCount = sr.ReadInteger();
            for (int i = 0; i < taskCount; i++)
            {
                LoadGoal(sr, ref user);
            }
            for (int i = 0; i < shortCount; i++)
            {
                LoadGoal(sr, ref user);
            }
            for (int i = 0; i < longCount; i++)
            {
                LoadGoal(sr, ref user);
            }

            return user;
        }
开发者ID:Gemore,项目名称:PerfectionV2,代码行数:32,代码来源:Loader.cs

示例2: LoadGoal

        /// <summary>
        /// Loads a goal from a stream reacer and attaches it to the profile
        /// </summary>
        /// <param name="sr">StreamReader</param>
        /// <param name="user">Profile</param>
        private void LoadGoal(StreamReader sr, ref Profile user)
        {
            Goal resultGoal = sr.ReadGoalType();
            string goalName = sr.ReadLine();
            string goalDesc = sr.ReadLine();
            GoalCategory goalCate = sr.ReadCategory();

            if (resultGoal is LongTermGoal)
            {
                LongTermGoal resultLong = new LongTermGoal(goalName, goalDesc, goalCate, new List<ShortTermGoal>());
                resultLong.Completed = sr.ReadBool();
                resultLong.ExpVal = sr.ReadInteger();
                resultLong.EstHours = sr.ReadInteger();
                int reqShort = sr.ReadInteger();
                for (int i = 0; i < reqShort; i++)
                {
                    string reqShortName = sr.ReadLine();
                    foreach (ShortTermGoal sg in user.ShortGoals)
                    {
                        if (sg.Name == reqShortName)
                        {
                            if (!resultLong.ReqShort.Contains(sg))
                            {
                                resultLong.ReqShort.Add(sg);
                                break;
                            }
                        }
                    }
                }
                resultGoal = resultLong;

            }
            else if (resultGoal is ShortTermGoal)
            {
                ShortTermGoal resultShort = new ShortTermGoal(goalName, goalDesc, goalCate, new List<TaskGoal>());
                resultShort.Completed = sr.ReadBool();
                resultShort.ExpVal = sr.ReadInteger();
                resultShort.EstHours = sr.ReadInteger();
                int reqTasks = sr.ReadInteger();
                for (int i = 0; i < reqTasks; i++)
                {
                    string reqTaskName = sr.ReadLine();
                    foreach (TaskGoal tg in user.Tasks)
                    {
                        if (tg.Name == reqTaskName)
                        {
                            if (!resultShort.ReqTasks.Contains(tg))
                            {
                                resultShort.ReqTasks.Add(tg);
                                break;
                            }
                        }
                    }
                }
                resultGoal = resultShort;
            }
            else
            {
                resultGoal = new TaskGoal(goalName, goalDesc, goalCate);
                resultGoal.Completed = sr.ReadBool();
                resultGoal.ExpVal = sr.ReadInteger();
                resultGoal.EstHours = sr.ReadInteger();
            }

            user.AddGoal(resultGoal);
        }
开发者ID:Gemore,项目名称:PerfectionV2,代码行数:71,代码来源:Loader.cs


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