コード例 #1
0
        public void Run(PortMap pm)
        {
            Int32 ret = NativeMethods.ion_builder_run(obj, pm.obj);

            if (ret != 0)
            {
                throw new InvalidOperationException();
            }
        }
コード例 #2
0
ファイル: SubModule.cs プロジェクト: RDunkley/VHDLCodeGen
        /// <summary>
        ///   Validates that mappings have a one-to-one relationship.
        /// </summary>
        /// <exception cref="InvalidOperationException">The maps don't have a one-to-one relationship.</exception>
        private void ValidateMappings()
        {
            if (Component.Generics.Count != GenericMap.Count)
            {
                throw new InvalidOperationException(string.Format
                                                    (
                                                        "The sub-module ({0}), does not have the same amount of generic maps ({1}) as the associated component's ({2}) generics ({3}).",
                                                        Name,
                                                        GenericMap.Count.ToString(),
                                                        Component.Name,
                                                        Component.Generics.Count.ToString()
                                                    ));
            }

            foreach (SimplifiedGenericInfo info in Component.Generics)
            {
                if (!GenericMap.ContainsKey(info))
                {
                    throw new InvalidOperationException(string.Format
                                                        (
                                                            "The sub-module ({0}), does not have a mapping for a generic ({1}) in the associated component ({2}).",
                                                            Name,
                                                            info.Name,
                                                            Component.Name
                                                        ));
                }
            }

            if (Component.Ports.Count != PortMap.Count)
            {
                throw new InvalidOperationException(string.Format
                                                    (
                                                        "The sub-module ({0}), does not have the same amount of port maps ({1}) as the associated component's ({2}) ports ({3}).",
                                                        Name,
                                                        PortMap.Count.ToString(),
                                                        Component.Name,
                                                        Component.Ports.Count.ToString()
                                                    ));
            }

            foreach (SimplifiedPortInfo info in Component.Ports)
            {
                if (!PortMap.ContainsKey(info))
                {
                    throw new InvalidOperationException(string.Format
                                                        (
                                                            "The sub-module ({0}), does not have a mapping for a port ({1}) in the associated component ({2}).",
                                                            Name,
                                                            info.Name,
                                                            Component.Name
                                                        ));
                }
            }
        }
コード例 #3
0
        private static bool TryGetContainerTcpPort(PortMap portMap, out int port)
        {
            string portString = string.Empty;

            foreach (var portMapKey in portMap.Keys)
            {
                if (portMapKey.Contains("/tcp"))
                {
                    portString = portMapKey.Substring(0, portMapKey.IndexOf("/"));
                }
            }

            return(int.TryParse(portString, out port));
        }
コード例 #4
0
        public void PortValidation(int port1, int port2, bool sameProtocol, bool allowed)
        {
            // Arrange
            var protocol = new DummyProtocol(7);

            PortMap.Register(IPAddress.Parse("192.168.0.42"), port1, protocol);

            // Act
            var success = PortMap.Register(IPAddress.Parse("192.168.0.42"), port2, new DummyProtocol(sameProtocol ? 7 : 9));

            // Assert
            if (allowed)
            {
                Assert.IsTrue(success, "Failed to register despite different address");
            }
            else
            {
                Assert.IsFalse(success, "Should not allow registration");
            }
        }
コード例 #5
0
        public void AddressValidation(string address1, string address2, bool sameProtocol, bool allowed)
        {
            // Arrange
            var protocol = new DummyProtocol(7);

            PortMap.Register(IPAddress.Parse(address1), 42, protocol);

            // Act
            var success = PortMap.Register(IPAddress.Parse(address2), 42, new DummyProtocol(sameProtocol ? 7 : 9));

            // Assert
            if (allowed)
            {
                Assert.IsTrue(success, "Failed to register despite different address");
            }
            else
            {
                Assert.IsFalse(success, "Should not allow registration");
            }
        }