private Task <IListener> BuildListener(JobHostConfiguration config, ApiHubFileTriggerAttribute attribute, string functionName, ITriggeredFunctionExecutor executor, TraceWriter trace)
        {
            var root = GetFileSource(attribute.ConnectionStringSetting);

            string path = attribute.Path;
            int    i    = path.LastIndexOf('/');

            if (i == -1)
            {
                i = path.LastIndexOf('\\');
            }

            string folderName;

            if (i <= 0)
            {
                // This is the root folder
                folderName = "/";
            }
            else
            {
                folderName = path.Substring(0, i);
            }

            var folder = root.GetFolderReference(folderName);

            var listener = new ApiHubListener(this, config, folder, functionName, executor, trace, attribute);

            return(Task.FromResult <IListener>(listener));
        }
        private async Task <IListener> BuildListener(ApiHubFileTriggerAttribute attribute, ITriggeredFunctionExecutor executor, TraceWriter trace)
        {
            var root = GetFileSource(attribute.Key);

            string path = attribute.Path;
            int    i    = path.LastIndexOf('/');

            if (i == -1)
            {
                i = path.LastIndexOf('\\');
            }

            string folderName;

            if (i <= 0)
            {
                // This is the root folder
                folderName = "/";
            }
            else
            {
                folderName = path.Substring(0, i);
            }

            var folder = await root.GetFolderReferenceAsync(folderName);

            var listener = new ApiHubListener(folder, executor, trace, attribute.PollIntervalInSeconds, attribute.FileWatcherType);

            return(listener);
        }