Exemple #1
0
        /// <summary>
        /// Finds an existing out-pin already present an wired to the given member (field or property).
        /// If no such out-pin exists, a new one is created.
        /// </summary>
        /// <param name="member">The member.</param>
        /// <returns>A newly created or already existing out-pin</returns>
        private IOutPin GetOutPin(string member)
        {
            // See if the outpin pinning the given member already exists. If not create one.
            IOutPin outPin = _outPinList.Find(p => p.Member == member);

            if (outPin == null)
            {
                outPin = PinFactory.CreateOutPin(this, member);
                _outPinList.Add(outPin);
            }
            return(outPin);
        }
Exemple #2
0
        /// <summary>
        /// Create a new in-pin for the given member (field or property). If the member is already exposed by an in-pin
        /// an exception is thrown because a member cannot be governed by two in-pins. If a non-null target type is specified,
        /// the member will be connected to the pin using <see cref="ConvertingFieldAccessor{TPin,TObj}"/> or
        /// <see cref="ConvertingPropertyAccessor{TPin,TObj}"/>.
        /// </summary>
        /// <param name="member">The member.</param>
        /// <param name="targetType">Type of the target.</param>
        /// <returns></returns>
        /// <exception cref="System.Exception">A member is already connected as InPin.</exception>
        internal IInPin GetInPin(string member, Type targetType)
        {
            // See if the inpin already exists. If so, throw - because a property
            // can be inpinnned only once.
            IInPin inPin = _inPinList.Find(p => p.Member == member);

            if (inPin != null)
            {
                // TODO: throw an appropriate exception
                throw new Exception("Member " + member + " already connected as InPin!");
            }
            inPin = PinFactory.CreateInPin(this, member, targetType);

            _inPinList.Add(inPin);
            _inPinActualList[inPin] = false;
            inPin.ReceivedValue    += OnReceivedValue;
            return(inPin);
        }