Exemplo n.º 1
0
        private static Role GetRole(Worksheet workSheet, int rrow)
        {
            Role role = new Role();

            role.Name = GetCellValue(workSheet, rrow, 2);
            string aliasesString = GetCellValue(workSheet, rrow, 3);
            var    aliases       = string.IsNullOrEmpty(aliasesString) ? new string[] { } : aliasesString.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries);

            foreach (string a in aliases)
            {
                role.AddAlias(a);
            }
            role.Tag = GetCellValue(workSheet, rrow, 6);
            string accountsString = GetCellValue(workSheet, rrow, 7);
            var    accounts       = string.IsNullOrEmpty(accountsString) ? new string[] { } : accountsString.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries);

            string csvTemplates = GetCellValue(workSheet, rrow, 4);
            string csvPorts     = GetCellValue(workSheet, rrow, 5);

            string[] templates = string.IsNullOrEmpty(csvTemplates) ? new string[] { } : csvTemplates.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
            string[] portLines = string.IsNullOrEmpty(csvPorts) ? new string[] { } : csvPorts.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);

            int numClusterEndpoints = templates.Length;

            for (int i = 0; i < numClusterEndpoints; i++)
            {
                string[] templateParts = string.IsNullOrEmpty(templates[i]) ? new string[] { } : templates[i].Split(new string[] { ":" }, StringSplitOptions.RemoveEmptyEntries);
                string   type          = templateParts[0].Trim();
                string   template      = templateParts[1];
                string[] ports         = string.IsNullOrEmpty(portLines[i]) ? new string[] { } : portLines[i].Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries);
                var      newEndpoint   = new ClusterEndpoint(template, type);
                foreach (string p in ports)
                {
                    newEndpoint.AddPort(int.Parse(p));
                }
                role.Endpoints.Add(newEndpoint);
            }
            foreach (string a in accounts)
            {
                role.AddAccount(a);
            }
            return(role);
        }