Ejemplo n.º 1
0
        /// <summary>
        /// Returns true if this implements given DaggerInterface
        /// </summary>
        /// <param name="daggerInterface"></param>
        /// <returns></returns>
        public bool Implements(DaggerInterface daggerInterface)
        {
            foreach (DaggerInterfacePin pin in daggerInterface._inputPins)
            {
                // find the input pin by name
                DaggerInterfacePin foundPin = GetInputPin(pin.PinName);
                if (foundPin == null)
                {
                    return(false);
                }

                // check type compatiblity
                if (!((foundPin.PinDataType.IsAssignableFrom(pin.PinDataType)) || pin.PinDataType.IsAssignableFrom(foundPin.PinDataType)))
                {
                    TypeConverter tc = TypeDescriptor.GetConverter(foundPin.PinDataType);
                    if (tc != null)
                    {
                        if (!tc.CanConvertFrom(foundPin.PinDataType))
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
            }

            foreach (DaggerInterfacePin pin in daggerInterface._outputPins)
            {
                // find the output pin by name
                DaggerInterfacePin foundPin = GetOutputPin(pin.PinName);
                if (foundPin == null)
                {
                    return(false);
                }

                // check type compatibility
                if (!((foundPin.PinDataType.IsAssignableFrom(pin.PinDataType)) || pin.PinDataType.IsAssignableFrom(foundPin.PinDataType)))
                {
                    TypeConverter tc = TypeDescriptor.GetConverter(foundPin.PinDataType);
                    if (tc != null)
                    {
                        return(tc.CanConvertFrom(foundPin.PinDataType));
                    }
                    else
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Returns true if interface contains a given Imported DaggerInterfacePin
        /// </summary>
        /// <param name="pin"></param>
        /// <returns></returns>
        public bool ContainsImportPin(DaggerInterfacePin pin)
        {
            foreach (DaggerInterfacePin inpin in this._inputPins)
            {
                if (inpin.PinDataType == pin.PinDataType && inpin.PinName == pin.PinName)
                {
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Contruct a DaggerInterface from an existing DaggerNode
        /// </summary>
        /// <param name="node"></param>
        public DaggerInterface(DaggerNode node)
        {
            _inputPins = new List <DaggerInterfacePin>();
            foreach (DaggerInputPin pin in node.InputPins)
            {
                DaggerInterfacePin newpin = AddInputPin(pin);
                if (newpin == null)
                {
                    throw new InvalidOperationException("Interface already contains an Input Pin named " + pin.Name);
                }
            }

            _outputPins = new List <DaggerInterfacePin>();
            foreach (DaggerOutputPin pin in node.OutputPins)
            {
                DaggerInterfacePin newpin = AddOutputPin(pin);
                if (newpin == null)
                {
                    throw new InvalidOperationException("Interface already contains an Output Pin named " + pin.Name);
                }
            }
        }
Ejemplo n.º 4
0
        public DaggerInterfacePin AddOutputPin(string pinName, Type pinDataType)
        {
            bool found = false;

            foreach (DaggerInterfacePin pin in _outputPins)
            {
                if (pin.PinName == pinName)
                {
                    found = true;
                    break;
                }
            }

            if (!found)
            {
                DaggerInterfacePin pin = new DaggerInterfacePin(pinName, pinDataType);
                _outputPins.Add(pin);
                return(pin);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 5
0
 public DaggerInterfacePin AddOutputPin(DaggerInterfacePin pin)
 {
     return(AddOutputPin(pin.PinName, pin.PinDataType));
 }
Ejemplo n.º 6
0
 private DaggerBasePin GetExportPin(DaggerInterfacePin pin, DaggerGraph Graph)
 {
     return((DaggerBasePin)Graph.GetExportPin(pin.PinName, pin.PinDataType));
 }