Ejemplo n.º 1
0
        /// <summary>
        /// Prior to this call, you must have created the connector using the
        /// </summary>
        /// <param name="self"></param>
        /// <param name="deserializationContext"></param>
        public void LoadFromXElement(XElement self, DeserializationContext deserializationContext)
        {
            IModel model            = null;
            string connectorName    = self.Attribute("connectorName").Value;
            string connectorDesc    = self.Attribute("connectorDesc").Value;
            Guid   connectorGuidWas = XmlConvert.ToGuid(self.Attribute("connectorGuid").Value);
            Guid   connectorGuidIs  = Guid.NewGuid();

            deserializationContext.SetNewGuidForOldGuid(connectorGuidWas, connectorGuidIs);
            IMOHelper.Initialize(ref m_model, model, ref m_name, connectorName, ref m_description, connectorDesc, ref m_guid, connectorGuidIs);
            IMOHelper.RegisterWithModel(this);

            XElement    source = self.Element("Source");
            Guid        upstreamOwnerGuidWas = XmlConvert.ToGuid(source.Attribute("guid").Value);
            Guid        upstreamOwnerGuidIs  = Guid.NewGuid();
            string      upstreamPortName     = source.Attribute("name").Value;
            IPortOwner  usmb         = (IPortOwner)deserializationContext.GetModelObjectThatHad(upstreamOwnerGuidWas);
            IOutputPort upstreamPort = (IOutputPort)usmb.Ports[upstreamPortName];

            XElement   destination            = self.Element("Destination");
            Guid       downstreamOwnerGuidWas = XmlConvert.ToGuid(destination.Attribute("guid").Value);
            Guid       downstreamOwnerGuidIs  = Guid.NewGuid();
            string     downstreamPortName     = destination.Attribute("name").Value;
            IPortOwner dsmb           = (IPortOwner)deserializationContext.GetModelObjectThatHad(downstreamOwnerGuidWas);
            IInputPort downstreamPort = (IInputPort)dsmb.Ports[downstreamPortName];

            Connect(upstreamPort, downstreamPort);
        }