示例#1
0
        internal InfrastructureNode AddInfrastructureNode(DeploymentNode parent, string name, string description, string technology, Dictionary <string, string> properties)
        {
            if (name == null || name.Trim().Length == 0)
            {
                throw new ArgumentException("A name must be specified.");
            }

            if (parent.GetDeploymentNodeWithName(name) == null && parent.GetInfrastructureNodeWithName(name) == null)
            {
                InfrastructureNode infrastructureNode = new InfrastructureNode
                {
                    Name        = name,
                    Description = description,
                    Technology  = technology,
                    Parent      = parent,
                    Environment = parent.Environment
                };

                if (properties != null)
                {
                    infrastructureNode.Properties = properties;
                }

                infrastructureNode.Id = IdGenerator.GenerateId(infrastructureNode);
                AddElementToInternalStructures(infrastructureNode);

                return(infrastructureNode);
            }
            else
            {
                throw new ArgumentException("A deployment/infrastructure node named '" + name + "' already exists.");
            }
        }
示例#2
0
        internal DeploymentNode AddDeploymentNode(DeploymentNode parent, string environment, string name, string description, string technology, int instances, Dictionary <string, string> properties)
        {
            if (name == null || name.Trim().Length == 0)
            {
                throw new ArgumentException("A name must be specified.");
            }

            if ((parent == null && GetDeploymentNodeWithName(name, environment) == null) || (parent != null && parent.GetDeploymentNodeWithName(name) == null && parent.GetInfrastructureNodeWithName(name) == null))
            {
                DeploymentNode deploymentNode = new DeploymentNode
                {
                    Name        = name,
                    Description = description,
                    Technology  = technology,
                    Parent      = parent,
                    Instances   = instances,
                    Environment = environment
                };

                if (properties != null)
                {
                    deploymentNode.Properties = properties;
                }

                if (parent == null)
                {
                    _deploymentNodes.Add(deploymentNode);
                }

                deploymentNode.Id = _idGenerator.GenerateId(deploymentNode);
                AddElementToInternalStructures(deploymentNode);

                return(deploymentNode);
            }
            else
            {
                throw new ArgumentException("A deployment/infrastructure node named '" + name + "' already exists.");
            }
        }