/// <summary> /// Adds a new custom header to an existing list of custom headers. /// </summary> /// <param name="source">The existing list of custom headers.</param> /// <param name="name">The name of the new custom header.</param> /// <param name="value">The value for the new custom header.</param> /// <returns>Instance of <see cref="ICustomHeader"/></returns> /// <example> /// <code> /// var headers = new <![CDATA[ List<ICustomHeader> ]]>(); /// headers.Add("name1", "value1"); /// headers.Add("name2", "value2"); /// </code> /// </example> public static ICustomHeader Add(this IList <ICustomHeader> source, string name, string value) { var customHeader = new CustomHeader(name, value); source.Add(customHeader); return(customHeader); }
public async Task SetHeaderCommand(CommandContext ctx, string headerName, [RemainingText] string headerValue) { Logger.LogInformation($"Added header {headerName} = {headerValue}"); using (var db = new DatabaseDbContext()) { var customHeader = new CustomHeader { Name = headerName, Value = headerValue }; db.AddOrUpdate(customHeader); await db.SaveChangesAsync(); } }
protected override void FillRecipientCustoms(ApiRecipient recipient, string[] data, List <CustomHeader> headerList, List <FieldConfiguration> fields) { var auxObject = new Dictionary <int, object>(); for (int i = 0; i < data.Length; i++) { if (fields.Exists(f => f.Position == i && f.IsBasic) || string.IsNullOrEmpty(data[i])) { continue; } CustomHeader customHeader = headerList.First(h => h.Position == i); if (customHeader != null) { if (customHeader.NameCount == 1) { recipient.Fields.Add(customHeader.HeaderName, data[i]); } else { List <Dictionary <string, object> > list; if (!recipient.Fields.ContainsKey("list")) { list = new List <Dictionary <string, object> >(); recipient.Fields.Add("list", list); } else { list = recipient.Fields["list"] as List <Dictionary <string, object> >; } Dictionary <string, object> item; if (auxObject.ContainsKey(customHeader.Index)) { item = auxObject[customHeader.Index] as Dictionary <string, object>; } else { item = new Dictionary <string, object>(); auxObject.Add(customHeader.Index, item); list.Add(item); } item.Add(customHeader.Name, data[i]); recipient.Fields.Add(customHeader.HeaderName, data[i]); } } } }
//UpdateCustomHeader public static void UpdateCustomHeader(this CustomHeader customHeader, CustomHeaderViewModel customHeaderViewModel) { customHeader.ID = customHeaderViewModel.ID; customHeader.Type = customHeaderViewModel.Type; customHeader.Color = customHeaderViewModel.Color; customHeader.Content = customHeaderViewModel.Content; customHeader.PaddingTop = customHeaderViewModel.PaddingTop; customHeader.Height = customHeaderViewModel.Height; customHeader.CreatedDate = customHeaderViewModel.CreatedDate; customHeader.UpdateDate = customHeaderViewModel.UpdateDate; customHeader.CreatedBy = customHeaderViewModel.CreatedBy; customHeader.UpdateBy = customHeaderViewModel.UpdateBy; customHeader.Status = customHeaderViewModel.Status; }
public object BeforeSendRequest(ref Message request, IClientChannel channel) { //Instantiate new HeaderObject with values from ClientContext; var dataToSend = new CustomHeader { WebNodeId = ClientCustomHeaderContext.HeaderInformation.WebNodeId, WebSessionId = ClientCustomHeaderContext.HeaderInformation.WebSessionId, WebUserId = ClientCustomHeaderContext.HeaderInformation.WebUserId }; var typedHeader = new MessageHeader <CustomHeader>(dataToSend); var untypedHeader = typedHeader.GetUntypedHeader("custom-header", "s"); request.Headers.Add(untypedHeader); return(null); }
public object BeforeSendRequest(ref Message request, IClientChannel channel) { //Instantiate new HeaderObject with values from ClientContext; var dataToSend = new CustomHeader { WebNodeId = ClientCustomHeaderContext.HeaderInformation.WebNodeId, WebSessionId = ClientCustomHeaderContext.HeaderInformation.WebSessionId, WebUserId = ClientCustomHeaderContext.HeaderInformation.WebUserId }; var typedHeader = new MessageHeader<CustomHeader>(dataToSend); var untypedHeader = typedHeader.GetUntypedHeader("custom-header", "s"); request.Headers.Add(untypedHeader); return null; }
protected virtual void FillRecipientCustoms(ApiRecipient recipient, string[] data, List <CustomHeader> headerList, List <FieldConfiguration> fields) { for (int i = 0; i < data.Length; i++) { if (fields.Exists(f => f.Position == i && (f.IsBasic || f.IsAttachment)) || string.IsNullOrEmpty(data[i])) { continue; } CustomHeader customHeader = headerList.First(h => h.Position == i); if (customHeader != null) { recipient.Fields.Add(customHeader.HeaderName, data[i]); } } }
protected virtual List <CustomHeader> GetHeaderList(string[] headersArray) { var headerList = new List <CustomHeader>(); for (int i = 0; i < headersArray.Length; i++) { if (headerList.Exists(h => h.Position == i)) { continue; } var customHeader = new CustomHeader() { Position = i, HeaderName = headersArray[i] }; headerList.Add(customHeader); } return(headerList); }
//发送客户端自定义消息 public static bool SendCustom(CustomHeader iMSG, params object[] objects) { if (mGameSender == null) { return(false); } VarList args = VarList.GetVarList(); args.AddInt((int)iMSG); for (int i = 0; i < objects.Length; i++) { AddObjectArgs(ref args, ref objects[i]); } if (mGameSender.Custom(ref args)) { args.Collect(); return(true); } args.Collect(); return(false); }
public HttpResponseMessage Create(HttpRequestMessage request, CustomHeaderViewModel customHeaderVM) { return(CreateHttpResponse(request, () => { HttpResponseMessage response = null; if (!ModelState.IsValid) { response = request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState); } else { CustomHeader newCustomHeader = new CustomHeader(); newCustomHeader.UpdateCustomHeader(customHeaderVM); newCustomHeader.CreatedDate = DateTime.Now; newCustomHeader.CreatedBy = User.Identity.Name; var page = _customImageService.Add(newCustomHeader); _customImageService.Save(); response = request.CreateResponse(HttpStatusCode.Created, page); } return response; })); }
public CustomHeaderOperationProcessor(CustomHeader customHeader) { _header = customHeader; }
static ClientCustomHeaderContext() { HeaderInformation = new CustomHeader(); }
protected override List <CustomHeader> GetHeaderList(string[] headersArray) { var headerList = new List <CustomHeader>(); for (int i = 0; i < headersArray.Length; i++) { if (headerList.Exists(h => h.Position == i)) { continue; } string index = string.Empty; bool numeric = false; foreach (char c in headersArray[i]) { if (char.IsNumber(c)) { numeric = true; index += c; } else if (numeric) { break; } } var customHeader = new CustomHeader() { Position = i, HeaderName = headersArray[i], Index = string.IsNullOrEmpty(index) ? -1 : int.Parse(index), Name = string.IsNullOrEmpty(index) ? headersArray[i] : headersArray[i].Replace(index, string.Empty) }; headerList.Add(customHeader); for (int k = i + 1; k < headersArray.Length; k++) { if (headersArray[k].Contains(customHeader.Name)) { int intIndex; if (int.TryParse(headersArray[k].Replace(customHeader.Name, string.Empty), out intIndex)) { var newHeader = new CustomHeader() { Position = k, HeaderName = headersArray[k], Index = intIndex, Name = customHeader.Name }; headerList.Add(newHeader); } } } } foreach (string name in headerList.Select(h => h.Name).Distinct()) { int count = headerList.Where(h => h.Name == name).Count(); headerList.Where(h => h.Name == name).ToList().ForEach(h => h.NameCount = count); } return(headerList); }
public CustomHeader Add(CustomHeader customHeader) { return(_customHeaderRepository.Add(customHeader)); }
public void Update(CustomHeader customHeader) { _customHeaderRepository.Update(customHeader); }
public GitLabService(IHttpClientWrapper httpClientWrapper, IConfiguration configuration) { _httpClientWrapper = httpClientWrapper; _gitLabBaseUrl = configuration.GitLabUrl; _customHeader = new CustomHeader("Private-Token", configuration.GitLabPrivateToken); }