/// <summary>
        /// Adds a new data input port on a node.
        /// </summary>
        /// <param name="self">The node to add the new port on.</param>
        /// <param name="portName">The name of port to create.</param>
        /// <param name="portId">The ID of the port to create.</param>
        /// <param name="orientation">The orientation of the port to create.</param>
        /// <param name="options">The options for the port to create.</param>
        /// <param name="defaultValue">The default value to assign to the constant associated to the port.</param>
        /// <typeparam name="TDataType">The type of data the port to create handles.</typeparam>
        /// <returns>The newly created data input port.</returns>
        public static IPortModel AddDataInputPort <TDataType>(this IInputOutputPortsNodeModel self, string portName,
                                                              string portId            = null, PortOrientation orientation = PortOrientation.Horizontal,
                                                              PortModelOptions options = PortModelOptions.Default, TDataType defaultValue = default)
        {
            Action <IConstant> initializationCallback = null;

            if (defaultValue is Enum || !EqualityComparer <TDataType> .Default.Equals(defaultValue, default))
            {
                initializationCallback = constantModel => constantModel.ObjectValue = defaultValue;
            }

            return(self.AddDataInputPort(portName, typeof(TDataType).GenerateTypeHandle(), portId, orientation, options, initializationCallback));
        }
 public override IPortModel CreatePort(PortDirection direction, PortOrientation orientation, string portName, PortType portType, TypeHandle dataType, string portId, PortModelOptions options)
 {
     return(new MathExpressionPortModel
     {
         Direction = direction,
         Orientation = orientation,
         PortType = portType,
         DataTypeHandle = dataType,
         Title = portName ?? "",
         UniqueName = portId,
         Options = options,
         NodeModel = this,
         AssetModel = AssetModel
     });
 }
 public override IPortModel CreatePort(PortDirection direction, PortOrientation orientation, string portName, PortType portType,
                                       TypeHandle dataType, string portId, PortModelOptions options)
 {
     return(new FakePortModel(GraphModel)
     {
         Direction = direction,
         Orientation = orientation,
         Title = portName,
         PortType = portType,
         DataTypeHandle = dataType,
         NodeModel = this
     });
 }
 public PortModel(string name = null, string uniqueId = null, PortModelOptions options = PortModelOptions.Default)
 {
     m_Name     = name;
     m_UniqueId = uniqueId;
     Options    = options;
 }
        public override IPortModel CreatePort(PortDirection direction, PortOrientation orientation, string portName,
                                              PortType portType, TypeHandle dataType, string portId, PortModelOptions options)
        {
            var port = new PortModel
            {
                Direction      = direction,
                Orientation    = orientation,
                PortType       = portType,
                DataTypeHandle = dataType,
                Title          = portName,
                UniqueName     = portId,
                Options        = options,
                NodeModel      = this
            };

            port.SetGraphModel(GraphModel);
            return(port);
        }
 /// <summary>
 /// Adds a new data input port on a node.
 /// </summary>
 /// <param name="self">The node to add the new port on.</param>
 /// <param name="portName">The name of port to create.</param>
 /// <param name="dataType">The type of data the port to create handles.</param>
 /// <param name="portId">The ID of the port to create.</param>
 /// <param name="orientation">The orientation of the port to create.</param>
 /// <param name="options">The options for the port to create.</param>
 /// <param name="initializationCallback">An initialization method for the associated constant (if one is needed
 /// for the port) to be called right after the port is created.</param>
 /// <returns>The newly created data input port.</returns>
 public static IPortModel AddDataInputPort(this IInputOutputPortsNodeModel self, string portName, TypeHandle dataType,
                                           string portId            = null, PortOrientation orientation = PortOrientation.Horizontal,
                                           PortModelOptions options = PortModelOptions.Default, Action <IConstant> initializationCallback = null)
 {
     return(self.AddInputPort(portName, PortType.Data, dataType, portId, orientation, options, initializationCallback));
 }
 /// <summary>
 /// Adds a new data output port on a node.
 /// </summary>
 /// <param name="self">The node to add the new port on.</param>
 /// <param name="portName">The name of port to create.</param>
 /// <param name="dataType">The type of data the port to create handles.</param>
 /// <param name="portId">The ID of the port to create.</param>
 /// <param name="orientation">The orientation of the port to create.</param>
 /// <param name="options">The options for the port to create.</param>
 /// <returns>The newly created data output port.</returns>
 public static IPortModel AddDataOutputPort(this IInputOutputPortsNodeModel self, string portName, TypeHandle dataType,
                                            string portId            = null, PortOrientation orientation = PortOrientation.Horizontal,
                                            PortModelOptions options = PortModelOptions.Default)
 {
     return(self.AddOutputPort(portName, PortType.Data, dataType, portId, orientation, options));
 }