Ejemplo n.º 1
0
        public void ApplyPatch(Patch patch)
        {
            lock (fileSystemSync) {
                if (Version != patch.FromVersion) {
                    throw new ArgumentException(string.Format("Cannot upgrade from version '{0}' using patch for version '{1}'", Version, patch.FromVersion));
                }

                IsModified = true;

                foreach (var instruction in patch.Instructions) {
                    instruction.Apply(patch.PatchDataRoot, ApplicationRoot);
                }

                WriteVersion(patch.ToVersion);

                Version = patch.ToVersion;
            }
        }
Ejemplo n.º 2
0
        private static Patch InitializeFrom(string patchDataRoot)
        {
            var config = new XmlDocument();
            config.Load(Path.Combine(patchDataRoot, "nocap.xml"));

            var patch = new Patch(patchDataRoot);
            ParsePatchConfig(patch, config);

            return patch;
        }
Ejemplo n.º 3
0
        private static void ParsePatchConfig(Patch patch, XmlDocument config)
        {
            var configRoot = config.DocumentElement;

            patch.Instructions = new ReadOnlyCollection<IPatchInstruction>(
                configRoot.SelectNodes("Instructions/*").OfType<XmlElement>().Select(ParseInstruction).ToArray()
            );

            patch.FromVersion = configRoot.SelectSingleNode("From").InnerText;
            patch.ToVersion = configRoot.SelectSingleNode("To").InnerText;
        }