/* 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; namespace dnSpy.Contracts.Hex { /// /// Creates s /// public abstract class HexBufferFactoryService { /// /// Constructor /// protected HexBufferFactoryService() { EmptyTags = new HexTags(Array.Empty()); DefaultMemoryTags = new HexTags(defaultMemoryTags); DefaultFileTags = new HexTags(defaultFileTags); } static readonly string[] defaultMemoryTags = new string[] { PredefinedHexBufferTags.Memory, }; static readonly string[] defaultFileTags = new string[] { PredefinedHexBufferTags.File, }; /// /// Gets the empty tags collection /// public HexTags EmptyTags { get; } /// /// Default memory tags /// public HexTags DefaultMemoryTags { get; } /// /// Default file / byte array tags /// public HexTags DefaultFileTags { get; } /// /// Creates a new instance /// /// Tags /// public HexTags CreateTags(IEnumerable tags) => new HexTags(tags); /// /// Raised when a new has been created /// public abstract event EventHandler? HexBufferCreated; /// /// Creates a new /// /// Filename /// Tags or null to use the default file tags /// public abstract HexBuffer Create(string filename, HexTags? tags = null); /// /// Creates a new /// /// Data /// Name, can be anything and is usually the filename /// Tags or null to use the default file tags /// public abstract HexBuffer Create(byte[] data, string name, HexTags? tags = null); /// /// Creates a new /// /// Stream to use /// Tags /// true if the returned buffer owns and /// disposes it when the buffer gets disposed /// public abstract HexBuffer Create(HexBufferStream stream, HexTags tags, bool disposeStream); } }