/// <summary> /// Adds a candidate patch. /// </summary> /// <param name="patch">The patch from PLib to add.</param> public void AddPatch(object patch) { if (patch == null) { throw new ArgumentNullException("patch"); } // Verify the class name if (patch.GetType().FullName == typeof(PLibPatches).FullName) { string ver = null; try { ver = Traverse.Create(patch).GetProperty <string>(nameof(PLibPatches. MyVersion)); } catch (Exception e) { PUtil.LogException(e); } if (ver == null) { #if DEBUG LogPatchWarning("Invalid patch provided to AddPatch!"); #endif } else if (!Patches.ContainsKey(ver)) { LogPatchDebug("Candidate version {0} from {1}".F(ver, patch.GetType(). Assembly.GetName()?.Name)); Patches.Add(ver, patch); } } else { LogPatchWarning("Invalid patch provided to AddPatch!"); } }
/// <summary> /// Adds a new patch to the map. Throws if can't add /// </summary> public void AddPatch(Patch patch) { if (Patches.ContainsKey(patch.ID)) { throw new ArgumentException("patch cannot be added to this map"); } Patches[patch.ID] = patch; }
/// <summary> /// Adds a candidate patch. /// </summary> /// <param name="patch">The patch from PLib to add.</param> public void AddPatch(object patch) { if (patch == null) { throw new ArgumentNullException("patch"); } string ver = Traverse.Create(patch).GetProperty <string>("MyVersion"); if (ver == null) { #if DEBUG LogPatchWarning("Invalid patch provided to AddPatch!"); #endif } else if (!Patches.ContainsKey(ver)) { LogPatchDebug("Candidate version {0} from {1}".F(ver, patch.GetType(). Assembly.GetName()?.Name)); Patches.Add(ver, patch); } }
public static ISkyrimMod GetOrAddPatch(string EspName, bool forLVLI = false) { if (!(EspName.Contains(Patcher.PatcherSuffix) || EspName.Contains(Patcher.PatcherLLSuffix))) { var suffix = forLVLI ? Patcher.PatcherLLSuffix : Patcher.PatcherSuffix; EspName = EspName.Replace(".esp", "") + suffix; } ModKey modKey = ModKey.FromNameAndExtension(EspName); if (Patches.ContainsKey(modKey.FileName)) { return(Patches.GetValueOrDefault(modKey.FileName)); } ISkyrimMod patch = new SkyrimMod(modKey, SkyrimRelease.SkyrimSE); Patches.TryAdd(modKey.FileName, patch); Cache.Add(patch); //var x = ModListing<ISkyrimModGetter>.CreateEnabled(patch.ModKey); //State.LoadOrder.Add((IModListing<ISkyrimModGetter>)x, State.LoadOrder.Count - 2); return(patch); }