Exemplo n.º 1
0
        private string GetNamesGreetingMesage(IFormatedMessage message)
        {
            string res = string.Empty;

            if (message.Names.Length > 0)
            {
                res = message.GetStartMessage(message.Names[0]);

                if (message.Names.Length > 2)
                {
                    for (int iCount = 1; iCount < message.Names.Length; iCount++)
                    {
                        if (iCount != message.Names.Length - 1)
                        {
                            res = res + coma + " " + message.Names[iCount];
                        }
                        else
                        {
                            res = message.GetEndMessage(res, message.Names[iCount]);
                        }
                    }
                }
                else if (message.Names.Length == 2)
                {
                    res = message.GetTwoNamesMessage(message.Names[0], message.Names[1]);
                }
                else
                {
                    res = message.GetSingleNameMessage(message.Names[0]);
                }
            }
            return(res);
        }
Exemplo n.º 2
0
        internal string Greet(string name)
        {
            IFormatedMessage message = messageFactory.GetMessageByName(name);

            if (message == null)
            {
                return($"{hello}, my friend.");
            }
            else
            {
                var names = name.Split(',');
                if (names.Length == 2)
                {
                    result = message.GetTwoNamesMessage(names[0], names[1]);
                }
                else if (names.Length > 2)
                {
                    result = ProcessMultipleNames(names);
                }
                else
                {
                    result = message.GetSingleNameMessage(name);
                }
            }

            return(result);
        }