internal void EnsureInitialized()
        {
            if (_initialized)
            {
                return;
            }

            var excludeBuiltIns = PatternsCollectionHelper.GetPatternsCollection(_rawProject, _projectDirectory, _projectFilePath, "excludeBuiltIn", DefaultBuiltInExcludePatterns);
            var excludePatterns = PatternsCollectionHelper.GetPatternsCollection(_rawProject, _projectDirectory, _projectFilePath, "exclude")
                                  .Concat(excludeBuiltIns);
            var contentBuiltIns  = PatternsCollectionHelper.GetPatternsCollection(_rawProject, _projectDirectory, _projectFilePath, "contentBuiltIn", DefaultContentsBuiltInPatterns);
            var compileBuiltIns  = PatternsCollectionHelper.GetPatternsCollection(_rawProject, _projectDirectory, _projectFilePath, "compileBuiltIn", DefaultCompileBuiltInPatterns);
            var resourceBuiltIns = PatternsCollectionHelper.GetPatternsCollection(_rawProject, _projectDirectory, _projectFilePath, "resourceBuiltIn", DefaultResourcesBuiltInPatterns);

            _publishExcludePatterns = PatternsCollectionHelper.GetPatternsCollection(_rawProject, _projectDirectory, _projectFilePath, "publishExclude", DefaultPublishExcludePatterns);

            _sharedPatternsGroup = PatternGroup.Build(_rawProject, _projectDirectory, _projectFilePath, "shared", fallbackIncluding: DefaultSharedPatterns, additionalExcluding: excludePatterns);

            _resourcePatternsGroup = PatternGroup.Build(_rawProject, _projectDirectory, _projectFilePath, "resource", additionalIncluding: resourceBuiltIns, additionalExcluding: excludePatterns);

            _preprocessPatternsGroup = PatternGroup.Build(_rawProject, _projectDirectory, _projectFilePath, "preprocess", fallbackIncluding: DefaultPreprocessPatterns, additionalExcluding: excludePatterns)
                                       .ExcludeGroup(_sharedPatternsGroup)
                                       .ExcludeGroup(_resourcePatternsGroup);

            _compilePatternsGroup = PatternGroup.Build(_rawProject, _projectDirectory, _projectFilePath, "compile", additionalIncluding: compileBuiltIns, additionalExcluding: excludePatterns)
                                    .ExcludeGroup(_sharedPatternsGroup)
                                    .ExcludeGroup(_preprocessPatternsGroup)
                                    .ExcludeGroup(_resourcePatternsGroup);

            _contentPatternsGroup = PatternGroup.Build(_rawProject, _projectDirectory, _projectFilePath, "content", additionalIncluding: contentBuiltIns, additionalExcluding: _publishExcludePatterns);

            _namedResources = NamedResourceReader.ReadNamedResources(_rawProject, _projectFilePath);

            // Files to be packed along with the project
            var packIncludeJson = _rawProject.Value <JToken>(PackIncludePropertyName) as JObject;

            if (packIncludeJson != null)
            {
                var packIncludeEntries = new List <PackIncludeEntry>();
                foreach (var token in packIncludeJson)
                {
                    packIncludeEntries.Add(new PackIncludeEntry(token.Key, token.Value));
                }

                _packInclude = packIncludeEntries;
            }
            else
            {
                _packInclude = new List <PackIncludeEntry>();
            }

            _initialized = true;
            _rawProject  = null;
        }
        public IEnumerable <string> GetContentFiles(IEnumerable <string> additionalExcludePatterns = null)
        {
            var patternGroup = new PatternGroup(ContentPatternsGroup.IncludePatterns,
                                                ContentPatternsGroup.ExcludePatterns.Concat(additionalExcludePatterns ?? new List <string>()),
                                                ContentPatternsGroup.IncludeLiterals);

            foreach (var excludedGroup in ContentPatternsGroup.ExcludePatternsGroup)
            {
                patternGroup.ExcludeGroup(excludedGroup);
            }

            return(patternGroup.SearchFiles(_projectDirectory));
        }
        public PatternGroup ExcludeGroup(PatternGroup group)
        {
            _excludeGroups.Add(group);

            return(this);
        }