// // HookOptionsBuilder.cs // // Copyright (c) František Boháček. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. namespace NosSmooth.LocalBinding.Hooks; /// /// Builder for . /// /// The type of hook options. public class HookOptionsBuilder { private string _name; private bool _hook; private string _pattern; private int _offset; /// /// Initializes a new instance of the class. /// /// The options. internal HookOptionsBuilder(HookOptions options) { _name = options.Name; _hook = options.Hook; _pattern = options.MemoryPattern; _offset = options.Offset; } /// /// Configure whether to hook this function. /// Default true. /// /// Whether to hook the function. /// This builder. public HookOptionsBuilder Hook(bool hook = true) { _hook = hook; return this; } /// /// Configure the memory pattern. /// Use ?? for any bytes. /// /// The memory pattern. /// This builder. public HookOptionsBuilder MemoryPattern(string pattern) { _pattern = pattern; return this; } /// /// Configure the offset from the pattern. /// /// The offset. /// This builder. public HookOptionsBuilder Offset(int offset) { _offset = offset; return this; } /// /// Create hook options from this builder. /// /// The options. internal HookOptions Build() => new HookOptions(_name, _hook, _pattern, _offset); }