Complement(
     TokenizedStringArray other)
 {
     return(new TokenizedStringArray(base.Complement(other)));
 }
 Intersect(
     TokenizedStringArray other)
 {
     return(new TokenizedStringArray(base.Intersect(other)));
 }
        CreateInternal(
            string tokenizedString,
            Module macroSource,
            bool verbatim,
            TokenizedStringArray positionalTokens,
            EFlags flags)
        {
            if (null == tokenizedString)
            {
                return null;
            }

            // strings can be created during the multithreaded phase
            lock (Cache)
            {
                if (0 == (flags & EFlags.NoCache))
                {
                    var search = Cache.Where((ts) =>
                    {
                        // first check the simple states for equivalence
                        if (ts.OriginalString == tokenizedString && ts.ModuleWithMacros == macroSource && ts.Verbatim == verbatim)
                        {
                            // and then check the positional tokens, if they exist
                            var samePosTokenCount = ((null != positionalTokens) && (positionalTokens.Count() == ts.PositionalTokens.Count())) ||
                                                    ((null == positionalTokens) && (0 == ts.PositionalTokens.Count()));
                            if (!samePosTokenCount)
                            {
                                return false;
                            }
                            for (int i = 0; i < ts.PositionalTokens.Count(); ++i)
                            {
                                // because positional tokens are TokenizedStrings, they will refer to the same object
                                if (ts.PositionalTokens[i] != positionalTokens[i])
                                {
                                    return false;
                                }
                            }
                            return true;
                        }
                        else
                        {
                            return false;
                        }
                    });
                    var foundTS = search.FirstOrDefault();
                    if (null != foundTS)
                    {
                        ++foundTS.RefCount;
                        return foundTS;
                    }
                }
                var newTS = new TokenizedString(tokenizedString, macroSource, verbatim, positionalTokens, flags);
                Cache.Add(newTS);
                return newTS;
            }
        }
 Create(
     string tokenizedString,
     Module macroSource,
     TokenizedStringArray positionalTokens = null)
 {
     return CreateInternal(tokenizedString, macroSource, false, positionalTokens, EFlags.None);
 }
 private TokenizedString(
     string original,
     Module moduleWithMacros,
     bool verbatim,
     TokenizedStringArray positionalTokens,
     EFlags flags)
 {
     this.CreationStackTrace = System.Environment.StackTrace;
     this.ModuleWithMacros = moduleWithMacros;
     if (null != positionalTokens)
     {
         this.PositionalTokens.AddRange(positionalTokens);
     }
     this.Verbatim = verbatim;
     this.Flags |= flags;
     this.OriginalString = original;
     if (verbatim)
     {
         this.ParsedString = NormalizeDirectorySeparators(original);
         return;
     }
 }