Пример #1
0
        public HashSet <string> FlatProjectDependency()
        {
            var hashSet = new HashSet <string>();

            Horizontals.ForAll(h =>
            {
                hashSet.Add(h.ProjectName);
                h.Project
                .FlatProjectDependency()
                .ForAll(hfpd => hashSet.Add(hfpd));
            });
            Verticals.ForAll(v =>
            {
                hashSet.Add(v.ProjectName);
                v.Project
                .FlatProjectDependency()
                .ForAll(vfpd => hashSet.Add(vfpd));
            });
            PlainProjectRefs.ForAll(p =>
            {
                hashSet.Add(p.ProjectName);
                p.Project
                .FlatProjectDependency()
                .ForAll(pfpd => hashSet.Add(pfpd));
            });

            return(hashSet);
        }
Пример #2
0
        public LogiConverter()
        {
            var puzzles = new Logi.Common.Puzzles();

            _puzzle = puzzles.Puzzle2;

            int line = 0;

            foreach (var horizontals in _puzzle.Horizontal)
            {
                foreach (var horizontal in horizontals)
                {
                    Horizontals.Add(new CellModel(CellTypes.Digit, horizontal, line));
                }
                line += 1;
            }

            foreach (var verticals in _puzzle.Vertical)
            {
                foreach (var vertical in verticals)
                {
                    Verticals.Add(new CellModel(CellTypes.Digit, vertical, line));
                }
                line += 1;
            }
        }
Пример #3
0
        private List <Cell[]> GetSections()
        {
            var sections = Horizontals.ToList();

            sections.AddRange(Verticals);
            sections.AddRange(SubGrids);
            return(sections);
        }
Пример #4
0
        public List <Cell> GetDomainCells(Cell cell)
        {
            var cells = new List <Cell>();

            cells.AddRange(Verticals.First(v => v.Contains(cell)));
            cells.AddRange(Horizontals.First(v => v.Contains(cell)));
            cells.AddRange(SubGrids.First(v => v.Contains(cell)));

            return(cells.Distinct().ToList());
        }
Пример #5
0
        private void ResolveDependentProjects(DependencyContext context)
        {
            //first resolve the projects
            Verticals.ForAll(v =>
            {
                v.Project = context.ProjectTable.GetOrAdd(
                    v.ProjectName,
                    _ => new Project(new FileInfo(v.ProjectPath), context));
            });
            Horizontals.ForAll(h =>
            {
                h.Project = context.ProjectTable.GetOrAdd(
                    h.ProjectName,
                    _ => new Project(new FileInfo(h.ProjectPath), context));
            });
            PlainProjectRefs.ForAll(p =>
            {
                p.Project = context.ProjectTable.GetOrAdd(
                    p.ProjectName,
                    _ => new Project(new FileInfo(p.ProjectPath), context));
            });

            //now remove transient references
            var refs = new HashSet <string>(Horizontals
                                            .SelectMany(h => h.Project.FlatProjectDependency())
                                            .Concat(Verticals
                                                    .SelectMany(v => v.Project.FlatProjectDependency())
                                                    .Concat(PlainProjectRefs
                                                            .SelectMany(p => p.Project.FlatProjectDependency()))));

            Verticals.ToArray().ForAll(v =>
            {
                if (refs.Contains(v.ProjectName))
                {
                    Verticals.Remove(v);
                }
            });

            Horizontals.ToArray().ForAll(h =>
            {
                if (refs.Contains(h.ProjectName))
                {
                    Horizontals.Remove(h);
                }
            });

            PlainProjectRefs.ToArray().ForAll(p =>
            {
                if (refs.Contains(p.ProjectName))
                {
                    PlainProjectRefs.Remove(p);
                }
            });
        }
Пример #6
0
 static public IEnumerable <Horizontal> ToValues(this Horizontals flags)
 {
     if ((flags & Horizontals.Left) != 0)
     {
         yield return(Horizontal.Left);
     }
     if ((flags & Horizontals.Right) != 0)
     {
         yield return(Horizontal.Right);
     }
 }
Пример #7
0
        static public Horizontals Opposite(this Horizontals flags)
        {
            var result = Horizontals.None;

            if ((flags & Horizontals.Left) != 0)
            {
                result |= Horizontals.Right;
            }
            if ((flags & Horizontals.Right) != 0)
            {
                result |= Horizontals.Left;
            }
            return(result);
        }
Пример #8
0
        public void Load(string formattedTileName)
        {
            BinaryReader reader = new BinaryReader(File.OpenRead(FilePaths.PathToUnityStreaming + "/TILECONFIGS/" + formattedTileName + ".DWB"));

            reader.BaseStream.Position += 4;
            int verticalCount   = reader.ReadInt32();
            int horizontalCount = reader.ReadInt32();

            reader.Close();

            string prefix = Environment.CurrentDirectory + "/" + FilePaths.PathToUnityTileResources + formattedTileName + "/";

            for (int i = 0; i < verticalCount; i++)
            {
                Verticals.Add(prefix + "VERTICAL_" + i + ".png");
            }
            for (int i = 0; i < horizontalCount; i++)
            {
                Horizontals.Add(prefix + "HORIZONTAL_" + i + ".png");
            }
        }
Пример #9
0
 public void CalculationOneTimeGroup()
 {
     Horizontals.ForEach(gc => CalcCellCollection(gc));
     Verticals.ForEach(gc => CalcCellCollection(gc));
     Squares.ForEach(gc => CalcCellCollection(gc));
 }
Пример #10
0
        private void BuildFromNewCsproj()
        {
            var propGroup = CsprojDoc.Root
                            .FindAll("PropertyGroup")
                            .First(Ext.ContainsProjectInfo);

            //build info
            typeof(ProjectInfo)
            .GetProperties()
            .Select(prop => new { Prop = prop, Element = propGroup.Find(prop.Name) })
            .Where(map => map.Element != null)
            .ForAll(map => map.Prop.SetValue(Info, map.Element.Value));
            Info.AssemblyName = CsprojFile.Name.TrimEnd(CsprojFile.Extension);

            //build dependencies
            //1. assembly references
            CsprojDoc.Root
            .FindAll("ItemGroup/Reference")
            .ForAll(element => Assemblies.Add(new AssemblyDependencyRef
            {
                ProjectName = element.Attribute("Include").Value
            }));

            //2. external packages
            CsprojDoc.Root
            .FindAll("ItemGroup/PackageReference")
            .Where(IsExternalPackageReference)
            .ForAll(element => ExternalPackages.Add(new PackageDependencyRef
            {
                ProjectName = element.Attribute("Include").Value,
                Version     = SemVerRange.Parse(element.Attribute("Version").Value)
            }));

            //3. horizontal project references
            CsprojDoc.Root
            .FindAll("ItemGroup/ProjectReference")
            .Where(IsHorizontalProjectReference)
            .ForAll(element =>
            {
                var path        = element.Attribute("Include").Value;
                var projectName = path.ExtractProjectNameFromFilePath();
                var versionArg  = ResolveHorizontalVersionArg(new FileInfo(path));
                Horizontals.Add(new ObgDependencyRef
                {
                    ProjectPath = path,
                    ProjectName = projectName,
                    Version     = SemVerRange.Parse(propGroup.Find(versionArg).Value)
                });
            });

            //4. vertical project references
            CsprojDoc.Root
            .FindAll("ItemGroup/ProjectReference")
            .Where(IsVerticalProjectReference)
            .ForAll(element =>
            {
                var path        = element.Attribute("Include").Value;
                var projectName = path.ExtractProjectNameFromFilePath();
                Verticals.Add(new ObgDependencyRef
                {
                    ProjectPath = path,
                    ProjectName = projectName
                });
            });

            //5. plain project reference
            CsprojDoc.Root
            .FindAll("ItemGroup/ProjectReference")
            .Where(IsPlainProjectReference)
            .ForAll(element =>
            {
                var path        = element.Attribute("Include").Value;
                var projectName = path.ExtractProjectNameFromFilePath();
                PlainProjectRefs.Add(new PlainProjectRef
                {
                    ProjectPath = path,
                    ProjectName = projectName
                });
            });
        }
Пример #11
0
        private void BuildFromOldCsproj()
        {
            var nuspecFile = new FileInfo(Ext.ResolveNuspecPath(CsprojFile));
            var nuspecDoc  = nuspecFile.Exists
                ? nuspecFile.OpenRead().Using(XDocument.Load)
                : null;

            #region Generate project Info
            Info.AssemblyName =
                nuspecDoc?.Root.Find("metadata/id").Value
                ?? CsprojDoc.Root.Find("PropertyGroup/AssemblyName").Value;

            var textInfo = new CultureInfo("en-US", false).TextInfo;
            Info.Product = textInfo.ToTitleCase(Info.AssemblyName);

            Info.Authors = "OBG Api";

            Info.Company =
                nuspecDoc?.Root.Find("metadata/owners")?.Value
                ?? "Betsson Group";

            Info.Copyright = $"Copyright © {DateTimeOffset.Now.Year}";

            Info.Description = nuspecDoc?.Root.Find("metadata/description")?.Value;

            Info.PackageReleaseNotes = nuspecDoc?.Root.Find("metadata/releaseNotes")?.Value;

            Info.PackageTags = nuspecDoc?.Root.Find("metadata/tags")?.Value;

            Info.PackageProjectUrl = nuspecDoc?.Root.Find("metadata/projectUrl")?.Value;

            Info.PackageIconUrl = nuspecDoc?.Root.Find("metadata/iconUrl")?.Value;
            #endregion

            //dependencies
            //1. assembly references
            CsprojDoc.Root
            .FindAll("ItemGroup/Reference")
            .Where(IsGacReference)
            .ForAll(element => Assemblies.Add(new AssemblyDependencyRef
            {
                ProjectName = element.Attribute("Include").Value
            }));

            //2. external packages
            CsprojDoc.Root
            .FindAll("ItemGroup/Reference")
            .Where(IsExternalNuspecDependency)
            .ForAll(element =>
            {
                var assembly = element.Attribute("Include").Value
                               .Split(',')
                               .First();

                var dependency = nuspecDoc?.Root
                                 .FindAll(
                    "metadata/dependencies/dependency",
                    "metadata/dependencies/group/dependency")
                                 .FirstOrDefault(Ext.HasAttribute("id", assembly));

                if (dependency != null)
                {
                    var version = dependency.Attribute("version").Value;
                    ExternalPackages.Add(new PackageDependencyRef
                    {
                        ProjectName = assembly,
                        Version     = string.IsNullOrWhiteSpace(version) ? null : SemVerRange.Parse(version)
                    });
                }

                //else this is a transitive dependency; ignore it.
            });

            //3. horizontal project reference
            //check the project references and determine, using the solution name, which are, and which aren't
            //horizontal references. Then check the nuspec file to determine the version to use
            CsprojDoc.Root
            .FindAll("ItemGroup/ProjectReference")
            .Where(IsOldHorizontalProjectReference)
            .ForAll(element =>
            {
                var path       = element.Attribute("Include").Value;
                var assembly   = path.ExtractProjectNameFromFilePath();
                var dependency = nuspecDoc?.Root
                                 .FindAll(
                    "metadata/dependencies/group/dependency",
                    "metadata/dependencies/dependency")
                                 .FirstOrDefault(Ext.HasAttribute("id", assembly));

                if (dependency != null)
                {
                    var version = dependency
                                  .Attribute("version")
                                  .Value;

                    Horizontals.Add(new ObgDependencyRef
                    {
                        ProjectPath = path,
                        ProjectName = assembly,
                        Version     = string.IsNullOrWhiteSpace(version) ? null : SemVerRange.Parse(version)
                    });
                }

                //else it is a transitive dependency; ignore it.
                //{
                //    PlainProjectRefs.Add(new PlainProjectRef
                //    {
                //        ProjectName = assembly,
                //        ProjectPath = path
                //    });
                //}
            });

            //4. vertical project references
            //check the project references and determine, using the solution name, which are, and whicha aren't
            //vertical references.
            CsprojDoc.Root
            .FindAll("ItemGroup/ProjectReference")
            .Where(IsOldVerticalProjectReference)
            .ForAll(element =>
            {
                var path        = element.Attribute("Include").Value;
                var projectName = path.ExtractProjectNameFromFilePath();
                Verticals.Add(new ObgDependencyRef
                {
                    ProjectPath = path,
                    ProjectName = projectName
                });
            });
        }