private static StandardResponse GetResponseCategories(CategoryList categoryList, List <string> responsePath) { Pointel.Logger.Core.ILog _logger = Pointel.Logger.Core.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, "AID"); StandardResponseList responselist = null; StandardResponse response = null; try { //pointel\Email\actional\actional //pointel\Email\emailaccount //response:Pointel\Sanofi\Email\Actonal\Sanofi\Email\Actonal //pointel\Sanofi\Email\Actonal int index = 0; foreach (string categoryName in responsePath) { //it for find category list, Only if the Category is not last item and should has child category if (responsePath.IndexOf(categoryName) != responsePath.Count - 1 && categoryList != null && categoryList.Count > 0 && categoryList.Cast <Category>().Where(c => c.Name.Equals(categoryName)).ToList().Count > 0) { Category category = categoryList.Cast <Category>().Where(c => c.Name.Equals(categoryName)).Single(); if (category != null) { categoryList = category.ChildrenCategories; if (index == responsePath.Count - 2) { responselist = category.ChildrenStdResponses; break; } } } else //if the user gives wrong signature path. { break; } index++; } if (responselist != null && responselist.Count > 0 && responselist.Cast <StandardResponse>().Where(s => s.TheName.Equals(responsePath.LastOrDefault())).ToList().Count > 0) { response = responselist.Cast <StandardResponse>().Where(s => s.TheName.Equals(responsePath.LastOrDefault())).Single(); } } catch (Exception ex) { _logger.Error("Error occurred at : " + ((ex.InnerException == null) ? ex.Message.ToString() : ex.InnerException.ToString())); } finally { _logger = null; } return(response); }