Ejemplo n.º 1
0
        /// <summary>
        /// Attaches this Node's object's member (specified by thisMember) as outgoing pin to the specified member of the object hosted by the other node.
        /// A member can be any field or property.
        /// </summary>
        /// <param name="thisMemberOut">The member of this node emitting values.</param>
        /// <param name="other">The other node.</param>
        /// <param name="otherMemberIn">The other node's object's member receiving values.</param>
        /// <remarks>
        /// This is a high-level method users can call to do the wiring inside a <see cref="Circuit"/>. It creates all the necessary in- and out-pins
        /// together with their respective member accessors.
        /// </remarks>
        public void Attach(string thisMemberOut, Node other, string otherMemberIn)
        {
            IOutPin outPin = GetOutPin(thisMemberOut);
            IInPin  inPin  = other.GetInPin(otherMemberIn, outPin.GetPinType());

            outPin.Attach(inPin);
        }
Ejemplo n.º 2
0
        public static void ReAttachOutPin(Node n, IOutPin op)
        {
            string member = op.Member;
            object elementAccessor;
            Type   memberType = GetMemberTypeAndAccessor(n, member, null, out elementAccessor);

            // This does a ip.ElementAccessor = elementAccessor. We need to use reflection because the type is not known at compile time
            op.GetType().GetProperty("MemberAccessor").SetValue(op, elementAccessor, null);
        }
Ejemplo n.º 3
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);
        }