private void CreateNewExternalServer(PermissableDefaults defaultToSet, IPatcher patcher) { if (CreatePlatformDatabase.CreateNewExternalServer(Activator.RepositoryLocator.CatalogueRepository, defaultToSet, patcher) != null) { RefreshUIFromDatabase(); } }
private void HandleConfig() { if (config.GameServer == Server.Rewritten) { currentAccountList = rewrittenAccountList; gamePatcher = rewrittenPatcher; loginHandler = rewrittenLoginHandler; gameHandler = rewrittenGameHandler; gridHandler = rewrittenGridHandler; rewrittenMenuItem.Checked = true; clashMenuItem.Checked = false; accountGrid.Columns[ToonSlots.Index].Visible = false; } else { currentAccountList = clashAccountList; gamePatcher = clashPatcher; loginHandler = clashLoginHandler; gameHandler = clashGameHandler; gridHandler = clashGridHandler; rewrittenMenuItem.Checked = false; clashMenuItem.Checked = true; accountGrid.Columns[ToonSlots.Index].Visible = true; } if (config.SelectEndGames) { endSelectedMenuItem.Visible = true; accountGrid.Columns[End.Index].ReadOnly = false; } }
public DSPSimplePatcher() { InitializeComponent(); sound = Global.Yse.CreateSound(); patcher = Global.Yse.CreatePatcher(); patcher.Create(1); mtof = patcher.AddObject("mtof"); sine = patcher.AddObject("sine"); lfo = patcher.AddObject("sine"); volume = patcher.AddObject("*"); IHandle multiplier = patcher.AddObject("*"); patcher.Connect(mtof, 0, sine, 0); // pass frequency to sine patcher.Connect(sine, 0, multiplier, 0); patcher.Connect(lfo, 0, multiplier, 1); patcher.Connect(multiplier, 0, volume, 0); patcher.Connect(volume, 0, patcher.GetOutputHandle(0), 0); mtof.SetData(0, 60f); lfo.SetData(0, 4f); volume.SetData(1, 0f); sound.Create(patcher); sound.Play(); }
private PatchingUI(DiscoveredDatabase database, ITableRepository repository, IPatcher patcher) { _database = database; _repository = repository; _patcher = patcher; InitializeComponent(); if (LicenseManager.UsageMode == LicenseUsageMode.Designtime) { return; } string name = patcher.Name + " v" + patcher.GetDbAssembly().GetName().Version.ToString(3); tbPatch.Text = $"{name}"; if (_database == null) { tbDatabase.Text = "Form loaded without a specific database to target!"; tbDatabase.ForeColor = Color.Red; } else { tbDatabase.Text = string.Format("{0}, Version:{1}", _database.GetRuntimeName(), repository.GetVersion()); } }
public DSPSimplePatcher() { InitializeComponent(); sound = Global.Yse.NewSound(); patcher = Global.Yse.NewPatcher(); patcher.Create(1); mtof = patcher.CreateObject(".mtof"); sine = patcher.CreateObject("~sine"); lfo = patcher.CreateObject("~sine"); volume = patcher.CreateObject("~*"); dac = patcher.CreateObject("~dac"); IHandle multiplier = patcher.CreateObject("~*"); patcher.Connect(mtof, 0, sine, 0); // pass frequency to sine patcher.Connect(sine, 0, multiplier, 0); patcher.Connect(lfo, 0, multiplier, 1); patcher.Connect(multiplier, 0, volume, 0); patcher.Connect(volume, 0, dac, 0); mtof.SetFloatData(0, 60f); lfo.SetFloatData(0, 4f); volume.SetFloatData(1, 0f); sound.Create(patcher); sound.Play(); }
private PatchingUI(DiscoveredDatabase database, ITableRepository repository, Version databaseVersion, IPatcher patcher, Patch[] patchesInDatabase, SortedDictionary <string, Patch> allPatchesInAssembly) { _database = database; _repository = repository; _databaseVersion = databaseVersion; _patcher = patcher; InitializeComponent(); if (LicenseManager.UsageMode == LicenseUsageMode.Designtime) { return; } _hostAssemblyVersion = new Version(FileVersionInfo.GetVersionInfo(_patcher.GetDbAssembly().Location).FileVersion); _patchesInDatabase = patchesInDatabase; _allPatchesInAssembly = allPatchesInAssembly; string name = patcher.Name + " v" + patcher.GetDbAssembly().GetName().Version.ToString(3); int numberOfPatchesToApply = _allPatchesInAssembly.Values.Except(_patchesInDatabase).Count(); tbPatch.Text = $"{name} ({numberOfPatchesToApply} Patch{(numberOfPatchesToApply > 1 ? "es":"")})"; if (_database == null) { tbDatabase.Text = "Form loaded without a specific database to target!"; tbDatabase.ForeColor = Color.Red; } else { tbDatabase.Text = string.Format("{0}, Version:{1}", _database.GetRuntimeName(), repository.GetVersion()); } }
private PatchingUI(SqlConnectionStringBuilder builder, ITableRepository repository, Version databaseVersion, IPatcher patcher, Patch[] patchesInDatabase, SortedDictionary<string, Patch> allPatchesInAssembly) { _builder = builder; _repository = repository; _databaseVersion = databaseVersion; _patcher = patcher; InitializeComponent(); if (_patcher == null) return; _hostAssemblyVersion = new Version(FileVersionInfo.GetVersionInfo(_patcher.GetDbAssembly().Location).FileVersion); _patchesInDatabase = patchesInDatabase; _allPatchesInAssembly = allPatchesInAssembly; lblPatchingAssembly.Text = patcher.GetDbAssembly().FullName; if (builder == null || string.IsNullOrWhiteSpace(builder.InitialCatalog)) { lblDatabaseVersion.Text = "Form loaded without a specific database to target!"; lblDatabaseVersion.ForeColor = Color.Red; } else { lblDatabaseVersion.Text = string.Format("{0}, Version:{1}", builder.InitialCatalog,repository.GetVersion()); } }
/// <summary>Applies the method patch using the specified <paramref name="patcher"/>.</summary> /// <param name="patcher">The patcher object that can perform the patching.</param> /// <exception cref="ArgumentNullException">Thrown when the argument is null.</exception> /// <exception cref="InvalidOperationException"> /// Thrown when both the 'Prefix' and 'Postfix' methods are missing /// in the derived type. /// </exception> public void ApplyPatch(IPatcher patcher) { if (patcher == null) { throw new ArgumentNullException(nameof(patcher)); } if (method == null) { method = GetMethod(); } else { return; } if (method == null) { return; } var thisType = GetType(); var prefix = thisType.GetMethod("Prefix", BindingFlags.Static | BindingFlags.NonPublic); var postfix = thisType.GetMethod("Postfix", BindingFlags.Static | BindingFlags.NonPublic); var transform = thisType.GetMethod("Transform", BindingFlags.Static | BindingFlags.NonPublic); if (prefix == null && postfix == null && transform == null) { throw new InvalidOperationException("At least one of the methods must be defined: 'Prefix', 'Postfix', 'Transform'."); } patcher.ApplyPatch(method, prefix, postfix, transform); }
public Events(IGame game, ILogger logger, IPatcher patcher) { _game = game; _logger = logger; _patcher = patcher; _instance = this; }
public PlatformDatabaseFoundEventArgs(ITableRepository repository, IPatcher patcher, RDMPPlatformDatabaseStatus status, Exception exception = null) { Repository = repository; Patcher = patcher; Status = status; Exception = exception; }
/// <summary>Applies the method patch using the specified <paramref name="patcher"/>.</summary> /// <param name="patcher">The patcher object that can perform the patching.</param> /// <exception cref="ArgumentNullException">Thrown when the argument is null.</exception> /// <exception cref="InvalidOperationException"> /// Thrown when both the 'Prefix' and 'Postfix' methods are missing /// in the derived type. /// </exception> public void ApplyPatch(IPatcher patcher) { if (patcher == null) { throw new ArgumentNullException(nameof(patcher)); } if (method == null) { method = GetMethod(); } else { return; } if (method == null) { return; } MethodInfo prefix = GetType().GetMethod("Prefix", BindingFlags.Static | BindingFlags.NonPublic); MethodInfo postfix = GetType().GetMethod("Postfix", BindingFlags.Static | BindingFlags.NonPublic); if (prefix == null && postfix == null) { throw new InvalidOperationException("At least one of the 'Prefix' and 'Postfix' methods must be defined"); } patcher.ApplyPatch(method, prefix, postfix); }
public static string GetInitialCreateScriptContents(IPatcher patcher) { var assembly = patcher.GetDbAssembly(); var subdirectory = patcher.ResourceSubdirectory; Regex initialCreationRegex; if (string.IsNullOrWhiteSpace(subdirectory)) { initialCreationRegex = new Regex(@".*\.runAfterCreateDatabase\..*\.sql"); } else { initialCreationRegex = new Regex(@".*\." + Regex.Escape(subdirectory) + @"\.runAfterCreateDatabase\..*\.sql"); } var candidates = assembly.GetManifestResourceNames().Where(r => initialCreationRegex.IsMatch(r)).ToArray(); if (candidates.Length == 1) { var sr = new StreamReader(assembly.GetManifestResourceStream(candidates[0])); return(sr.ReadToEnd()); } if (candidates.Length == 0) { throw new FileNotFoundException("Could not find an initial create database script in dll " + assembly.FullName + ". Make sure it is marked as an Embedded Resource and that it is in a folder called 'runAfterCreateDatabase' (and matches regex " + initialCreationRegex + "). And make sure that it is marked as 'Embedded Resource' in the .csproj build action"); } throw new Exception("There are too many create scripts in the assembly " + assembly.FullName + " only 1 create database script is allowed, all other scripts must go into the up folder"); }
public static SortedDictionary <string, Patch> GetAllPatchesInAssembly(IPatcher patcher) { var assembly = patcher.GetDbAssembly(); var subdirectory = patcher.ResourceSubdirectory; Regex upgradePatchesRegexPattern; if (string.IsNullOrWhiteSpace(subdirectory)) { upgradePatchesRegexPattern = new Regex(@".*\.up\.(.*\.sql)"); } else { upgradePatchesRegexPattern = new Regex(@".*\." + Regex.Escape(subdirectory) + @"\.up\.(.*\.sql)"); } var files = new SortedDictionary <string, Patch>(); //get all resources out of foreach (string manifestResourceName in assembly.GetManifestResourceNames()) { var match = upgradePatchesRegexPattern.Match(manifestResourceName); if (match.Success) { string fileContents = new StreamReader(assembly.GetManifestResourceStream(manifestResourceName)).ReadToEnd(); files.Add(match.Groups[1].Value, new Patch(match.Groups[1].Value, fileContents)); } } return(files); }
public EntryPlugin() { _instance = this; _harmony = new Harmony("org.undermine.api.entryplugin"); _logger = new Logger(); _patcher = new Patcher(_harmony, _logger); }
public RestCollection(IRepository <TEntity> repository, IPatcher <TEntity> patcher, IInstanciator <TEntity> instanciator) : base(repository) { Patcher = patcher; Repository = repository; Instanciator = instanciator; }
public PluginPatcherFoundEventArgs(Type type, IPatcher instance, PluginPatcherStatus status, Exception exception = null) { Type = type; Instance = instance; Status = status; Exception = exception; }
/// <summary> /// Creates a new converter for a new table /// </summary> /// <param name="sourceContainer">Source table container</param> /// <param name="fileName">File name of the file being imported</param> /// <param name="options">Optional convert options</param> public VpxSceneConverter(FileTableContainer sourceContainer, string fileName = "", ConvertOptions options = null) { _sourceContainer = sourceContainer; _sourceTable = sourceContainer.Table; _patcher = PatcherManager.GetPatcher(); _patcher?.Set(sourceContainer, fileName, this, this); _options = options ?? new ConvertOptions(); }
/// <summary> /// Initializes a new instance of the <see cref="Regenerator"/> class. /// </summary> /// <param name="inputSource">Source of input samples (IPatcher).</param> /// <param name="predictor">Predictions calculator.</param> /// <param name="detector">Error level calculator.</param> public Regenerator( IPatcher inputSource, IPredictor predictor, IDetector detector) { this.inputSource = inputSource; this.predictor = predictor; this.detector = detector; }
public static object Patch(this IPatcher patcher, object patchedObject, IJsonElement json) { if (patchedObject == null) { throw new ArgumentNullException("patchedObject"); } return(patcher.PatchValue(patchedObject, patchedObject.GetType(), json)); }
/// <inheritdoc/> public bool WasCreatedBy(IPatcher patcher) { if (string.IsNullOrWhiteSpace(CreatedByAssembly)) { return(false); } return(patcher.Name == CreatedByAssembly || patcher.LegacyName == CreatedByAssembly); }
public static object PatchFromAnonymous(this IPatcher patcher, object patchedObject, object anonymousObject) { if (anonymousObject == null) { return(patchedObject); } return(Patch(patcher, patchedObject, new JsonParser().ParseFromAnonymous(anonymousObject))); }
/// <summary> /// Creates a new platform database and patches it /// </summary> /// <param name="patcher">Determines the SQL schema created</param> /// <param name="notifier">audit object, can be a new ThrowImmediatelyCheckNotifier if you aren't in a position to pass one</param> public void CreateAndPatchDatabase(IPatcher patcher, ICheckNotifier notifier) { string sql = Patch.GetInitialCreateScriptContents(patcher); //get everything in the /up/ folder that are .sql var patches = Patch.GetAllPatchesInAssembly(patcher); CreateDatabase(sql, "1.0.0.0", notifier); PatchDatabase(patches, notifier, (p) => true);//apply all patches without question }
private bool Find(ITableRepository tableRepository, IPatcher patcher, ICheckNotifier notifier) { var db = tableRepository.DiscoveredServer.GetCurrentDatabase(); notifier.OnCheckPerformed(new CheckEventArgs(string.Format("Connecting to {0} on {1}", db.GetRuntimeName(), db.Server.Name), CheckResult.Success)); //is it reachable try { tableRepository.TestConnection(); } catch (Exception ex) { //no DatabaseFound(this, new PlatformDatabaseFoundEventArgs(tableRepository, patcher, RDMPPlatformDatabaseStatus.Unreachable, ex)); return(false); } Patch.PatchingState patchingRequired; try { //is it up-to-date on patches? Version databaseVersion; Patch[] patchesInDatabase; SortedDictionary <string, Patch> allPatchesInAssembly; patchingRequired = Patch.IsPatchingRequired((SqlConnectionStringBuilder)tableRepository.ConnectionStringBuilder, patcher, out databaseVersion, out patchesInDatabase, out allPatchesInAssembly); } catch (Exception e) { //database is broken (maybe the version of the db is ahead of the host assembly?) DatabaseFound(this, new PlatformDatabaseFoundEventArgs(tableRepository, patcher, RDMPPlatformDatabaseStatus.Broken, e)); return(false); } switch (patchingRequired) { case Patch.PatchingState.NotRequired: DatabaseFound(this, new PlatformDatabaseFoundEventArgs(tableRepository, patcher, RDMPPlatformDatabaseStatus.Healthy)); break; case Patch.PatchingState.Required: DatabaseFound(this, new PlatformDatabaseFoundEventArgs(tableRepository, patcher, RDMPPlatformDatabaseStatus.RequiresPatching)); break; case Patch.PatchingState.SoftwareBehindDatabase: DatabaseFound(this, new PlatformDatabaseFoundEventArgs(tableRepository, patcher, RDMPPlatformDatabaseStatus.SoftwareOutOfDate)); break; default: throw new ArgumentOutOfRangeException("patchingRequired"); } return(true); }
//Methods private bool Validate(string FileToCheck) { //Yeah I could have handled it so much better... This entire code is a disgrace //Rayman M patcher = new Patcher(FileToCheck, PatchNode.OffsetM, PatchNode.OriginalM, PatchNode.PatchedM); if (patcher.IsPatchable) { UnlockCrackButton(); return(true); } else if (patcher.IsAlreadyPatched()) { patcher.ToPatchBytes = PatchNode.OriginalM; UnlockUnCrackButton(); return(true); } //Rayman Arena patcher.Offset = PatchNode.OffsetA; patcher.OriginalBytes = PatchNode.OriginalA; patcher.ToPatchBytes = PatchNode.PatchedA; if (patcher.IsPatchable) { UnlockCrackButton(); return(true); } else if (patcher.IsAlreadyPatched()) { patcher.ToPatchBytes = PatchNode.OriginalA; UnlockUnCrackButton(); return(true); } //Rayman M Obscure the first patcher.Offset = PatchNode.OffsetUbiExFocus; patcher.OriginalBytes = PatchNode.OriginalUbiExFocus; patcher.ToPatchBytes = PatchNode.PatchedUbiExFocus; if (patcher.IsPatchable) { UnlockCrackButton(); return(true); } else if (patcher.IsAlreadyPatched()) { //I'm cringing so hard on this patcher.ToPatchBytes = PatchNode.OriginalUbiExFocus; UnlockUnCrackButton(); return(true); } return(false); }
/// <summary> /// Initializes a new instance of the <see cref="DamagedSampleDetector"/> class. /// </summary> /// <param name="predictionErrPatcher">Source of prediction errors /// for normCalculator.</param> /// <param name="inputPatcher">Source of input samples for /// calculating prediction errors.</param> /// <param name="normCalculator">Calculator for normal prediction errors.</param> /// <param name="predictor">Calculator for predictions.</param> public DamagedSampleDetector( IPatcher predictionErrPatcher, IPatcher inputPatcher, IAnalyzer normCalculator, IPredictor predictor) { this.predictionErrPatcher = predictionErrPatcher; this.inputPatcher = inputPatcher; this.normCalculator = normCalculator; this.predictor = predictor; }
/// <summary> /// Calls the main constructor but passing control of what scripts to extract to the Patch class /// </summary> public CreatePlatformDatabase(IPatcher patcher) { _patcher = patcher; InitializeComponent(); //show only Database section serverDatabaseTableSelector1.HideTableComponents(); if (patcher.SqlServerOnly) { serverDatabaseTableSelector1.LockDatabaseType(DatabaseType.MicrosoftSQLServer); } }
public void Setup() { _arrayValueEqualsIndex = Enumerable.Range(0, _testArrayLength) .Select(i => (double)i) .ToImmutableArray(); _patchCollection = new PatchCollection(); _patcher = new Patcher( _arrayValueEqualsIndex, _patchCollection, (patch, position) => patch.GetValue(position)); }
/// <summary> /// Reverts the method patch using the specified <paramref name="patcher"/> Has no effect if no patches have been /// applied previously. /// </summary> /// <param name="patcher">The patcher object that can perform the patching.</param> /// <exception cref="ArgumentNullException">Thrown when the argument is null.</exception> void IPatch.RevertPatch(IPatcher patcher) { if (patcher == null) { throw new ArgumentNullException(nameof(patcher)); } if (method != null) { patcher.RevertPatch(method); method = null; } }
/// <summary> /// Reverts the method patch using the specified <paramref name="patcher"/> Has no effect if no patches have been /// applied previously. /// </summary> /// <param name="patcher">The patcher object that can perform the patching.</param> /// <exception cref="ArgumentNullException">Thrown when the argument is null.</exception> public void RevertPatch(IPatcher patcher) { if (patcher == null) { throw new ArgumentNullException(nameof(patcher)); } MethodInfo patchedMethod = method ?? GetMethod(); if (patchedMethod != null) { patcher.RevertPatch(patchedMethod); method = null; } }
public ExecuteCommandCreateNewExternalDatabaseServer(IActivateItems activator, IPatcher patcher, PermissableDefaults defaultToSet) : base(activator) { _patcher = patcher; _defaultToSet = defaultToSet; _overlayProvider = new IconOverlayProvider(); _databaseIconProvider = new ExternalDatabaseServerStateBasedIconProvider(_overlayProvider); //do we already have a default server for this? var existingDefault = Activator.ServerDefaults.GetDefaultFor(_defaultToSet); if (existingDefault != null) { SetImpossible("There is already an existing " + _defaultToSet + " database"); } }
public virtual void readObject(IPatcher patcher) { Ice.Object v = null; if(_readEncapsStack == null) // Lazy initialization { _readEncapsStack = _readEncapsCache; if(_readEncapsStack != null) { _readEncapsCache = _readEncapsCache.next; } else { _readEncapsStack = new ReadEncaps(); } } if(_readEncapsStack.patchMap == null) // Lazy initialization { _readEncapsStack.patchMap = new Hashtable(); _readEncapsStack.unmarshaledMap = new Hashtable(); _readEncapsStack.typeIdMap = new Hashtable(); } int index = readInt(); if(patcher != null) { if(index == 0) { patcher.patch(null); return; } if(index < 0) { int i = -index; IceUtilInternal.LinkedList patchlist = (IceUtilInternal.LinkedList)_readEncapsStack.patchMap[i]; if(patchlist == null) { // // We have no outstanding instances to be patched // for this index, so make a new entry in the // patch map. // patchlist = new IceUtilInternal.LinkedList(); _readEncapsStack.patchMap[i] = patchlist; } // // Append a patcher for this instance and see if we // can patch the instance. (The instance may have been // unmarshaled previously.) // patchlist.Add(patcher); patchReferences(null, i); return; } } if(index < 0) { throw new Ice.MarshalException("Invalid class instance index"); } string mostDerivedId = readTypeId(); string id = mostDerivedId; while(true) { // // If we slice all the way down to Ice::Object, we throw // because Ice::Object is abstract. // if(id == Ice.ObjectImpl.ice_staticId()) { Ice.NoObjectFactoryException ex = new Ice.NoObjectFactoryException(); ex.type = mostDerivedId; throw ex; } // // Try to find a factory registered for the specific // type. // Ice.ObjectFactory userFactory = instance_.servantFactoryManager().find(id); if(userFactory != null) { v = userFactory.create(id); } // // If that fails, invoke the default factory if one // has been registered. // if(v == null) { userFactory = instance_.servantFactoryManager().find(""); if(userFactory != null) { v = userFactory.create(id); } } // // Last chance: check whether the class is // non-abstract and dynamically instantiate it using // reflection. // if(v == null) { userFactory = loadObjectFactory(id); if(userFactory != null) { v = userFactory.create(id); } } if(v == null) { if(_sliceObjects) { // // Performance sensitive, so we use lazy // initialization for tracing. // if(_traceSlicing == -1) { _traceSlicing = instance_.traceLevels().slicing; _slicingCat = instance_.traceLevels().slicingCat; } if(_traceSlicing > 0) { TraceUtil.traceSlicing("class", id, _slicingCat, instance_.initializationData().logger); } skipSlice(); // Slice off this derived part -- we don't understand it. id = readTypeId(); // Read next id for next iteration. continue; } else { Ice.NoObjectFactoryException ex = new Ice.NoObjectFactoryException(); ex.type = id; throw ex; } } int i = index; _readEncapsStack.unmarshaledMap[i] = v; // // Record each object instance so that // readPendingObjects can invoke ice_postUnmarshal // after all objects have been unmarshaled. // if(_objectList == null) { _objectList = new ArrayList(); } _objectList.Add(v); v.read__(this, false); patchReferences(i, null); return; } }