/*
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.Collections.Generic;
namespace dnSpy.Contracts.Hex.Editor {
///
/// Structure info provider
///
public abstract class HexStructureInfoProvider {
///
/// Constructor
///
protected HexStructureInfoProvider() { }
///
/// Gets all related fields. It's enough to return the span of the current field at
/// and the span of the full structure that contains the field.
///
/// Position
///
public abstract IEnumerable GetFields(HexPosition position);
///
/// Gets a tooltip or null
///
/// Position
///
public abstract object? GetToolTip(HexPosition position);
///
/// Gets a reference or null. The reference can be used to look up a high level
/// representation of the data, eg. the C# statement in decompiled code.
///
/// Position
///
public abstract object? GetReference(HexPosition position);
}
///
/// Field kind
///
public enum HexStructureFieldKind {
///
/// Some other kind
///
Other,
///
/// Span is the full structure
///
Structure,
///
/// Span is a sub structure
///
SubStructure,
///
/// Span is a field
///
Field,
///
/// Span is the current field
///
CurrentField,
}
///
/// Structure field
///
public readonly struct HexStructureField {
///
/// Span of field
///
public HexBufferSpan BufferSpan { get; }
///
/// Field kind
///
public HexStructureFieldKind Kind { get; }
///
/// true if it's the current field
///
public bool IsCurrentField => Kind == HexStructureFieldKind.CurrentField;
///
/// Constructor
///
/// Span of field
/// Field kind
public HexStructureField(HexBufferSpan bufferSpan, HexStructureFieldKind kind) {
BufferSpan = bufferSpan;
Kind = kind;
}
}
}