public async Task InstallPluginAsync(
            INuGetProjectContext projectContext,
            IEnumerable <SourceRepository> sourceRepositories,
            bool allowPrereleaseVersions        = false,
            CancellationToken cancellationToken = default)
        {
            if (_pluginHomeDirPath.Exists())
            {
                _pluginHomeDirPath.Delete();
            }

            _pluginHomeDirPath.Create();

            ResolutionContext resolutionContext = new ResolutionContext(
                DependencyBehavior.Lowest, allowPrereleaseVersions, false, VersionConstraints.None);

            await CreatePackageManager().InstallPackageAsync(
                this,
                Plugin.Identity,
                resolutionContext,
                projectContext,
                sourceRepositories,
                Array.Empty <SourceRepository>(),
                cancellationToken).ConfigureAwait(false);

            foreach (var contentDir in Plugin.GetContentDirectoryPath(this, _currentFramework))
            {
                contentDir.CopyTo(_pluginHomeDirPath);
            }

            _isInstalled = true;
        }
Ejemplo n.º 2
0
        public async Task <(string?MutagenVersion, string?SynthesisVersion)> GetLatestVersions(Version?dotNetVersion, bool includePrerelease)
        {
            try
            {
                if (dotNetVersion == null)
                {
                    Log.Logger.Error("Can not query for latest nuget versions as there is not dotnet SDK installed.");
                    return(null, null);
                }
                Log.Logger.Information("Querying for latest published library versions");
                var bootstrapProjectDir = new DirectoryPath(Path.Combine(Execution.Paths.WorkingDirectory, "VersionQuery"));
                bootstrapProjectDir.DeleteEntireFolder();
                bootstrapProjectDir.Create();
                var slnPath = Path.Combine(bootstrapProjectDir.Path, "VersionQuery.sln");
                SolutionInitialization.CreateSolutionFile(slnPath);
                var projPath = Path.Combine(bootstrapProjectDir.Path, "VersionQuery.csproj");
                SolutionInitialization.CreateProject(projPath, GameCategory.Skyrim, insertOldVersion: true);
                SolutionInitialization.AddProjectToSolution(slnPath, projPath);
                var ret = await DotNetCommands.QuerySynthesisVersions(projPath, current : false, includePrerelease : includePrerelease, CancellationToken.None);

                Log.Logger.Information("Latest published library versions:");
                Log.Logger.Information($"  Mutagen: {ret.MutagenVersion}");
                Log.Logger.Information($"  Synthesis: {ret.SynthesisVersion}");
                return(ret.MutagenVersion ?? this.MutagenVersion, ret.SynthesisVersion ?? this.SynthesisVersion);
            }
            catch (Exception ex)
            {
                Log.Logger.Error(ex, "Error querying for latest nuget versions");
                return(null, null);
            }
        }
Ejemplo n.º 3
0
        public static Scoped <DirectoryPath> GetEmptyDirectory()
        {
            var directory = new DirectoryPath(Path.GetRandomFileName());

            directory.Create();
            return(Scoped.Create(directory, () => directory.Delete()));
        }
Ejemplo n.º 4
0
 private static DirectoryPath ExtractPathFromCategory(string category)
 {
     if (string.IsNullOrWhiteSpace(category))
     {
         return(DirectoryPath.Root());
     }
     return(DirectoryPath.Create(category.Split('/')));
 }
Ejemplo n.º 5
0
 public void InitializeContext()
 {
     StarFisherContext.Instance.Initialize(
         DirectoryPath.Create(StarAwardsDirectoryPath),
         Domain.NominationListAggregate.ValueObjects.AwardsPeriod.CreateFromValue(AwardsPeriod),
         Convert(EiaCoChair1),
         Convert(EiaCoChair2),
         Convert(HrPeople),
         Convert(LuncheonPlannerPeople),
         Convert(CertificatePrinterPerson));
 }
        private void AddRootFolder()
        {
            if (!GenericInputDialog.ShowInputDialog(Owner, "Insert the name for the new folder", "Folder name", "", out var foldercomponent))
            {
                return;
            }
            if (string.IsNullOrWhiteSpace(foldercomponent))
            {
                return;
            }

            var path = DirectoryPath.Create(Enumerable.Repeat(foldercomponent, 1));

            Owner.NotesViewControl.AddFolder(path);
        }
Ejemplo n.º 7
0
        public ResponseHelper AddImage(int id, HttpPostedFileBase file)
        {
            var rh = new ResponseHelper();

            try
            {
                // Creamos la ruta
                var path = DirectoryPath.CourseImage(id);
                DirectoryPath.Create(path);

                // Ahora vamos a crear los nombres para el archivo
                var fileName = path
                               + DateTime.Now.ToString("yyyyMMddHHmmss")
                               + Path.GetExtension(file.FileName);

                // La ruta completa
                var fullPath = HttpContext.Current.Server.MapPath("~/" + fileName);

                // La ruta donde lo vamos guardar
                file.SaveAs(fullPath);

                using (var ctx = _dbContextScopeFactory.Create())
                {
                    // Obtenemos el curso
                    var originalCourse = _courseRepo.Single(x => x.Id == id);

                    // Seteamos la imagen
                    originalCourse.Image1 = fileName;
                    originalCourse.Image2 = fileName;

                    _courseRepo.Update(originalCourse);

                    ctx.SaveChanges();
                    rh.SetResponse(true);
                    rh.Result = fileName;
                }
            }
            catch (Exception e)
            {
                logger.Error(e.Message);
                rh.SetResponse(false, e.Message);
            }

            return(rh);
        }
Ejemplo n.º 8
0
        public async Task <Func <string> > EsureDayCached(Day day)
        {
            var cacheFile = GetCacheFile(day);

            if (cacheFile.Exists)
            {
                logger.Debug($"Found {day} cached as {cacheFile}");
                return(() => File.ReadAllText(cacheFile.Absolute));
            }

            CacheDirectory.Create();
            var data = await Sgx.GetDay(day);

            logger.Info($"Caching {day} to file {cacheFile}...");
            await File.WriteAllTextAsync(cacheFile.Absolute, data);

            return(() => data);
        }
Ejemplo n.º 9
0
        public async Task Setup()
        {
            // Load Settings
            System.Console.WriteLine("Running in directory: " + Directory.GetCurrentDirectory());
            FilePath settingsPath = "../../../../TestingSettings.xml";

            System.Console.WriteLine("Settings path: " + settingsPath);
            Settings = JsonConvert.DeserializeObject <TestingSettings>(File.ReadAllText(settingsPath.Path));
            System.Console.WriteLine("Target settings: " + Settings.ToString());

            // Setup folders and paths
            ModKey           = new ModKey("Oblivion", ModType.Master);
            TempFolder       = new TempFolder(deleteAfter: true);
            DataPath         = Path.Combine(Settings.DataFolderLocations.Oblivion, "Oblivion.esm");
            BinaryPath       = Path.Combine(TempFolder.Dir.Path, "Oblivion.esm");
            OneTimeXmlFolder = new DirectoryPath(Path.Combine(TempFolder.Dir.Path, "OneTimeFolder"));
            OneTimeXmlFolder.Create();

            // Setup
            Mod = OblivionMod.CreateFromBinary(new ModPath(ModKey, DataPath));
        }
Ejemplo n.º 10
0
        private DirectoryPath GetPath()
        {
            if (!_hConfig.EmulateSubfolders)
            {
                return(DirectoryPath.Root());
            }

            if (_pathCache != null && _pathCache.Item1 == InternalTitle)
            {
                return(_pathCache.Item2);
            }

            var plist = _hConfig.UnescapeStringFromRemote(InternalTitle).ToList();
            var t     = plist.Last();

            plist.RemoveAt(plist.Count - 1);
            var p = DirectoryPath.Create(plist);

            _pathCache = Tuple.Create(InternalTitle, p, t);

            return(p);
        }