protected override int Run(string command) { if (String.IsNullOrEmpty(name) && String.IsNullOrEmpty(path)) { Out.WriteLine("you must define either the name or the path of the assembly to check"); return -1; } Assembly assembly = Tools.LoadAssembly(name, path); if (assembly == null) { Out.WriteLine("could not load {0}{1}", name,path); return -1; } if (!assembly.HasSettings()) { Out.WriteLine("{0} has no settings object passes by default", assembly.FullName); return 0; } SnapShot assemblySettings = SnapShot.BuildFrom(assembly); SnapShot databaseSettings = SnapShot.GetFor(assembly); Patch patch = new Patch(databaseSettings, assemblySettings); if (patch.IsEmpty) { Out.WriteLine("All of the settings in this assembly are in the database"); return 0; } Out.WriteLine("The assembly and the database are out of sync run 'stsadm -o settings-sync-with-assembly' to sync"); if(showPatch) Out.WriteLine(patch.ToXml().ToString(SaveOptions.None)); return 1; }
public static Patch FromXml(XElement element) { Patch ret = new Patch(); if (element.Name == "patch") { ret.Assembly = element.Attribute("assembly").Value; ret.Section = element.Attribute("section").Value; foreach(var action in element.Elements("action")){ ret.Actions.Add( new Action() { Type = (Action.ActionType)Enum.Parse(typeof(Action.ActionType), action.Attribute("type").Value), Name = action.Attribute("name").Value, Value = action.Attribute("value").Value, IsConnectionString = Boolean.Parse(action.Attribute("is-connection-string").Value) } ); } } return ret; }