public IEnumerable <HttpFunctionData> GetMethods()
 {
     foreach (var method in _typeLocator.GetTypes().SelectMany(x => x.GetMethods()))
     {
         var explorerSettings = method.GetCustomAttribute <ApiExplorerSettingsAttribute>(false);
         if (explorerSettings != null && explorerSettings.IgnoreApi)
         {
             continue;
         }
         var functionNameAttribute = method.GetCustomAttribute <FunctionNameAttribute>(false);
         if (functionNameAttribute == null)
         {
             continue;
         }
         if (!TryGetParameterWithAttribute <HttpTriggerAttribute>(method, out var httpTriggerParameter, out var httpTriggerAttribute))
         {
             continue;
         }
         yield return(new HttpFunctionData
         {
             MethodInfo = method,
             Name = functionNameAttribute.Name,
             TriggerAttribute = httpTriggerAttribute,
             TriggerParameter = httpTriggerParameter
         });
     }
 }
        private string ComputeHostId()
        {
            // Search through all types for the first job method.
            // The reason we have to do this rather than attempt to use the entry assembly
            // (Assembly.GetEntryAssembly) is because that doesn't work for WebApps, and the
            // SDK supports both WebApp and Console app hosts.
            MethodInfo firstJobMethod = null;

            foreach (var type in _typeLocator.GetTypes())
            {
                firstJobMethod = FunctionIndexer.GetJobMethods(type).FirstOrDefault();
                if (firstJobMethod != null)
                {
                    break;
                }
            }

            // Compute hash and map to Guid
            // If the job host doesn't yet have any job methods (e.g. it's a new project)
            // then a default ID is generated
            string hostName = firstJobMethod?.DeclaringType.Assembly.FullName ?? "Unknown";
            Guid   id;

            using (var md5 = MD5.Create())
            {
                var hash = md5.ComputeHash(Encoding.UTF8.GetBytes(hostName));
                id = new Guid(hash);
            }

            return(id.ToString("N"));
        }
        public IReadOnlyList <Type> GetCloudBlobStreamBinderTypes()
        {
            if (_cloudBlobStreamBinderTypes == null)
            {
                _cloudBlobStreamBinderTypes = GetCloudBlobStreamBinderTypes(_typeLocator.GetTypes());
            }

            return(_cloudBlobStreamBinderTypes);
        }
        private async Task <IFunctionIndex> CreateAsync(CancellationToken cancellationToken)
        {
            FunctionIndex        index   = new FunctionIndex();
            FunctionIndexer      indexer = new FunctionIndexer(_triggerBindingProvider, _bindingProvider, _activator, _executor, _extensions, _singletonManager, _trace, _loggerFactory);
            IReadOnlyList <Type> types   = _typeLocator.GetTypes();

            foreach (Type type in types)
            {
                await indexer.IndexTypeAsync(type, index, cancellationToken);
            }

            return(index);
        }
        private async Task <IFunctionIndex> CreateAsync(CancellationToken cancellationToken)
        {
            FunctionIndex        index           = new FunctionIndex();
            IBindingProvider     bindingProvider = _bindingProviderFactory;
            FunctionIndexer      indexer         = new FunctionIndexer(_triggerBindingProvider, bindingProvider, _activator, _executor, _extensions, _singletonManager, _loggerFactory, null, _sharedQueue, allowPartialHostStartup: _allowPartialHostStartup);
            IReadOnlyList <Type> types           = _typeLocator.GetTypes();

            foreach (Type type in types)
            {
                await indexer.IndexTypeAsync(type, index, cancellationToken);
            }

            return(index);
        }