/* 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.ObjectModel; using System.ComponentModel.Composition; namespace dnSpy.Contracts.Documents { /// /// Shows a reference /// public abstract class ReferenceNavigatorService { /// /// Shows a reference. It can be called from any thread. /// /// Reference. MEF exported s can convert this to another reference. /// Options passed to s, eg. public abstract void GoTo(object? reference, object[]? options = null); } /// /// Predefined options /// public static class PredefinedReferenceNavigatorOptions { /// /// Show the reference in a new tab /// public const string NewTab = nameof(NewTab); } /// /// Shows a reference. Use to export an instance. /// public abstract class ReferenceNavigator { /// /// Returns true if it showed the reference, and false if the next handler should get called. /// This method is called on the UI thread. /// /// Reference. MEF exported s can convert this reference to another reference. /// Options passed to s, eg. /// public abstract bool GoTo(object reference, ReadOnlyCollection options); } /// Metadata public interface IReferenceNavigatorMetadata { /// See double Order { get; } } /// /// Exports a instance /// [MetadataAttribute, AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] public sealed class ExportReferenceNavigatorAttribute : ExportAttribute, IReferenceNavigatorMetadata { /// Constructor public ExportReferenceNavigatorAttribute() : base(typeof(ReferenceNavigator)) => Order = double.MaxValue; /// /// Order of this instance /// public double Order { get; set; } } /// /// Converts a reference passed to . This /// new reference is passed to . /// Use to export an instance. /// public abstract class ReferenceConverter { /// /// Converts a reference. If null is written to , /// won't get called. /// This method is called on the UI thread. /// /// Reference public abstract void Convert(ref object? reference); } /// Metadata public interface IReferenceConverterMetadata { /// See double Order { get; } } /// /// Exports a instance /// [MetadataAttribute, AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] public sealed class ExportReferenceConverterAttribute : ExportAttribute, IReferenceConverterMetadata { /// Constructor public ExportReferenceConverterAttribute() : base(typeof(ReferenceConverter)) => Order = double.MaxValue; /// /// Order of this instance /// public double Order { get; set; } } }