namespace FoodFactory.Blueprints.Providers.Converters; using System; using SharpYaml.Serialization; public sealed class ComponentNameConverter : ItemComponentsConverter { public override IValueProvider Read(YamlReader reader) { if (reader.TokenType == YamlTokenType.Scalar) { var key = reader.GetScalarValue(); reader.Read(); return new StaticCompiledNode(new(key)); } return base.Read(reader); } public override void Write(YamlWriter writer, IValueProvider value) => throw new NotImplementedException(); } // public class ComponentBinderRegistry // { // private readonly Dictionary _binder = []; // public void Add(ComponentBinder componentBinder) where T : struct // { // _binder.Add(typeof(T), componentBinder); // } // public void Apply(Entity entity, World world, CompiledBlueprint itemData) // { // var s = world.GetSignature(entity); // for (int i = 0; i < s.Count; i++) // { // if (!_binder.ContainsKey(s.Components[i])) // { // continue; // } // var binder = _binder[s.Components[i]]; // var type = s.Components[i].Type; // var context = new BlueprintContext(){World = world}; // binder.ApplyUntyped(entity, itemData.Providers[type], context); // } // } // public void Apply(Span entities, World world, CompiledBlueprint itemData) // { // var signature = world.GetSignature(entities[0]); // for (int i = 1; i < entities.Length; i++) // { // Debug.Assert(world.GetSignature(entities[i]) == signature); // } // for (int i = 0; i < signature.Count; i++) // { // var binder = _binder[signature.Components[i]]; // var type = signature.Components[i].Type; // var context = new BlueprintContext(){World = world}; // binder.ApplyUntyped(entities, itemData.Providers[type], context); // } // } // } // public abstract class DataNode//(Dictionary Data) // { // public abstract DataNodeType NodeType { get; } // // public T Get(string name) => (T)Data[name]; // } // public enum DataNodeType // {hthous stomatitis, pharyngitis, adenitis) is a // Value, // Sequence, // Mapping, // Component // } // public sealed class ValueNode(object value) : DataNode // { // public override DataNodeType NodeType => DataNodeType.Value; // public object Value { get; set; } = value; // public Option As() => Value is T o?Option.Some(o):Option.None; // } // public sealed class SequenceNode(IReadOnlyList values) : DataNode // { // public override DataNodeType NodeType => DataNodeType.Sequence; // public IReadOnlyList Values { get; set; } = values; // } // public sealed class MappingNode(IReadOnlyDictionary values) : DataNode // { // public override DataNodeType NodeType => DataNodeType.Mapping; // public IReadOnlyDictionary Values { get; set; } = values; // public bool TryGet(string key, [NotNullWhen(true)] out T value) where T : DataNode // { // var result = Values.TryGetValue(key, out var node); // value = (T)node!; // return result; // } // public bool TryGet(string key, [NotNullWhen(true)] out DataNode node) => Values.TryGetValue(key, out node!); // } // public class DataNodeSerlicer : YamlConverter, IJsonFormatter // { // private Dictionary _data = new(); // public DataNode Deserialize(ref JsonReader reader, IJsonFormatterResolver formatterResolver) // { // var i = 0; // while (reader.ReadIsInObject(ref i)) // { // var name = reader.ReadPropertyName(); // var value = reader.ReadString(); // _data.Add(name, value); // } // throw new NotImplementedException(); // } // public void Serialize(ref JsonWriter writer, DataNode value, IJsonFormatterResolver formatterResolver) => throw new NotImplementedException(); // public override DataNode? Read(YamlReader reader) // { // // reader.pa // throw new NotImplementedException(); // } // public override void Write(YamlWriter writer, DataNode value) // { // throw new NotImplementedException(); // } // }