//
// 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;
///
/// Builder for .
///
public class HookOptionsBuilder
{
private bool _hook;
private string _pattern;
private int _offset;
///
/// Initializes a new instance of the class.
///
/// The options.
internal HookOptionsBuilder(HookOptions options)
{
_hook = options.Hook;
_pattern = options.MemoryPattern;
_offset = options.Offset;
}
///
/// Initializes a new instance of the class.
///
/// Whether to hook the function.
/// The default pattern.
/// The default offset.
internal HookOptionsBuilder(bool hook, string pattern, int offset)
{
_offset = offset;
_pattern = pattern;
_hook = hook;
}
///
/// 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(_hook, _pattern, _offset);
}