• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# StringReader类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Parse

        /// <summary>
        /// Parses "Min-SE" from specified reader.
        /// </summary>
        /// <param name="reader">Reader from where to parse.</param>
        /// <exception cref="ArgumentNullException">Raised when <b>reader</b> is null.</exception>
        /// <exception cref="SIP_ParseException">Raised when invalid SIP message.</exception>
        public override void Parse(StringReader reader)
        {
            /*
                Min-SE = delta-seconds *(SEMI generic-param)
            */

            if(reader == null){
                throw new ArgumentNullException("reader");
            }

            // Parse address
            string word = reader.ReadWord();
            if(word == null){
                throw new SIP_ParseException("Min-SE delta-seconds value is missing !");
            }
            try{
                m_Time = Convert.ToInt32(word);
            }
            catch{
                throw new SIP_ParseException("Invalid Min-SE delta-seconds value !");
            }

            // Parse parameters
            ParseParameters(reader);
        }
开发者ID:CivilPol,项目名称:LumiSoft.Net,代码行数:31,代码来源:SIP_t_MinSE.cs


示例2: testStemming

 //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
 //ORIGINAL LINE: public void testStemming() throws Exception
 public virtual void testStemming()
 {
     Reader reader = new StringReader("cariñosa");
     TokenStream stream = new MockTokenizer(reader, MockTokenizer.WHITESPACE, false);
     stream = tokenFilterFactory("GalicianStem").create(stream);
     assertTokenStreamContents(stream, new string[] {"cariñ"});
 }
开发者ID:WakeflyCBass,项目名称:lucenenet,代码行数:9,代码来源:TestGalicianStemFilterFactory.cs


示例3: Serialization1

        public static void Serialization1(Human human)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(Human));
            StringBuilder sb = new StringBuilder();

            /* SERIALIZATION */
            using (StringWriter writer = new StringWriter(sb))
            {
                serializer.Serialize(writer, human);
            }
            // XML file
            //Console.WriteLine("SB: " +sb.ToString());
            /* END SERIALIZATION */



            /* DESERIALIZATION */
            Human newMartin = new Human();
            using (StringReader reader = new StringReader(sb.ToString()))
            {
                newMartin = serializer.Deserialize(reader) as Human;
            }
            Console.WriteLine(newMartin.ToString() + Environment.NewLine);
            /* END DESERIALIZATION */
        }
开发者ID:m4rwin,项目名称:BestPractices,代码行数:25,代码来源:Program.cs


示例4: NameEntered

    void NameEntered()
    {
        congratulationsUILabel.text = "";
        PlayerPrefs.SetString("name", playerName);

        StringReader reader = new StringReader(PlayerPrefs.GetString(Application.loadedLevel+"","600 IACONIC\n1200 IACONIC\n1800 IACONIC\n2400 IACONIC\n3000 IACONIC\n3600 IACONIC\n4200 IACONIC\n4800 IACONIC\n5400 IACONIC\n6000 IACONIC"));
        string output = "";
        bool counted = false;
        timeUILabel.text = "";
        nameUILabel.text = "";
        for(int i = 0; i < 10; i ++)
        {
            string input = reader.ReadLine();
            int timer = int.Parse(input.Split(' ')[0]);
            if(playTime<timer&&!counted)
            {
                timeUILabel.text += TimeToString(playTime) + "\n";
                nameUILabel.text += playerName + "\n";
                output += playTime + " " + playerName + "\n";
                i ++;
                counted = true;
            }
            timeUILabel.text += TimeToString(timer);
            nameUILabel.text += input.Split(' ')[1];
            if(i!=9)
            {
                timeUILabel.text +=  "\n";
                nameUILabel.text +=  "\n";
            }
            output += input + "\n";
        }
        reader.Close();
        PlayerPrefs.SetString(Application.loadedLevel+"",output);
    }
开发者ID:iaconic,项目名称:Crossword,代码行数:34,代码来源:Scoreboard.cs


示例5: Parse

        /// <summary>
        /// Parses "CSeq" from specified reader.
        /// </summary>
        /// <param name="reader">Reader from where to parse.</param>
        /// <exception cref="ArgumentNullException">Raised when <b>reader</b> is null.</exception>
        /// <exception cref="SIP_ParseException">Raised when invalid SIP message.</exception>
        public override void Parse(StringReader reader)
        {
            // CSeq = 1*DIGIT LWS Method

            if(reader == null){
                throw new ArgumentNullException("reader");
            }

            // Get sequence number
            string word = reader.ReadWord();
            if(word == null){
                throw new SIP_ParseException("Invalid 'CSeq' value, sequence number is missing !");
            }
            try{
                m_SequenceNumber = Convert.ToInt32(word);
            }
            catch{
                throw new SIP_ParseException("Invalid CSeq 'sequence number' value !");
            }

            // Get request method
            word = reader.ReadWord();
            if(word == null){
                throw new SIP_ParseException("Invalid 'CSeq' value, request method is missing !");
            }
            m_RequestMethod = word;
        }
开发者ID:iraychen,项目名称:LumiSoft.Net,代码行数:33,代码来源:SIP_t_CSeq.cs


示例6: testTrimming

 //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
 //ORIGINAL LINE: public void testTrimming() throws Exception
 public virtual void testTrimming()
 {
     Reader reader = new StringReader("trim me    ");
     TokenStream stream = new MockTokenizer(reader, MockTokenizer.KEYWORD, false);
     stream = tokenFilterFactory("Trim").create(stream);
     assertTokenStreamContents(stream, new string[] {"trim me"});
 }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:9,代码来源:TestTrimFilterFactory.cs


示例7: loadLevel

    protected List<Dictionary<string, int>> loadLevel(int level)
    {
        if(reader == null){
            text = (TextAsset)Resources.Load("LevelDesign/fases/fase" + level,typeof(TextAsset));
            reader = new StringReader(text.text);
        }

        while((line = reader.ReadLine()) != null){
            if(line.Contains(",")){
                string[] note = line.Split(new char[]{','});
                phaseNotes.Add(new Dictionary<string,int>(){
                    {"time",int.Parse(note[0])},
                    {"show",int.Parse(note[1])},
                    {"note",int.Parse(note[2])}
                });
                linecount++;
            }else if(line.Contains("tick"))
            {
                string[] tick = line.Split(new char[]{':'});
                musicTick = float.Parse(tick[tick.Length - 1]);

                linecount ++;
            }
        }
        linecount = 0;

        return getNotesDuration(excludeDoubleNotes(phaseNotes));
    }
开发者ID:renanclaudino,项目名称:SoundWalker,代码行数:28,代码来源:LevelDesign.cs


示例8: Main

    static void Main()
    {
        Dictionary<string, string> dictionary = new Dictionary<string, string>();

        string textLines = @".NET - platform for applications from Microsoft
        CLR - managed execution environment for .NET
        namespace - hierarchical organization of classes
        ";

        StringReader readLines = new StringReader(textLines);

        string line;
        while ((line = readLines.ReadLine())!=null)
        {
            string[] token = line.Split('-');
            dictionary.Add(token[0].Trim(), token[1]);
        }

        string input = Console.ReadLine();

        if (dictionary.ContainsKey(input))
        {
            Console.WriteLine(dictionary[input]);
        }
        else
        {
            Console.WriteLine("No such term in dictionary");
        }
    }
开发者ID:vassil,项目名称:CSharp,代码行数:29,代码来源:14.Dictionary.cs


示例9: Load

    public static LevelData Load(TextAsset asset)
    {
        LevelData level = null;
        var serializer = new XmlSerializer(typeof(LevelData));

        using (var stream = new StringReader(asset.text))
        {
            level = serializer.Deserialize(stream) as LevelData;
        }

        int yLength = level.Rows.Length;
        int xLength = yLength > 0 ? level.Rows[0].RowLength : 0;

        level.Grid = new int[xLength, yLength];

        for (int y = 0; y < yLength; ++y)
        {
            char[] row = level.Rows[y].RowData.ToCharArray();

            for (int x = 0; x < xLength; ++x)
            {
                level.Grid[x, y] = row[x] == WALL ? 1 : 0;
            }
        }

        return level;
    }
开发者ID:DrSkipper,项目名称:Watchlist,代码行数:27,代码来源:LevelData.cs


示例10: generateLevel

    //Funcion que con el nombre del nivel (el mismo que el del xml) crea los gameobjects del nivel
    public GameObject generateLevel(string nameLevel)
    {
        //Extraemos el XML y lo deserializamos
        TextAsset xmlTextAsset = (TextAsset)Resources.Load("LevelsXML/"+nameLevel, typeof(TextAsset));
        StringReader stream = new StringReader(xmlTextAsset.text);
        XmlSerializer s = new XmlSerializer(typeof(structureXML));
        m_structureXML = s.Deserialize(stream) as structureXML;

        //Creamos un gameObject vacio que representará el nivel
        GameObject goLevel = new GameObject(nameLevel);
        goLevel.transform.position = Vector3.zero;
        goLevel.transform.parent = Managers.GetInstance.SceneMgr.rootScene.transform;

        Managers.GetInstance.TimeMgr.seconds = m_structureXML.time.seconds;
        Managers.GetInstance.SceneMgr.spawnPointPlayer = new Vector3(m_structureXML.spawnPoint.x, m_structureXML.spawnPoint.y, 0);

        //Creamos cada uno de los items definidos en el XML en la posicion alli indicada, con el scale alli indicado.
        foreach (structureXML.Item go in m_structureXML.prefabs.items)
        {
            GameObject newGO = Managers.GetInstance.SpawnerMgr.createGameObject(Resources.Load("Prefabs/GamePrefabs/" + go.prefab) as GameObject, new Vector3(go.x, go.y, 0), Quaternion.identity);
            newGO.transform.localScale = new Vector3(go.scaleX, go.scaleY, 1);
            //Finalmente como padre ponemos al gameObject que representa el nivel
            newGO.transform.parent = goLevel.transform;
        }

        return goLevel;
    }
开发者ID:cesarpazguzman,项目名称:platform2DUnity,代码行数:28,代码来源:createLevelFromXML.cs


示例11: Deserialize

 object Deserialize(string messageBody, Type objectType)
 {
     using (StringReader textReader = new StringReader(messageBody))
     {
         return serializer.Deserialize(textReader, objectType);
     }
 }
开发者ID:fivec,项目名称:docs.particular.net,代码行数:7,代码来源:OwinToBus.cs


示例12: Parse

        /// <summary>
        /// Parses LSUB response from lsub-response string.
        /// </summary>
        /// <param name="lSubResponse">LSub response string.</param>
        /// <returns>Returns parsed lsub response.</returns>
        /// <exception cref="ArgumentNullException">Is raised when <b>lSubResponse</b> is null reference.</exception>
        public static IMAP_r_u_LSub Parse(string lSubResponse)
        {
            if(lSubResponse == null){
                throw new ArgumentNullException("lSubResponse");
            }

            /* RFC 3501 7.2.3. LSUB Response.
                Contents:   name attributes
                            hierarchy delimiter
                            name

                The LSUB response occurs as a result of an LSUB command.  It
                returns a single name that matches the LSUB specification.  There
                can be multiple LSUB responses for a single LSUB command.  The
                data is identical in format to the LIST response.

                Example:    S: * LSUB () "." #news.comp.mail.misc
            */

            StringReader r = new StringReader(lSubResponse);
            // Eat "*"
            r.ReadWord();
            // Eat "LSUB"
            r.ReadWord();

            string attributes = r.ReadParenthesized();
            string delimiter  = r.ReadWord();
            string folder     = TextUtils.UnQuoteString(IMAP_Utils.DecodeMailbox(r.ReadToEnd().Trim()));

            return new IMAP_r_u_LSub(folder,delimiter[0],attributes == string.Empty ? new string[0] : attributes.Split(' '));
        }
开发者ID:CivilPol,项目名称:LumiSoft.Net,代码行数:37,代码来源:IMAP_r_u_LSub.cs


示例13: Parse

        /// <summary>
        /// Parses media from "t" SDP message field.
        /// </summary>
        /// <param name="tValue">"t" SDP message field.</param>
        /// <returns></returns>
        public static SDP_Time Parse(string tValue)
        {
            // t=<start-time> <stop-time>

            SDP_Time time = new SDP_Time();

            // Remove t=
            StringReader r = new StringReader(tValue);
            r.QuotedReadToDelimiter('=');

            //--- <start-time> ------------------------------------------------------------
            string word = r.ReadWord();
            if(word == null){
                throw new Exception("SDP message \"t\" field <start-time> value is missing !");
            }
            time.m_StartTime = Convert.ToInt64(word);

            //--- <stop-time> -------------------------------------------------------------
            word = r.ReadWord();
            if(word == null){
                throw new Exception("SDP message \"t\" field <stop-time> value is missing !");
            }
            time.m_StopTime = Convert.ToInt64(word);

            return time;
        }
开发者ID:janemiceli,项目名称:authenticated_mail_server,代码行数:31,代码来源:SDP_Time.cs


示例14: testStemming

 //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
 //ORIGINAL LINE: public void testStemming() throws Exception
 public virtual void testStemming()
 {
     Reader reader = new StringReader("abc");
     TokenStream stream = new MockTokenizer(reader, MockTokenizer.WHITESPACE, false);
     stream = tokenFilterFactory("HunspellStem", "dictionary", "simple.dic", "affix", "simple.aff").create(stream);
     assertTokenStreamContents(stream, new string[] {"ab"});
 }
开发者ID:WakeflyCBass,项目名称:lucenenet,代码行数:9,代码来源:TestHunspellStemFilterFactory.cs


示例15: Start

    // Use this for initialization
    void Start()
    {
        //DELETE THIS BEFORE RELEASE

        Data temp = GameObject.FindGameObjectWithTag("Load").GetComponent<Data>();
        Debug.Log("1");
        if (!temp.loaded)
        {
            Debug.Log("2");
            string s = PlayerPrefs.GetString(ADDRESS, "FIRST!");
            Debug.Log(s);
            if (!s.Equals("FIRST!"))
            {

                StringReader status = new StringReader(s);
                stats = (SavedData)serialize.Deserialize(status);
                Debug.Log(stats.gold);
            }
            else
            {
                stats = new SavedData();
                Debug.Log("no");
            }
            temp.setStats(stats);
        }
    }
开发者ID:Zror,项目名称:DatRepo,代码行数:27,代码来源:xmlLoadingClass.cs


示例16: Parse

        /// <summary>
        /// Parses media from "a" SDP message field.
        /// </summary>
        /// <param name="aValue">"a" SDP message field.</param>
        /// <returns></returns>
        public static SDP_Attribute Parse(string aValue)
        {
            // a=<attribute>
            // a=<attribute>:<value>

            // Remove a=
            StringReader r = new StringReader(aValue);
            r.QuotedReadToDelimiter('=');

            //--- <attribute> ------------------------------------------------------------
            string name = "";
            string word = r.QuotedReadToDelimiter(':');
            if (word == null)
            {
                throw new Exception("SDP message \"a\" field <attribute> name is missing !");
            }
            name = word;

            //--- <value> ----------------------------------------------------------------
            string value = "";
            word = r.ReadToEnd();
            if (word != null)
            {
                value = word;
            }

            return new SDP_Attribute(name, value);
        }
开发者ID:Inzaghi2012,项目名称:teamlab.v7.5,代码行数:33,代码来源:SDP_Attribute.cs


示例17: testEmails

 // Test with some emails from TestUAX29URLEmailTokenizer's
 // email.addresses.from.random.text.with.email.addresses.txt
 //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
 //ORIGINAL LINE: public void testEmails() throws Exception
 public virtual void testEmails()
 {
     string textWithEmails = " some extra\nWords thrown in here. " + "[email protected]\n" + "[email protected][082.015.228.189]\n" + "\"%U\[email protected]?\\B\"@Fl2d.md" + " samba Halta gamba " + "Bvd#@tupjv.sn\n" + "SBMm0Nm.oyk70.rMNdd8k.#[email protected]\n" + "[email protected]\n" + " inter Locutio " + "C'ts`@Vh4zk.uoafcft-dr753x4odt04q.UY\n" + "}[email protected]" + " blah Sirrah woof " + "lMahAA.j/[email protected]\n" + "lv'[email protected]\n";
     Reader reader = new StringReader(textWithEmails);
     TokenStream stream = tokenizerFactory("UAX29URLEmail").create(reader);
     assertTokenStreamContents(stream, new string[] {"some", "extra", "Words", "thrown", "in", "here", "[email protected]", "[email protected][082.015.228.189]", "\"%U\[email protected]?\\B\"@Fl2d.md", "samba", "Halta", "gamba", "Bvd#@tupjv.sn", "SBMm0Nm.oyk70.rMNdd8k.#[email protected]", "[email protected]", "inter", "Locutio", "C'ts`@Vh4zk.uoafcft-dr753x4odt04q.UY", "}[email protected]", "blah", "Sirrah", "woof", "lMahAA.j/[email protected]", "lv'[email protected]"});
 }
开发者ID:WakeflyCBass,项目名称:lucenenet,代码行数:11,代码来源:TestUAX29URLEmailTokenizerFactory.cs


示例18: OnHandleResponse

    public override void OnHandleResponse(OperationResponse response)
    {

        NetworkManager view = _controller.ControlledView as NetworkManager;
        view.LogDebug("GOT A RESPONSE for KNOWN STARS");
        if (response.ReturnCode == 0)
        {
            view.LogDebug(response.Parameters[(byte)ClientParameterCode.KnownStars].ToString());

            // Deserialize
            var xmlData = response.Parameters[(byte)ClientParameterCode.KnownStars].ToString();
            XmlSerializer deserializer = new XmlSerializer(typeof(XmlStarPlayerList));
            TextReader reader = new StringReader(xmlData);
            object obj = deserializer.Deserialize(reader);
            XmlStarPlayerList starCollection = (XmlStarPlayerList)obj;
            reader.Close();

            List<KnownStar> stars = new List<KnownStar>();
            foreach (SanStarPlayer s in starCollection.StarPlayers)
                stars.Add(new KnownStar(s));

            // Update local data
            PlayerData.instance.UpdateKnownStars(stars);
        }
        else
        {
            view.LogDebug("RESPONSE: " + response.DebugMessage);
            DisplayManager.Instance.DisplayMessage(response.DebugMessage);
        }
    }
开发者ID:seanbraley,项目名称:PocketCosmos,代码行数:30,代码来源:KnownStarsResponseHandler.cs


示例19: testNormalizer

 /// <summary>
 /// Test ArabicNormalizationFilterFactory
 /// </summary>
 //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
 //ORIGINAL LINE: public void testNormalizer() throws Exception
 public virtual void testNormalizer()
 {
     Reader reader = new StringReader("الذين مَلكت أيمانكم");
     Tokenizer tokenizer = tokenizerFactory("Standard").create(reader);
     TokenStream stream = tokenFilterFactory("ArabicNormalization").create(tokenizer);
     assertTokenStreamContents(stream, new string[] {"الذين", "ملكت", "ايمانكم"});
 }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:12,代码来源:TestArabicFilters.cs


示例20: testStemming

 /// <summary>
 /// Ensure the filter actually stems and normalizes text.
 /// </summary>
 //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
 //ORIGINAL LINE: public void testStemming() throws Exception
 public virtual void testStemming()
 {
     Reader reader = new StringReader("Brasília");
     Tokenizer tokenizer = new MockTokenizer(reader, MockTokenizer.WHITESPACE, false);
     TokenStream stream = tokenFilterFactory("BrazilianStem").create(tokenizer);
     assertTokenStreamContents(stream, new string[] {"brasil"});
 }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:12,代码来源:TestBrazilianStemFilterFactory.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# StringScanner类代码示例发布时间:2022-05-24
下一篇:
C# StringParser类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap