using Microsoft.AspNetCore.Http;
using System.Linq;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using System.Collections.Generic;

namespace HTCoreServiceApp.WebApi
{
	public static class Extension
	{
		/// <summary>
		/// 获取客户Ip
		/// </summary>
		/// <param name="context"></param>
		/// <returns></returns>
		public static string GetClientUserIp(this HttpContext context)
		{
			var ip = context.Request.Headers["X-Forwarded-For"].FirstOrDefault();
			if (string.IsNullOrEmpty(ip))
			{
				ip = context.Connection.RemoteIpAddress.ToString();
			}
			return ip;
		}
	}

	//public record WritePara(string TagName, string GroupName, string WriteAddress, byte DataType, string Value)
	//{
	//}
}
