Exemplo n.º 1
0
        public static PatchingEnvironment FromExisting(string path)
        {
            var patchingEnvironment = new PatchingEnvironment(path);
            patchingEnvironment.Version = patchingEnvironment.ReadVersion() ?? DefaultVersion;

            return patchingEnvironment;
        }
Exemplo n.º 2
0
        public static PatchingEnvironment Create(PatchingEnvironment baseEnvironment)
        {
            string newApplicationRoot = FileSystem.GetTempDirectory();

            Computer.FileSystem.CopyDirectory(baseEnvironment.ApplicationRoot, newApplicationRoot);

            return FromExisting(newApplicationRoot);
        }
Exemplo n.º 3
0
 private void CreateNewPatchingEnvironment()
 {
     this.patchingEnvironment = PatchingEnvironment.Create(PatchingEnvironment.GetCurrent());
 }
Exemplo n.º 4
0
        public void ReplaceWith(PatchingEnvironment other)
        {
            // TODO Sanity checks, etc.

            string source = other.ApplicationRoot;
            string destination = ApplicationRoot;

            // Rename the destination,
            // move source to (old) destination,
            // delete renamed destination

            string tempRoot = Path.Combine(Path.GetDirectoryName(destination), string.Format("NoCap-{0}", Path.GetRandomFileName()));

            bool success;

            success = false;

            try {
                MoveDirectory(destination, tempRoot);

                success = true;
            } finally {
                if (!success) {
                    if (Directory.Exists(tempRoot)) {
                        MoveDirectory(tempRoot, destination);
                    }
                }
            }

            success = false;

            try {
                MoveDirectory(source, destination);

                success = true;
            } finally {
                if (!success) {
                    if (Directory.Exists(destination)) {
                        Directory.Delete(destination, true);
                    }

                    MoveDirectory(tempRoot, destination);
                }
            }

            Directory.Delete(tempRoot, true);
        }