Exemplo n.º 1
0
        internal static VPort C2V(IPort contract)
        {
            if (contract == null)
            {
                return null;
            }

            if (!System.Runtime.Remoting.RemotingServices.IsObjectOutOfAppDomain(contract) &&
                (contract.GetType().Equals(typeof(PortV2C))))
            {
                return ((PortV2C)(contract)).GetSourceView();
            }
            else
            {
                return new PortC2V(contract);
            }
        }
Exemplo n.º 2
0
        internal static VPort C2V(IPort contract)
        {
            if (contract == null)
            {
                return(null);
            }

            if (!System.Runtime.Remoting.RemotingServices.IsObjectOutOfAppDomain(contract) &&
                (contract.GetType().Equals(typeof(PortV2C))))
            {
                return(((PortV2C)(contract)).GetSourceView());
            }
            else
            {
                return(new PortC2V(contract));
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Connects the Nexus to the specified port If the specified port is an input port, creates an output port
        /// on the nexus and adds a connector to the specified port from that output port. The relationship does not
        /// allow taking or peeking from the nexus.
        /// </summary>
        /// <param name="port">The port.</param>
        public void Bind(IPort port)
        {
            IPort myNewPort = null;

            if (port is IInputPort)
            {
                myNewPort = new SimpleOutputPort(m_model, "Output" + (m_outCount++), Guid.NewGuid(), this, m_cantTakeOrPeekFromNexus, m_cantTakeOrPeekFromNexus);
            }
            else if (port is IOutputPort)
            {
                myNewPort = new SimpleInputPort(m_model, "Input" + (m_inCount++), Guid.NewGuid(), this, m_canAlwaysAcceptData);
                myNewPort.PortDataAccepted += new PortDataEvent(OnPortDataAccepted);
            }
            else
            {
                throw new ApplicationException("Unknown port type " + port.GetType().Name + " encountered.");
            }
            // m_ports.AddPort(myNewPort); <-- Done in port's ctor.
            ConnectorFactory.Connect(port, myNewPort);
        }
Exemplo n.º 4
0
 public void Connect(IPort p1, IPort p2)
 {
     if (m_upstream != null || m_downstream != null)
     {
         throw new ApplicationException("Trying to connect an already-connected port.");
     }
     if (p1 is IInputPort && p2 is IOutputPort)
     {
         Attach((IInputPort)p1, (IOutputPort)p2);
     }
     else if (p2 is IInputPort && p1 is IOutputPort)
     {
         Attach((IInputPort)p2, (IOutputPort)p1);
     }
     else
     {
         throw new ApplicationException("Trying to connect non-compatible ports " + p1.GetType() + " and " + p2.GetType());
     }
     //Console.WriteLine("Just connected " + ((IHasIdentity)m_upstream.Owner).Name + "." + m_upstream.Key + " to " + ((IHasIdentity)m_downstream.Owner).Name + "." + m_downstream.Key);
     //Console.WriteLine(Upstream.Connector + ", " + Downstream.Connector);
 }