// Copyright Epic Games, Inc. All Rights Reserved. using System; namespace EpicGames.Horde.Storage { /// /// Attribute used to denote the converter for an object type /// [AttributeUsage(AttributeTargets.Class)] public sealed class BlobConverterAttribute : Attribute { /// /// Type of the converter /// public Type ConverterType { get; } /// /// Constructor /// public BlobConverterAttribute(Type converterType) => ConverterType = converterType; } /// /// Base class for converter types that can serialize blobs from native C# types. Semantics mirror . /// public abstract class BlobConverter { /// /// Determines if the converter can handle the given type /// /// The type that needs to be converted /// True if this converter can handle the given type public abstract bool CanConvert(Type typeToConvert); } /// /// Serializer for typed values to blob data. Mimics the interface for familiarity. /// public abstract class BlobConverter : BlobConverter { /// public override bool CanConvert(Type type) => type == typeof(T); /// /// Reads a strongly typed value /// public abstract T Read(IBlobReader reader, BlobSerializerOptions options); /// /// Writes a strongly typed value /// public abstract BlobType Write(IBlobWriter writer, T value, BlobSerializerOptions options); } }