コード例 #1
0
        public ModInfo(string path)
        {
            RootPath = DirectoryHelper.GetExactPathName(path);

            RootFolder            = Path.GetFileName(RootPath);
            ModName               = RootFolder;
            InnerFolder           = ModName;
            SolutionName          = ModName;
            SolutionOptionsName   = ModName;
            ProjectName           = ModName;
            SourceCodeInnerFolder = ModName;
        }
コード例 #2
0
ファイル: ModProject.cs プロジェクト: danarcher/XCom2ModTool
        public void Update()
        {
            var folderPath = Path.GetDirectoryName(ModInfo.ProjectPath);

            Content = Directory.GetFiles(folderPath, "*.*", SearchOption.AllDirectories)
                      .Where(x => !x.EndsWith(ModInfo.SolutionExtension, StringComparison.OrdinalIgnoreCase) &&
                             !x.EndsWith(ModInfo.ProjectExtension, StringComparison.OrdinalIgnoreCase) &&
                             !x.EndsWith(ModInfo.SolutionOptionsExtension, StringComparison.OrdinalIgnoreCase))
                      .Select(x => DirectoryHelper.GetExactPathName(x))
                      .OrderBy(x => x)
                      .ToArray();

            Folders = Content.Select(x => Path.GetDirectoryName(x))
                      .Distinct()
                      .Where(x => !string.Equals(x, folderPath, StringComparison.OrdinalIgnoreCase))
                      .OrderBy(x => x)
                      .ToArray();
        }
コード例 #3
0
ファイル: ModProject.cs プロジェクト: danarcher/XCom2ModTool
        public static ModProject Load(ModInfo modInfo, XCom2Edition edition)
        {
            if (PathHelper.IsRelative(modInfo.ProjectPath))
            {
                throw new InvalidOperationException($"The project path is a relative path");
            }

            var document   = XDocument.Parse(File.ReadAllText(modInfo.ProjectPath));
            var properties = document.Root.GetElementsByLocalName(XmlPropertyGroup).First();

            var folderPath = Path.GetDirectoryName(modInfo.ProjectPath);
            var itemGroups = document.Root.GetElementsByLocalName(XmlItemGroup);

            var folders = itemGroups.SelectMany(x => x.GetElementsByLocalName(XmlFolder))
                          .Select(x => x.GetAttributeByLocalName(XmlInclude).Value)
                          .Select(x => PathHelper.MakeAbsolute(x, folderPath))
                          .Select(x => DirectoryHelper.GetExactPathName(x));

            var content = itemGroups.SelectMany(x => x.GetElementsByLocalName(XmlContent))
                          .Select(x => x.GetAttributeByLocalName(XmlInclude).Value)
                          .Select(x => PathHelper.MakeAbsolute(x, folderPath))
                          .Select(x => DirectoryHelper.GetExactPathName(x));

            var project = new ModProject
            {
                ModInfo        = modInfo,
                Edition        = edition,
                Id             = Guid.Parse(properties.GetElementByLocalName(XmlGuid).Value),
                Title          = properties.GetElementByLocalName(XmlTitle).Value,
                Description    = properties.GetElementByLocalName(XmlDescription).Value,
                AssemblyName   = properties.GetElementByLocalName(XmlAssemblyName).Value,
                RootNamespace  = properties.GetElementByLocalName(XmlRootNamespace).Value,
                SteamPublishId = ulong.Parse(properties.GetElementByLocalName(XmlSteamPublishId).Value, NumberStyles.None, CultureInfo.InvariantCulture),
                Folders        = folders.ToArray(),
                Content        = content.ToArray()
            };

            return(project);
        }