/*
Copyright (C) 2014-2019 de4dot@gmail.com
This file is part of dnSpy
dnSpy is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
dnSpy is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with dnSpy. If not, see .
*/
using System;
using System.Collections.Generic;
using System.Linq;
namespace dnSpy.Contracts.Decompiler {
///
/// Decompiler settings
///
public abstract class DecompilerSettingsBase {
///
/// Clones the settings
///
///
public abstract DecompilerSettingsBase Clone();
///
/// Version number that gets incremented whenever the options change
///
public abstract int Version { get; }
///
/// Raised when is changed
///
public abstract event EventHandler? VersionChanged;
///
/// Gets all options
///
public abstract IEnumerable Options { get; }
///
/// Returns an option or null
///
/// Guid
///
public IDecompilerOption? TryGetOption(Guid guid) => Options.FirstOrDefault(a => a.Guid == guid);
///
/// Returns an option or null
///
/// Name
///
public IDecompilerOption? TryGetOption(string name) => Options.FirstOrDefault(a => StringComparer.Ordinal.Equals(a.Name, name));
///
/// Returns a boolean or false if the option doesn't exist
///
/// Guid
///
public bool GetBoolean(Guid guid) => TryGetOption(guid)?.Value as bool? ?? false;
///
/// Returns a boolean or false if the option doesn't exist
///
/// Name
///
public bool GetBoolean(string name) => TryGetOption(name)?.Value as bool? ?? false;
///
/// Returns true if this instance equals
///
/// Other object, may be null
///
public abstract override bool Equals(object? obj);
///
/// Gets the hash code of this instance
///
///
public abstract override int GetHashCode();
}
}