Пример #1
0
        public string GetMessageBody(string fileContents)
        {
            string messageBody = string.Empty;
            bool   wasHandled  = false;

            foreach (IFileFormatReader formatReader in _formatReaders)
            {
                if (formatReader.CanHandle(fileContents))
                {
                    if (formatReader.GetType().Equals(typeof(DatabaseConnectionReader)))
                    {
                        messageBody = "pretend this came from a database. :)";
                    }
                    else
                    {
                        messageBody = formatReader.GetMessageBody(fileContents);
                    }
                    wasHandled = true;
                }
            }

            if (!wasHandled)
            {
                messageBody = _defaultFormatReader.GetMessageBody(fileContents);
            }

            return(messageBody);
        }
Пример #2
0
        private string ParseFileContents(string fileContents)
        {
            string messageBody = string.Empty;
            bool   wasHandled  = false;

            foreach (IFileFormatReader formatReader in formatReaders)
            {
                if (formatReader.CanHandle(fileContents))
                {
                    messageBody = formatReader.GetMessageBody(fileContents);
                    wasHandled  = true;
                }
            }

            if (!wasHandled)
            {
                messageBody = _defaultFormatReader.GetMessageBody(fileContents);
            }

            return(messageBody);
        }