GetToken() public method

public GetToken ( ) : string
return string
Ejemplo n.º 1
0
        public void TestGetToken()
        {
            m_TokenSet.Tokens.Add("a");
            m_Random.ExpectAndReturn("Next", 0, 1);
            Assert.AreEqual("a", m_TokenSet.GetToken());

            m_TokenSet.Tokens.Add("b");
            m_Random.ExpectAndReturn("Next", 0, 2);
            Assert.AreEqual("a", m_TokenSet.GetToken());

            m_Random.ExpectAndReturn("Next", 1, 2);
            Assert.AreEqual("b", m_TokenSet.GetToken());
        }
Ejemplo n.º 2
0
        public override void Execute(Context context)
        {
            TokenSet ts = Project.TokenSets.FindByName(this.TokenSet);

            if (ts != null)
            {
                context.Tokens.Insert(0, ts.GetToken());
            }
        }
Ejemplo n.º 3
0
        private string ExpandReplacement(string[] destination, Match m)
        {
            List <string> result = new List <string>();

            foreach (string token in destination)
            {
                int tokenId;
                if (token.StartsWith("\\") && int.TryParse(token.Substring(1), out tokenId))
                {
                    result.Add(m.Groups[tokenId].Value);
                }
                else if (token.StartsWith("$"))
                {
                    result.Add(Project.TokenSets.FindByName(token.Substring(1)).GetToken());
                }
                else if (token.StartsWith("["))
                {
                    List <string> tokens = ProjectSerializer.ReadTokens(token.Substring(1, token.Length - 2));

                    TokenSet ts = Project.CreateTokenSet();

                    foreach (string t in tokens)
                    {
                        ts.Tokens.AddRange(ExpandTokenSet(t, true).Split('|'));
                    }

                    result.Add(ts.GetToken());
                }
                else
                {
                    result.Add(token);
                }
            }

            return("|" + string.Join("|", result.ToArray()) + "|");
        }
Ejemplo n.º 4
0
    private string ExpandReplacement(string[] destination, Match m)
    {
        List<string> result = new List<string>();

        foreach (string token in destination) {
            int tokenId;
            if (token.StartsWith("\\") && int.TryParse(token.Substring(1), out tokenId)) {
                result.Add(m.Groups[tokenId].Value);
            }
            else if (token.StartsWith("$")) {
                result.Add(Project.TokenSets.FindByName(token.Substring(1)).GetToken());
            }
            else if (token.StartsWith("[")) {
                List<string> tokens = ProjectSerializer.ReadTokens(token.Substring(1, token.Length - 2));

                TokenSet ts = new TokenSet();

                foreach (string t in tokens) {
                    ts.Tokens.AddRange(ExpandTokenSet(t, true).Split('|'));
                }

                result.Add(ts.GetToken());
            }
            else {
                result.Add(token);
            }
        }

        return "|" + string.Join("|", result.ToArray()) + "|";
    }