Exemplo n.º 1
0
        /// <summary>
        ///
        /// Add a file to an IParallelEnv.
        /// Warnings: After calling this function, you should save the env to a file.
        ///
        /// </summary>
        /// <param name="env">To be added</param>
        /// <param name="filePath">The path for the file</param>
        /// <param name="settings">IParallelEnvsSettings</param>
        public static void AddFile(ref IParallelEnv env, string filePath, IParallelEnvsSettings settings)
        {
            //
            // If there were no file which is located at "filePath", it would be thrown an exception.
            //
            if (!File.Exists(filePath))
            {
                throw new FileNotFoundException($"The file, {filePath} is not found.");
            }

            //
            // Generate a managed file path from GUID.
            //
            var file = new InternalParallelFile() as IParallelFile;

            file.OrdinaryFilePath = filePath;
            file.ManagedFilePath  = Path.Combine(settings.ManagedDirectoryPath, Guid.NewGuid().ToString());

            Directory.CreateDirectory(settings.ManagedDirectoryPath);

            //
            // Copy the file to the managed file path.
            //
            File.Copy(file.OrdinaryFilePath, file.ManagedFilePath);

            //
            // Add a file to the env.
            //
            env.Files.Add(file);
        }
Exemplo n.º 2
0
 private static void AddCommands(IParallelEnvsSettings settings, ICommandWithInfo[] commands)
 {
     foreach (var command in commands)
     {
         command.AttachInfo(settings);
         Commands.Add(command as ICommand);
     }
 }
Exemplo n.º 3
0
        static void InitalizeSettings(out IParallelEnvsSettings settings)
        {
            settings = new ParallelEnvsSettings();

            if (File.Exists(Path.Combine(settings.ApplicationWorkDirectoryPath, ParallelEnvsSettings.FILE_NAME)))
            {
                settings.LoadFromFile();
            }
        }
Exemplo n.º 4
0
        public static void Initalize(IParallelEnvsSettings settings)
        {
            Commands = new List <ICommand>();

            var commands = new ICommandWithInfo[]
            {
                new FileListCmd(),
                new EnvListCmd(),
                new CreateCmd(),
                new AddCmd()
            };

            AddCommands(settings, commands);
        }
Exemplo n.º 5
0
 public void AttachInfo(IParallelEnvsSettings settings)
 {
     Settings = settings;
 }