public static MyRequestContext SetQueryInfo(this MyRequestContext context, HttpRequest httpRequest) { var theGroup = context.GetOrCreate(context.GetGroupName_QueryInfos()); var queryCollection = httpRequest.Query; var keys = queryCollection.Keys; foreach (var key in keys) { StringValues values; if (!queryCollection.TryGetValue(key, out values)) { theGroup.Items[key] = null; } else { values = values.Where(x => !string.IsNullOrWhiteSpace(x)).ToArray(); foreach (var value in values) { //set by last one theGroup.Items[key] = value; } } } return(context); }
public static MyRequestContext SetUserInfo(this MyRequestContext context, HttpRequest httpRequest) { var theGroup = context.GetOrCreate(context.GetGroupName_UserInfos()); //todo return(context); }
public static MyRouteInfo GetRouteInfo(this MyRequestContext context) { var info = new MyRouteInfo(); var theGroup = context.GetOrCreate(context.GetGroupName_RouteInfos()); theGroup.Items.SetProperties(info); return(info); }
public static MyRequestContext SetRouteInfo(this MyRequestContext context, RouteData routeData) { if (context == null) { throw new ArgumentNullException(nameof(context)); } var theGroup = context.GetOrCreate(context.GetGroupName_RouteInfos()); foreach (var item in routeData.DataTokens) { theGroup.Items[item.Key] = item.Value?.ToString(); } foreach (var item in routeData.Values) { theGroup.Items[item.Key] = item.Value?.ToString(); } return(context); }