示例#1
0
        public static void AddRange(this List <string> list, Particle particle, IEnumerable <string> strings, string format, IFormatProvider formatProvider, bool hasParent)
        {
            int i = 0;

            foreach (string s in strings)
            {
                i++;
                if (particle.MiddleOnly)
                {
                    //more than 1? must join!
                    //0? Well, depends on where we are. If we have a parent, must join
                    if (i > 1 || hasParent)
                    {
                        if (list.Count > 0)
                        {
                            string lastWord = list[list.Count - 1];

                            if (!Token.CheckIsParticle(lastWord) && !Token.CheckIsConjunction(lastWord))
                            {
                                list.AddIfNotReduplicate(particle.ToString(format, formatProvider));
                            }
                        }
                    }
                }
                else
                {
                    if (list.Count > 0)
                    {
                        string lastWord = list[list.Count - 1];
                        if ((!Particle.CheckIsParticle(lastWord) && !Token.CheckIsConjunction(lastWord)))
                        {
                            list.AddIfNotReduplicate(particle.ToString(format, formatProvider));
                        }
                    }
                    else if (list.Count == 0)
                    {
                        list.AddIfNotReduplicate(particle.ToString(format, formatProvider));
                    }
                }
                list.Add(s);
            }
        }