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; } }
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"); } }
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 }); }); }
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 }); }); }