private void BuildInstructionsForOneToken(IList <FormattedSentence.IInstructionQueueMember> instructionQueue, FormattedSentence.Token token)
        {
            FormattedSentence.Sentence    sentence    = token as FormattedSentence.Sentence;
            FormattedSentence.SimpleToken simpleToken = token as FormattedSentence.SimpleToken;
            if (sentence != null)
            {
                this.BuildInstructionQueue(instructionQueue, sentence);
                return;
            }
            if (simpleToken == null)
            {
                return;
            }
            switch (simpleToken.Flavor)
            {
            case FormattedSentence.SimpleToken.TokenFlavor.None:
                instructionQueue.Add(new FormattedSentence.StringConstant(simpleToken.Value));
                return;

            case FormattedSentence.SimpleToken.TokenFlavor.InCurlyBraces:
                instructionQueue.Add(new FormattedSentence.ResolvePlaceholder(simpleToken.Value));
                return;

            default:
                throw new NotSupportedException("Token flavor is not supported");
            }
        }
 private static bool AddToken(IList <FormattedSentence.Token> tokens, int endAt, ref FormattedSentence.SimpleToken.Builder tokenBuilder)
 {
     if (tokenBuilder.IsValid)
     {
         FormattedSentence.SimpleToken simpleToken = tokenBuilder.Create(endAt);
         if (simpleToken != null)
         {
             tokens.Add(simpleToken);
         }
         tokenBuilder.Invalidate();
         return(simpleToken != null);
     }
     return(false);
 }
        protected void BuildInstructionQueue(IList <FormattedSentence.IInstructionQueueMember> instructionQueue, FormattedSentence.Sentence sentence)
        {
            if (sentence.Tokens.Count == 0)
            {
                instructionQueue.Add(FormattedSentence.StringConstant.EmptySpacer);
                return;
            }
            if (sentence.Tokens.Count == 1)
            {
                this.BuildInstructionsForOneToken(instructionQueue, sentence.Tokens[0]);
                return;
            }
            bool flag = false;
            int  num  = 0;

            for (int i = 0; i < sentence.Tokens.Count; i++)
            {
                FormattedSentence.SimpleToken simpleToken = sentence.Tokens[i] as FormattedSentence.SimpleToken;
                bool flag2 = simpleToken != null && simpleToken.Flavor == FormattedSentence.SimpleToken.TokenFlavor.None;
                if (i == 0 && flag2)
                {
                    instructionQueue.Add(FormattedSentence.StringConstant.Null);
                    num++;
                }
                if (i > 0 && !flag && !flag2)
                {
                    instructionQueue.Add(FormattedSentence.StringConstant.EmptySpacer);
                    num++;
                }
                this.BuildInstructionsForOneToken(instructionQueue, sentence.Tokens[i]);
                num++;
                flag = flag2;
            }
            if (flag)
            {
                instructionQueue.Add(FormattedSentence.StringConstant.Null);
                num++;
            }
            int num2 = (num - 1) / 2;

            for (int j = 0; j < num2; j++)
            {
                instructionQueue.Add(new FormattedSentence.ConditionalDelimiter());
            }
        }