private static void PreparePatches() { ColoredOutput.WriteInformation("Preparing patches..."); _gameAssemblyDefinition = ModuleLoader.LoadGameModule(_gameAssemblyFilename); if (!string.IsNullOrEmpty(_bootstrapAssemblyFilename)) { _bootstrapAssemblyDefinition = ModuleLoader.LoadBootstrapModule(_bootstrapAssemblyFilename); } _patcher = new Patcher(_bootstrapAssemblyDefinition, _gameAssemblyDefinition); _patcher.AddPatch(new CentrifugeInitPatch()); }
private async Task <TEntity> UpdateAsync(TEntity entity, ICandidate <TEntity, TKey> candidate, Query <TEntity> query) { await OnBeforeUpdateEntity(entity, candidate); entity = Patcher.Patch(entity, candidate.JsonValue); await OnAfterUpdateEntity(entity, candidate, query); await ValidateOrDiscardAsync(entity); return(entity); }
/// <summary>Initializes a new instance of the <see cref="MethodPatcher"/> class.</summary> /// <param name="patches">The patches to process by this object.</param> /// <exception cref="ArgumentException">Thrown when no patches specified.</exception> public MethodPatcher(params IPatch[] patches) { if (patches == null || patches.Length == 0) { throw new ArgumentException("At least one patch is required"); } this.patches = patches; var harmony = HarmonyInstance.Create(HarmonyId); patcher = new Patcher(harmony); }
public void PatchAgents() { // GetLastFiredBullet() extension Patcher.Postfix(typeof(Gun), nameof(Gun.spawnBullet), new Type[5] { typeof(bulletStatus), typeof(InvItem), typeof(int), typeof(bool), typeof(string) }); Patcher.AnyErrors(); }
/********* ** Private methods *********/ /**** ** Event handlers ****/ /// <inheritdoc cref="IGameLoopEvents.GameLaunched"/> /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> private void OnGameLaunched(object sender, GameLaunchedEventArgs e) { log.T("Initialising mod data."); // Content //Translations.Initialise(); // Patches Patcher.PatchAll(); //ModConfig.SetUpModConfigMenu(Config, this); }
static bool Prefix(Element element, AspectDetailsWindow __instance) { return(Patcher.Run(() => { if (element.Id == "__GetActivityState()") { WindowController.aspectDetailsVisible = __instance.gameObject.activeInHierarchy; return false; } return true; })); }
/// <summary> /// Installs given mod, returns true it was succesfull /// </summary> /// <param name="modInnitTarget"></param> /// <param name="modPatcher"></param> /// <returns></returns> public static bool InstallMod(Target modInnitTarget, Patcher modPatcher) { try { modPatcher.Patch(modInnitTarget); } catch (Exception exp) { throw new Exception($"Erro no Patching | Patching error: {exp}"); } return(true); }
protected override void ProcessRecord() { var pattern = Model.Pattern.Parse(Pattern); using (var stream = File.Open(TargetFile, FileMode.Open, FileAccess.Read, FileShare.Read)) { using (var patcher = new Patcher(stream)) { WriteObject(patcher.FindPattern(pattern)); } } }
public void Apply(Archive entity, Patcher patcher) { entity.Id = Id; if (!entity.IsNew()) { entity.OldName = patcher.Value(entity, x => x.Name); } entity.Name = Name; entity.File = File; }
public static void Patch(Harmony harmony) { var originalRenderInstanceBuildingAIMethod = AccessTools.Method(typeof(BuildingAI), nameof(BuildingAI.RenderInstance)); var prefixRenderInstanceBuildingAIMethod = AccessTools.Method(typeof(BuildingAIPatch), nameof(RenderInstanceBuildingAIPrefix)); Patcher.PatchPrefix(harmony, originalRenderInstanceBuildingAIMethod, prefixRenderInstanceBuildingAIMethod); var originalRenderInstanceCableCarPylonAIMethod = AccessTools.Method(typeof(CableCarPylonAI), nameof(CableCarPylonAI.RenderInstance)); var prefixRenderInstanceCableCarPylonAIMethod = AccessTools.Method(typeof(BuildingAIPatch), nameof(RenderInstanceCableCarPylonAIPrefix)); Patcher.PatchPrefix(harmony, originalRenderInstanceCableCarPylonAIMethod, prefixRenderInstanceCableCarPylonAIMethod); var originalRenderInstancePowerPoleAIMethod = AccessTools.Method(typeof(PowerPoleAI), nameof(PowerPoleAI.RenderInstance)); var prefixRenderInstancePowerPoleAIMethod = AccessTools.Method(typeof(BuildingAIPatch), nameof(RenderInstancePowerPoleAIPrefix)); Patcher.PatchPrefix(harmony, originalRenderInstancePowerPoleAIMethod, prefixRenderInstancePowerPoleAIMethod); var originalRenderInstanceCommonBuildingAIMethod = AccessTools.Method(typeof(CommonBuildingAI), nameof(CommonBuildingAI.RenderInstance)); var prefixRenderInstanceCommonBuildingAIMethod = AccessTools.Method(typeof(BuildingAIPatch), nameof(RenderInstanceCommonBuildingAIPrefix)); Patcher.PatchPrefix(harmony, originalRenderInstanceCommonBuildingAIMethod, prefixRenderInstanceCommonBuildingAIMethod); var originalRenderDestroyedPropsMethod = AccessTools.Method(typeof(BuildingAI), "RenderDestroyedProps"); var prefixRenderDestroyedPropsMethod = AccessTools.Method(typeof(BuildingAIPatch), nameof(RenderDestroyedPropsPrefix)); Patcher.PatchPrefix(harmony, originalRenderDestroyedPropsMethod, prefixRenderDestroyedPropsMethod); var originalRenderPropsMethod = AccessTools.Method(typeof(BuildingAI), "RenderProps", new Type[] { typeof(RenderManager.CameraInfo), typeof(ushort), typeof(Building).MakeByRefType(), typeof(int), typeof(RenderManager.Instance).MakeByRefType(), typeof(bool), typeof(bool), typeof(bool) }); var prefixRenderPropsMethod = AccessTools.Method(typeof(BuildingAIPatch), nameof(RenderPropsPrefix)); Patcher.PatchPrefix(harmony, originalRenderPropsMethod, prefixRenderPropsMethod); var originalGetCollapseTimeMethod = AccessTools.Method(typeof(CommonBuildingAI), "GetCollapseTime"); var reverseGetCollapseTimeMethod = AccessTools.Method(typeof(BuildingAIPatch), nameof(GetCollapseTimeReverse)); Patcher.PatchReverse(harmony, originalGetCollapseTimeMethod, reverseGetCollapseTimeMethod); var originalGetConstructionTimeMethod = AccessTools.Method(typeof(CommonBuildingAI), "GetConstructionTime"); var reverseGetConstructionTimeMethod = AccessTools.Method(typeof(BuildingAIPatch), nameof(GetConstructionTimeReverse)); Patcher.PatchReverse(harmony, originalGetConstructionTimeMethod, reverseGetConstructionTimeMethod); var originalRenderFireEffectPropsMethod = AccessTools.Method(typeof(CommonBuildingAI), "RenderFireEffectProps"); var reverseRenderFireEffectPropsMethod = AccessTools.Method(typeof(BuildingAIPatch), nameof(RenderFireEffectPropsReverse)); Patcher.PatchReverse(harmony, originalRenderFireEffectPropsMethod, reverseRenderFireEffectPropsMethod); var originalGetPropRenderIDMethod = AccessTools.Method(typeof(BuildingAI), "GetPropRenderID"); var reverseGetPropRenderIDMethod = AccessTools.Method(typeof(BuildingAIPatch), nameof(GetPropRenderIDReverse)); Patcher.PatchReverse(harmony, originalGetPropRenderIDMethod, reverseGetPropRenderIDMethod); }
/// <summary> /// Index of the installed mod, returns -1 if not installed /// </summary> /// <param name="modInnitTarget"></param> /// <param name="modPatcher"></param> /// <param name="occurence"></param> /// <returns></returns> public static int IndexOfInstalledMod(Target modInnitTarget, Patcher modPatcher, int occurence = 0) { Instruction[] instructionOfMethod = modPatcher.GetInstructions(modInnitTarget); int comparingIndex = 0; // Do method para conferir int instructionIndex = 0; // Do mod int occurenceCounter = 0; while (instructionIndex < modInnitTarget.Instructions.Length && comparingIndex < instructionOfMethod.Length) { if (modInnitTarget.Instructions[instructionIndex].Operand == null && instructionOfMethod[comparingIndex].Operand == null && modInnitTarget.Instructions[instructionIndex].OpCode.Name == instructionOfMethod[comparingIndex].OpCode.Name) { comparingIndex++; instructionIndex++; if (instructionIndex == (modInnitTarget.Instructions.Length - 1)) { if (occurenceCounter == occurence) { return(comparingIndex - instructionIndex); } else { occurenceCounter++; } } } else if (modInnitTarget.Instructions[instructionIndex].OpCode.Name == instructionOfMethod[comparingIndex].OpCode.Name && modInnitTarget.Instructions[instructionIndex].Operand.ToString() == instructionOfMethod[comparingIndex].Operand.ToString()) { comparingIndex++; instructionIndex++; if (instructionIndex == (modInnitTarget.Instructions.Length - 1)) { if (occurenceCounter == occurence) { return(comparingIndex - instructionIndex); } else { occurenceCounter++; } } } else { comparingIndex = comparingIndex - instructionIndex + 1; instructionIndex = 0; } } return(-1); }
public override void Initialize() { Patcher.Patch(this, typeof(WarpPopup), "Initialize", "WarpPopup", null, typeof(object), typeof(Entity)); Events.OnGameUpdated += (a, b) => { if (GameInstance.KeyDown(KeyCode.Keypad1)) { _showAll = !_showAll; Logger.Debug("Showing All Maps: " + _showAll); } }; }
/********* ** Private methods *********/ /**** ** Event handlers ****/ /// <inheritdoc cref="IGameLoopEvents.GameLaunched"/> /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> private void OnGameLaunched(object sender, GameLaunchedEventArgs e) { log.T("Initialising mod data."); // Content //Translations.Initialise(); // Patches Patcher.PatchAll(); // Load APIs LoadAPIs(); }
void UpdateBuild(DateTime last, bool valid, bool release, bool dx) { if (last == DateTime.MinValue || !valid) { return; } Build build = release ? stable : dev; string dir = dx ? build.DirectXPath : build.OpenGLPath; Console.WriteLine("FETCH! " + dir); Patcher.Update(dir); }
public void GetOnlyProperty_CanNot_BePatched() { const string newValue = "new value"; var testObject = new TestObject(); var oldValue = testObject.PropertyWithGetOnly; var patchDictionary = new Dictionary <string, object> { { "PropertyWithGetOnly", newValue } }; Patcher.Apply(testObject, patchDictionary); testObject.PropertyWithGetOnly.Should().Be(oldValue); }
private void Handle1() { if (!Patcher.TempFS.Exists("BTL_PACK_UK.DAT")) { Patcher.GameAccessPath("btl.svo", () => { Patcher.GameGetFile("BTL_PACK_UK.DAT", (PackStream) => { Patcher.TempFS.WriteAllBytes("BTL_PACK_UK.DAT", PackStream.ReadAll()); }); }); } }
public void PrivateProperty_CanNot_BePatched() { const string newValue = "new value"; var testObject = new TestObject(); var oldValue = testObject.GetPrivateStringProperty(); var patchDictionary = new Dictionary <string, object> { { "PrivateStringProperty", newValue } }; Patcher.Apply(testObject, patchDictionary); testObject.GetPrivateStringProperty().Should().Be(oldValue); }
static bool Prefix() { return(Patcher.Run(() => { // If escape was not pressed or if it was pressed with either shift key we run the game's default function if (!Input.GetKeyDown(KeyCode.Escape) || (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift))) { return true; } WindowController.CloseAll(excludeSituations: WindowController.AnyTopPanelsVisible()); return false; })); }
private Bitmap _TranslateZoneAnimationImage(Bitmap BaseImage, string Row1, string Row2) { var Bitmap = new Bitmap(512, 512); Patcher.PatcherGetFile("Font/Seagull.ttf", (FontStream) => { { var Graphics2 = Graphics.FromImage(BaseImage); Graphics2.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy; Graphics2.FillRectangle(new SolidBrush(Color.Transparent), new Rectangle(0, 38, 512, 190)); } var PrivateFontCollection = new PrivateFontCollection(); var FontBytes = FontStream.ReadAll(); fixed(byte *FontPointer = FontBytes) { PrivateFontCollection.AddMemoryFont(new IntPtr(FontPointer), FontBytes.Length); } var graphics = Graphics.FromImage(Bitmap); var Font1 = new Font(PrivateFontCollection.Families[0].Name, 26, FontStyle.Regular); var Font2 = new Font(PrivateFontCollection.Families[0].Name, 40, FontStyle.Regular); //graphics.FillRectangle(new SolidBrush(Color.White), new Rectangle(0, 0, 512, 512)); graphics.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceOver; graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High; graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; graphics.TextRenderingHint = TextRenderingHint.AntiAlias; var SolidBrush = new SolidBrush((ARGB_Rev)"#503c3c"); graphics.DrawString(Row1, Font1, SolidBrush, new PointF(-2, 35.2f)); //graphics.DrawString(Row2, Font2, SolidBrush, new PointF(-3, 97)); float Position = -3; for (int n = 0; n < Row2.Length; n++) { graphics.DrawString(Row2.Substr(n, 1), Font2, SolidBrush, new PointF(Position, 97)); var Size = graphics.MeasureString(Row2.Substr(n, 1), Font2); Position += Size.Width - 2; } var _DistanceMap = DistanceMap.GetDistanceMap(DistanceMap.GetMask(Bitmap)); DistanceMap.DrawGlow(Bitmap, _DistanceMap, 6, "#fff0d3", 0.1f); graphics.DrawImage(BaseImage, Point.Empty); }); Bitmap.Save(@"C:\vesperia\vesperia\test.png"); return(Bitmap); }
private static bool HandlerArgs(string[] args) { string gameArgs = ""; int crashDelay = 25; if (args.Length > 0) { if (args.Length > 1) { gameArgs = args[1]; // may gets overwritten somwhere else } if (args[0].Equals("-FixLocalSave", StringComparison.InvariantCultureIgnoreCase)) { // hande FixLocalSave SaveFilePatcher.PatchSaveFiles(args.ElementAtOrDefault(1), true); return(true); } else if (args[0].Equals("-FixLocalSaveNoQuests", StringComparison.InvariantCultureIgnoreCase)) { // hande FixLocalSave SaveFilePatcher.PatchSaveFiles(args.ElementAtOrDefault(1), false); return(true); } else if (args[0].Equals("-UpdateKeyBinds", StringComparison.InvariantCultureIgnoreCase)) { // hande UpdateKeyBinds KeyBindingSync.SyncKeyBindings(args.ElementAtOrDefault(1)); return(false); } else if (args.Length > 1 && args[1].Equals("-Delay", StringComparison.InvariantCultureIgnoreCase)) { // Handle Delay if (!Int32.TryParse(args[2], out crashDelay)) { Console.WriteLine("Bad argument for -Delay"); return(false); } ConsolePrint($"Delay has been set to: {crashDelay}ms", ConsoleColor.DarkYellow); // if user is setting a custom delay value and specifying game.exe path if (args.Length > 3) { gameArgs = args[3]; } } // launch with extra CLI options return(Patcher.Start(args[0], crashDelay, gameArgs)); } // launch with default settings return(Patcher.Start()); }
private void HandleTextureDat() { Patcher.GameAccessPath("TEXTURE.DAT", () => { Patcher.GameGetTXM("0", "1", (Txm) => { Patcher.UpdateTxm2DWithPng(Txm, PatchPaths.U_USUALBTLFONT00, "U_USUALBTLFONT00", "U_USUALBTLFONT00_EU"); Patcher.UpdateTxm2DWithPng(Txm, PatchPaths.U_USUALBTLFONT01, "U_USUALBTLFONT01"); Patcher.UpdateTxm2DWithPng(Txm, PatchPaths.U_USUALLOAD00, "U_USUALLOAD00"); Patcher.UpdateTxm2DWithPng(Txm, PatchPaths.U_USUALLOAD01, "U_USUALLOAD01"); Patcher.UpdateTxm2DWithPng(Txm, PatchPaths.U_USUALFIEINFO02, "U_USUALFIEINFO02"); }); }); }
static void ResolvePath() { if (!Patcher.CrusaderExists(Configuration.Path)) { if (Patcher.CrusaderExists(Environment.CurrentDirectory)) { Configuration.Path = Environment.CurrentDirectory; } else if (Patcher.CrusaderExists(Path.Combine(Environment.CurrentDirectory, "..\\"))) { Configuration.Path = Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, "..\\")); } } }
void pButtonUninstall_Click(object sender, RoutedEventArgs e) { string path = pTextBoxPath.Text; if (Directory.Exists(path)) { Patcher.RestoreOriginals(path); Debug.Show(Localization.Get("ui_uninstalldone"), Localization.Get("ui_uninstall")); } else { Debug.Error(Localization.Get("ui_wrongpath")); } }
internal void Tick(int currentTick) { if (currentTick % CheckTickDelay != 0) { return; } var settings = Settings.Get(); if (settings.perfomanceMode) { Patcher.UnpatchByRule(settings.ruleTiming, settings.ruleTicks); } }
public void Can_Patch_NullableGuidProperty_WithNullValue() { var testObject = new TestObject { NullableGuidProperty = Guid.NewGuid() }; var patchDictionary = new Dictionary <string, object> { { "NullableGuidProperty", null } }; Patcher.Apply(testObject, patchDictionary); testObject.NullableGuidProperty.Should().BeNull(); }
protected override void ApplyPatch(HarmonyInstance harmony = null) { MethodInfo _ThingWithComps_InitializeComps = typeof(Verse.ThingWithComps).GetMethod("InitializeComps", BindingFlags.Public | BindingFlags.Instance); Patcher.LogNULL(_ThingWithComps_InitializeComps, "_ThingWithComps_InitializeComps", true); //Get the Prefix Patch MethodInfo _InitializeCompsPrefix = typeof(PatchThingWithComps_Nano).GetMethod("InitializeCompsPrefix", BindingFlags.Public | BindingFlags.Static); Patcher.LogNULL(_InitializeCompsPrefix, "_AddCompPrefix", true); //Apply the Prefix Patch harmony.Patch(_ThingWithComps_InitializeComps, new HarmonyMethod(_InitializeCompsPrefix), null); }
private static void ValidatePatch(Patch patch) { Console.WriteLine($"{DateTime.Now:yyyy-MM-dd HH:mm:ss} Validating patch..."); using (var stream = File.Open(@"e:\Work\RE\Notepad\notepad_3.bin", FileMode.Open, FileAccess.ReadWrite, FileShare.Read)) { using (var patcher = new Patcher(stream)) { Console.WriteLine(patcher.Validate(patch) ? "Patch is valid" : "Patch is NOT valid"); } } Console.WriteLine($"{DateTime.Now:yyyy-MM-dd HH:mm:ss} Validation completed"); }
public void HandleBattlePackImagesCommon() { Patcher.Action("Battle Common", () => { Patcher.GameAccessPath("2", () => { Patcher.Action("Level Up", () => { Patcher.GameAccessPath("E_A018", () => { Patcher.GameGetTXM("8", "9", (Txm) => { Patcher.UpdateTxm2DWithPng(Txm, PatchPaths.E_A018_LVUP_00, "E_A018_LVUP_00"); }); }); }); Patcher.Action("New Skill", () => { Patcher.GameAccessPath("E_A019", () => { Patcher.GameGetTXM("8", "9", (Txm) => { Patcher.UpdateTxm2DWithPng(Txm, PatchPaths.E_A019_NEW_00, "E_A019_NEW_00"); }); }); }); Patcher.Action("New Arte", () => { Patcher.GameAccessPath("E_A024", () => { Patcher.GameGetTXM("8", "9", (Txm) => { Patcher.UpdateTxm2DWithPng(Txm, PatchPaths.E_A024_LEARNING_00, "E_A024_LEARNING_00"); }); Patcher.GameGetTXM("10", "11", (Txm) => { Patcher.UpdateTxm2DWithEmpty(Txm, "E_A024_LEARNING_00_F", "E_A024_LEARNING_00_G"); }); }); }); Patcher.Action("Secret Mission Completed!", () => { Patcher.GameAccessPath("E_A027", () => { Patcher.GameGetTXM("8", "9", (Txm) => { Patcher.UpdateTxm2DWithPng(Txm, PatchPaths.E_A027_MISSION_00, "E_A027_MISSION_00"); }); }); }); Patcher.Action("New Title", () => { Patcher.GameAccessPath("E_A062", () => { Patcher.GameGetTXM("8", "9", (Txm) => { Patcher.UpdateTxm2DWithPng(Txm, PatchPaths.E_A062_TITLE_00, "E_A062_TITLE_00"); }); Patcher.GameGetTXM("10", "11", (Txm) => { Patcher.UpdateTxm2DWithEmpty(Txm, "E_A062_TITLE_00_F", "E_A062_TITLE_00_G"); }); }); }); }); }); }
public void EmptyPatch_TryApply_NoMetadataChange() { var sourceData = new byte[0x200].Fluent(array => array[1] = 1); var destinationData = new byte[0x200].Fluent(array => array[2] = 2); var patch = Patcher.BuildUpsPatch(sourceData, destinationData); var patchFile = new LoadedFile("patch.ups", patch); FileSystem.ShowOptions = (_, _, _, _) => 1; ViewPort.TryImport(patchFile, FileSystem); Assert.True(ViewPort.ChangeHistory.IsSaved); Assert.False(ViewPort.ChangeHistory.HasDataChange); }
static void Prefix(ref float intervalThisBeat) { try { if (Mod.SpeedMultiplier != null) { intervalThisBeat = intervalThisBeat * (float)Mod.SpeedMultiplier; } } catch (Exception e) { Patcher.HandleException(e); } }
void myPatcher_PatchStepFired(object sender, Patcher.PatchingEventArgs e) { this.Dispatcher.BeginInvoke(new System.Windows.Forms.MethodInvoker(delegate() { if (e.NewEvent) { //add a new line to split them up lblPatchProgress.Text += Environment.NewLine; } else { lblPatchProgress.Text += "...."; } lblPatchProgress.Text += e.Message; svProgress.ScrollToBottom(); }), System.Windows.Threading.DispatcherPriority.Normal); }
void myPatchProgress_PatchComplete(object sender, Patcher.PatchFunctionCompleteEventArgs e) { if (e.Success) { this.Dispatcher.BeginInvoke(new System.Windows.Forms.MethodInvoker(delegate() { btnLaunchClient.IsEnabled = true; }), System.Windows.Threading.DispatcherPriority.Normal); } if (OnError != null) { OnError(sender, new ErrorMessageEventArgs(e.Message, null)); } if (PatchComplete != null) { PatchComplete(this, e); } }
public void Should_patch_config_file() { var username = "******"; var password = "******"; var hostname = "hostname"; var configUpdate = "5"; var configRetry = "6"; var cacheLength = "7"; var path = "test.config"; var uri = "uri"; var input = new string[8]; input[0] = string.Format("username={0}", username); input[1] = string.Format("password={0}", password); input[2] = string.Format("hostname={0}", hostname); input[3] = string.Format("configupdate={0}", configUpdate); input[4] = string.Format("configretry={0}", configRetry); input[5] = string.Format("cachelength={0}", cacheLength); input[6] = string.Format("path={0}", path); input[7] = string.Format("configuri={0}", uri); var parseParamaters = new ParseParamaters(input); var patcher = new Patcher(parseParamaters); patcher.Patch(); var xmlDocument = new XmlDocument(); xmlDocument.Load(@"test.config"); Assert.That(xmlDocument.SelectSingleNode("/configuration/SqlToGraphite/@Hostname").Value, Is.EqualTo(hostname)); Assert.That(xmlDocument.SelectSingleNode("/configuration/SqlToGraphite/@ConfigUsername").Value, Is.EqualTo(username)); Assert.That(xmlDocument.SelectSingleNode("/configuration/SqlToGraphite/@ConfigPassword").Value, Is.EqualTo(password)); Assert.That(xmlDocument.SelectSingleNode("/configuration/SqlToGraphite/@ConfigUri").Value, Is.EqualTo(uri)); Assert.That(xmlDocument.SelectSingleNode("/configuration/SqlToGraphite/@CheckConfigUpdatedEveryMinutes").Value, Is.EqualTo(configUpdate)); Assert.That(xmlDocument.SelectSingleNode("/configuration/SqlToGraphite/@MinutesBetweenRetryToGetConfigOnError").Value, Is.EqualTo(configRetry)); Assert.That(xmlDocument.SelectSingleNode("/configuration/SqlToGraphite/@ConfigCacheLengthMinutes").Value, Is.EqualTo(cacheLength)); }
static void Main(string[] args) { var patcher = new Patcher(new ParseParamaters(args)); patcher.Patch(); }
void myPatchProgress_PatchComplete(object sender, Patcher.PatchFunctionCompleteEventArgs e) { if (OnError != null) { OnError(this, new ErrorMessageEventArgs(e.Message, new EventHandler(PatchComplete))); } if (PatchCompleted != null) { PatchCompleted(this, new EventArgs()); } }
void myPatcher_PatchFunctionComplete(object sender, Patcher.PatchFunctionCompleteEventArgs e) { if (PatchComplete != null) { PatchComplete(this, e); } myPatcher.Dispose(); }
public void StartPatch() { //make the patcher myPatcher = new Patcher(myTextVariables, myUserPreferences); myPatcher.OnError += new EventHandler<ErrorMessageEventArgs>(myPatcher_OnError); myPatcher.PatchStepFired += new EventHandler<Patcher.PatchingEventArgs>(myPatcher_PatchStepFired); myPatcher.PatchFunctionComplete += new EventHandler<Patcher.PatchFunctionCompleteEventArgs>(myPatcher_PatchFunctionComplete); //and start checking those files myPatcher.PatchClient(theServerInfo); }
public void Should_not_add_password_when_patching_config_file() { var username = "******"; var password = ""; var input = new string[3]; input[0] = string.Format("username={0}", username); input[1] = string.Format("password={0}", password); input[2] = string.Format("path={0}", "test.config"); var parseParamaters = new ParseParamaters(input); var patcher = new Patcher(parseParamaters); patcher.Patch(); var xmlDocument = new XmlDocument(); xmlDocument.Load(@"test.config"); Assert.That(xmlDocument.SelectSingleNode("/configuration/SqlToGraphite/@ConfigUsername").Value, Is.EqualTo(username)); Assert.That(xmlDocument.SelectSingleNode("/configuration/SqlToGraphite/@ConfigPassword"), Is.Null); }
public void Should_not_add_username_when_patching_config_file() { var username = ""; var password = "******"; var input = new string[6]; input[0] = "username"; input[1] = username; input[2] = "password"; input[3] = password; input[4] = "path"; input[5] = "test.config"; var parseParamaters = new ParseParamaters(input); var patcher = new Patcher(parseParamaters); patcher.Patch(); var xmlDocument = new XmlDocument(); xmlDocument.Load(@"test.config"); Assert.That(xmlDocument.SelectSingleNode("/configuration/SqlToGraphite/@ConfigUsername"), Is.Null); Assert.That(xmlDocument.SelectSingleNode("/configuration/SqlToGraphite/@ConfigPassword"), Is.EqualTo(password)); }