using Microsoft.AspNetCore.Http;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace MEU.API.MiddleWare
{
    public class RequestParams
    {
        static string sPrefix = "_MIDDLEPARAMPREFIX_";
        //static HttpContext context = null;

        //public static void reset(HttpContext _context) {
        //    context = _context;
        //}
        public static object getParam(string ParamName)
        {
            HttpContext context = AppHttpContext.Current;
            ParamName = sPrefix + ParamName;
            if (context!=null && context.Items.ContainsKey(ParamName))
            {
                return context.Items[ParamName];
            }
            else
            {
                return null;
            }               
        }
        public static void setParam(string ParamName, object Value)
        {
            HttpContext context = AppHttpContext.Current;
            ParamName = sPrefix + ParamName;
            if (context.Items.ContainsKey(ParamName))
            {
                context.Items[ParamName] = Value;
            }
            else
            {
                context.Items.Add(ParamName, Value);
            }
        }
    }
}
