Exemplo n.º 1
0
        public static async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req,
            [Inject] IPrimaryInterface primaryInterface,
            ILogger log)
        {
            log.LogInformation("C# HTTP trigger function processed a request.");

            string name = req.Query["name"];

            string  requestBody = await new StreamReader(req.Body).ReadToEndAsync();
            dynamic data        = JsonConvert.DeserializeObject(requestBody);

            name = name ?? data?.name;

            if (name == null)
            {
                return(new BadRequestObjectResult("Please pass a name on the query string or in the request body"));
            }

            else
            {
                name = primaryInterface.ThisIsAMethod("hello", name);
                return((ActionResult) new OkObjectResult($"Hello, {name}"));
            }
        }
Exemplo n.º 2
0
        public void InitializeContainer()
        {
            var services = new ServiceCollection();

            services.AddClassLibraryDependencies();

            var provider = services.BuildServiceProvider();

            _primary = provider.GetService <IPrimaryInterface>();
        }
Exemplo n.º 3
0
 public TestClass(IPrimaryInterface primaryInterface)
 {
     _primaryInterface = primaryInterface;
 }