Exemple #1
0
        private ICollection <CubePosition> DoCycles(ICollection <CubePosition> activeCubes,
                                                    bool includeW)
        {
            ICollection <CubePosition> newState  = new ConcurrentHashSet <CubePosition>();
            ICollection <CubePosition> mayActive = new ConcurrentHashSet <CubePosition>();

            activeCubes.AsParallel().ForAll(currentCube =>
            {
                int active = 0;

                foreach (var toCheckPos in GetNeighbors(currentCube, new CubePosition(), includeW))
                {
                    if (toCheckPos.Equals(currentCube))
                    {
                        continue;
                    }
                    if (activeCubes.Contains(toCheckPos))
                    {
                        active++;
                    }
                    else
                    {
                        mayActive.Add(new CubePosition
                        {
                            X = toCheckPos.X,
                            Y = toCheckPos.Y,
                            Z = toCheckPos.Z,
                            W = toCheckPos.W
                        });
                    }
                }

                if (active >= 2 && active <= 3)
                {
                    newState.Add(currentCube);
                }
            });

            mayActive.AsParallel().ForAll(currentCube =>
            {
                int active = GetNeighbors(currentCube, new CubePosition(), includeW)
                             .Where(toCheckPos => !toCheckPos.Equals(currentCube))
                             .Count(activeCubes.Contains);

                if (active == 3)
                {
                    newState.Add(currentCube);
                }
            });

            return(newState);
        }
Exemple #2
0
        public void ProcessAssembliesAndContent()
        {
            List <DirectoryPath> contentPaths = _packageIdentities
                                                .AsParallel()
                                                .SelectMany(packageIdentity =>
            {
                DirectoryPath installedPath        = new DirectoryPath(GetInstalledPath(packageIdentity));
                string packageFilePath             = GetInstalledPackageFilePath(packageIdentity);
                PackageArchiveReader archiveReader = new PackageArchiveReader(packageFilePath, null, null);
                AddReferencedAssemblies(installedPath, archiveReader);
                return(GetContentDirectories(installedPath, archiveReader));
            })
                                                .ToList();

            foreach (DirectoryPath contentPath in contentPaths)
            {
                _fileSystem.InputPaths.Insert(0, contentPath);
                Trace.Verbose($"Added content path {contentPath} to included paths");
            }
        }