/// <summary> /// Converts an enumerable list of <see cref="T:Stumps.Server.HttpHeader"/> objects into an /// array of <see cref="T:Stumps.Web.Models.HeaderModel"/> objects. /// </summary> /// <param name="headers">The enumerable list of <see cref="T:Stumps.Server.HttpHeader"/> objects.</param> /// <returns>An array of <see cref="T:Stumps.Web.Models.HeaderModel"/> objects.</returns> private HeaderModel[] CreateHeaderModel(IHttpHeaders headers) { var headerList = new List<HeaderModel>(); foreach (var header in headers.HeaderNames) { var headerModel = new HeaderModel { Name = header, Value = headers[header] }; headerList.Add(headerModel); } return headerList.ToArray(); }
private HeaderModel[] CreateHeadersFromRules(StumpContract contract) { var models = new List<HeaderModel>(); var rules = contract.Rules.FindRuleContractByName(typeof(HeaderRule).Name); foreach (var rule in rules) { var headerRule = ContractBindings.CreateRuleFromContract<HeaderRule>(rule); var model = new HeaderModel { Name = headerRule.HeaderNameTextMatch, Value = headerRule.HeaderValueTextMatch }; models.Add(model); } return models.ToArray(); }
/// <summary> /// Generates the HTTP headers used by a <see cref="T:Stumps.IStumpsHttpContextPart"/>. /// </summary> /// <param name="part">The <see cref="T:Stumps.IStumpsHttpContextPart"/> used to generate headers.</param> /// <returns>An array of <see cref="Stumps.Web.Models.HeaderModel"/> objects.</returns> private HeaderModel[] GenerateHeaderModels(IStumpsHttpContextPart part) { var modelList = new List<HeaderModel>(); foreach (var headerName in part.Headers.HeaderNames) { var modelHeader = new HeaderModel { Name = headerName, Value = part.Headers[headerName] }; modelList.Add(modelHeader); } return modelList.ToArray(); }