using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using Artemis.Core.Modules;
using Humanizer;
namespace Artemis.Core;
///
/// Represents a collection of output pins for a node capable of outputting the properties of an object or value type.
///
public class ObjectOutputPins
{
private readonly Dictionary, OutputPin> _propertyPins;
private OutputPin? _valueTypePin;
///
/// Creates an instance of the class.
///
/// The node the object output was created for.
public ObjectOutputPins(Node node)
{
Node = node;
_propertyPins = new Dictionary, OutputPin>();
}
///
/// Gets the node the object output was created for.
///
public Node Node { get; }
///
/// Gets the current type the node's pins are set up for.
///
public Type? CurrentType { get; private set; }
///
/// Gets a read only collection of the pins outputting the object of this object node.
///
public ReadOnlyCollection Pins => _valueTypePin != null ? new ReadOnlyCollection(new List {_valueTypePin}) : _propertyPins.Values.ToList().AsReadOnly();
///
/// Change the current type and create pins on the node to reflect this.
///
/// The type to change the collection to.
public void ChangeType(Type? type)
{
if (type == CurrentType)
return;
CurrentType = type;
// Remove current pins
foreach ((Func