public static MyContext SetUserInfo(this MyContext context, HttpRequest httpRequest) { var theGroup = context.GetOrCreate(context.GetGroupName_UserInfos()); //todo return(context); }
public static MyQueryInfo GetQueryInfo(this MyContext context) { var info = new MyQueryInfo(); var theGroup = context.GetOrCreate(context.GetGroupName_QueryInfos()); theGroup.Items.SetProperties(info); return(info); }
public static MyContext AppendPageInfos(this MyContext context, ViewContext viewContext) { var theGroup = context.GetOrCreate(context.GetGroupName_PageInfos()); var myPageInfo = viewContext.CreateMyPageInfo(); theGroup.Items[viewContext.View.Path] = myPageInfo.ToJson(); return(context); }
public static IList <MyPageInfo> GetPageInfos(this MyContext context) { var myPageInfos = new List <MyPageInfo>(); var theGroup = context.GetOrCreate(context.GetGroupName_PageInfos(), false); if (theGroup == null) { return(myPageInfos); } var jsonList = theGroup.Items.Values.ToList(); return(jsonList.Select(x => x.FromJson <MyPageInfo>(null)).Where(x => x != null).ToList()); }
public static MyContext SetRouteInfo(this MyContext 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); }
public static MyContext SetQueryInfo(this MyContext context, HttpRequest httpRequest) { var theGroup = context.GetOrCreate(context.GetGroupName_QueryInfos()); var queryCollection = httpRequest.Query; var keys = queryCollection.Keys; foreach (var key in keys) { if (!queryCollection.TryGetValue(key, out var 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); }