Example #1
0
        public override void OnReadFromXmlNode(IXmlCodeReader reader, XmlNode node)
        {
            base.OnReadFromXmlNode(reader, node);
            _eventId = XmlUtil.GetAttributeUInt(node, XMLATT_eventId);
            _firerId = XmlUtil.GetAttributeUInt(node, XMLATT_firerId);
            XmlNode portNode = node.SelectSingleNode(XML_FirerPort);

            if (portNode != null)
            {
                _firerPort = new EventPortOutFirer(this);
                _firerPort.OnReadFromXmlNode(reader, portNode);
            }
        }
Example #2
0
 public static void MakePortLinks(PortCollection ports)
 {
     foreach (LinkLineNodePort p in ports)
     {
         EventPortIn epi = p as EventPortIn;
         if (epi != null)
         {
             EventPortInFireEvent epife = epi as EventPortInFireEvent;
             //
             bool bLinked = false;
             foreach (LinkLineNodePort p2 in ports)
             {
                 bool bMatch = false;
                 if (epife != null)
                 {
                     EventPortOutFirer epof = p2 as EventPortOutFirer;
                     if (epof != null)
                     {
                         //it is a fire-event action
                         ComponentIconFireEvent cife = epof.PortOwner as ComponentIconFireEvent;
                         if (cife != null)
                         {
                             FireEventMethod fe1 = epife.FireEventMethod;
                             FireEventMethod fe2 = cife.Firer;
                             if (fe1 != null && fe2 != null && fe1.EventId == fe2.EventId && fe2.MemberId == fe2.MemberId)
                             {
                                 bMatch = true;
                             }
                         }
                     }
                 }
                 else
                 {
                     EventPortOut epo = p2 as EventPortOut;
                     if (epo != null)
                     {
                         if (epi.Event.IsSameObjectRef(epo.Event))
                         {
                             ComponentIconEvent cieDest = (ComponentIconEvent)(epi.PortOwner);
                             if (epo.IsActionExecuter(cieDest))
                             {
                                 bMatch = true;
                             }
                         }
                     }
                 }
                 if (bMatch)
                 {
                     if (p2.LinkedPortID == epi.PortID && p2.LinkedPortInstanceID == epi.PortInstanceID &&
                         epi.LinkedPortID == p2.PortID && epi.LinkedPortInstanceID == p2.PortInstanceID)
                     {
                         bLinked = true;
                         break;
                     }
                     else
                     {
                         //try to fix it
                         if (p2.LinkedPortID == 0 && epi.LinkedPortID == 0)
                         {
                             p2.LinkedPortID          = epi.PortID;
                             p2.LinkedPortInstanceID  = epi.PortInstanceID;
                             epi.LinkedPortID         = p2.PortID;
                             epi.LinkedPortInstanceID = p2.PortInstanceID;
                             bLinked = true;
                             break;
                         }
                         else
                         {
                             LinkLineNodePort lp;
                             lp = ports.GetPortByID(epi.LinkedPortID, epi.LinkedPortInstanceID);
                             if (lp == null)
                             {
                                 if (p2.LinkedPortID == 0)
                                 {
                                     p2.LinkedPortID          = epi.PortID;
                                     p2.LinkedPortInstanceID  = epi.PortInstanceID;
                                     epi.LinkedPortID         = p2.PortID;
                                     epi.LinkedPortInstanceID = p2.PortInstanceID;
                                     bLinked = true;
                                     break;
                                 }
                                 else
                                 {
                                     lp = ports.GetPortByID(p2.LinkedPortID, p2.LinkedPortInstanceID);
                                     if (lp == null)
                                     {
                                         p2.LinkedPortID          = epi.PortID;
                                         p2.LinkedPortInstanceID  = epi.PortInstanceID;
                                         epi.LinkedPortID         = p2.PortID;
                                         epi.LinkedPortInstanceID = p2.PortInstanceID;
                                         bLinked = true;
                                         break;
                                     }
                                 }
                             }
                             else
                             {
                                 if (lp.LinkedPortID == epi.PortID && lp.LinkedPortInstanceID == epi.PortInstanceID)
                                 {
                                     bLinked = true;
                                     break;
                                 }
                             }
                         }
                     }
                 }
             }
             if (!bLinked)
             {
                 if (epi.LinkedPortID != 0)
                 {
                     LinkLineNodePort lp;
                     lp = ports.GetPortByID(epi.LinkedPortID, epi.LinkedPortInstanceID);
                     if (lp == null || lp != epi)
                     {
                         epi.LinkedPortInstanceID = 0;
                         epi.LinkedPortID         = 0;
                     }
                 }
                 if (epi.LinkedPortID == 0)
                 {
                 }
             }
         }
     }
     foreach (LinkLineNodePort p in ports)
     {
         EventPortOut epo = p as EventPortOut;
         if (epo != null)
         {
             if (epo.LinkedPortID != 0)
             {
                 if (ports.GetPortByID(epo.LinkedPortID, epo.LinkedPortInstanceID) == null)
                 {
                     epo.LinkedPortInstanceID = 0;
                     epo.LinkedPortID         = 0;
                 }
             }
         }
     }
 }