You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.2 KiB
40 lines
1.2 KiB
using System;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Win.Utils;
|
|
|
|
namespace Win.Sfs.Shared.CurrentBranch
|
|
{
|
|
public class BranchManager: IBranchManager
|
|
{
|
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
|
|
|
protected BranchManager() { }
|
|
|
|
public BranchManager(IHttpContextAccessor httpContextAccessor)
|
|
{
|
|
_httpContextAccessor = httpContextAccessor;
|
|
}
|
|
|
|
public virtual Guid GetId()
|
|
{
|
|
var context = _httpContextAccessor.HttpContext;
|
|
|
|
var strBranchId = context?.Request.Headers[BranchHeaderConsts.HeaderName];
|
|
if (string.IsNullOrEmpty(strBranchId))
|
|
return Guid.NewGuid();
|
|
var branchId = Guid.Parse(strBranchId);
|
|
return branchId;
|
|
}
|
|
|
|
// public virtual T GetId<T>()
|
|
// {
|
|
// var context = _httpContextAccessor.HttpContext;
|
|
//
|
|
// var strBranchId = context?.Request.Headers[BranchHeaderConsts.HeaderName];
|
|
// if (string.IsNullOrEmpty(strBranchId))
|
|
// return default;
|
|
// var t = strBranchId.ChangeType<T>();
|
|
// return t;
|
|
// }
|
|
}
|
|
}
|