/// <summary> /// Add header item /// </summary> /// <param name="name">header name</param> /// <param name="value">value</param> /// <returns>this</returns> public RestClient AddHeader(string name, string value) { Verify.IsNotEmpty(nameof(name), name); Verify.IsNotEmpty(nameof(value), value); HeaderItems.Add(name, value); return(this); }
public void LoadData() { if (_isConfigured) { return; } if (!File.Exists(_sourceFilePath)) { return; } var document = new XmlDocument(); document.Load(_sourceFilePath); var configNode = document.SelectSingleNode("//Settings"); if (configNode == null) { return; } foreach (var node in configNode.SelectNodes("./SolutionHeader")?.OfType <XmlNode>().ToArray() ?? new XmlNode[] { }) { HeaderItems.Add(ListDataItem.FromXml(node)); } foreach (var node in configNode.SelectNodes("./SolutionCombo1")?.OfType <XmlNode>().ToArray() ?? new XmlNode[] { }) { Combo1Items.Add(ListDataItem.FromXml(node)); } foreach (var node in configNode.SelectNodes("./Toggles/Toggle")?.OfType <XmlNode>().ToArray() ?? new XmlNode[] { }) { var id = node.Attributes?.OfType <XmlAttribute>() .FirstOrDefault(a => String.Equals(a.Name, "Id", StringComparison.OrdinalIgnoreCase))?.Value?.ToLower(); switch (id) { case PositioningId: Positioning = PositioningInfo.FromXml(node); break; case ResearchId: Research = ResearchInfo.FromXml(node); break; case StyleId: Style = StyleInfo.FromXml(node, _imagesFolder, ProductId); break; } } HeaderConfiguration = TextEditorConfiguration.FromXml(configNode, "SolutionHeader"); Combo1Configuration = TextEditorConfiguration.FromXml(configNode, "SolutionCombo1"); _isConfigured = true; }
private void AddNewItem() { HeaderItems.Add(new RFQHeaderItem(RFQItems)); HeaderItemsSelectedItem = HeaderItems[HeaderItems.Count - 1]; if (SubHeaderSerial != null) { HeaderItemsSelectedItem.ParentID = SubHeaderSerial; } }
private void ReadData() { String[] Lines = File.ReadAllLines(PathIn).Where(x => !string.IsNullOrEmpty(x)).ToArray(); if (Lines.Length < 15) { throw new Exception("File corrupted or invalid format."); } int HeaderSize = Int32.Parse(Lines[0].Split(',')[1]); // Header size must always be on the first line! if (HeaderSize < 15) { throw new Exception("File corrupted or invalid format."); } for (int i = 0; i < HeaderSize; i++) { HeaderItems.Add(Regex.Replace(Lines[i].Split(',')[0], @"\s+", "").Trim('"').ToLower(), Lines[i].Replace(Lines[i].Split(',')[0].Trim(' ').Trim('"'), "").Replace('"', ' ').Replace(" ", "").ToLower().Split(',')); } int BlockSize = Int32.Parse(GetHeaderItem("blocksize")[1]); if (Lines.Length < BlockSize) { throw new Exception("File corrupted or invalid format."); } String[] Columns = { "Time", "Current", "Voltage", "WirePos", "PowerIn", "PowerCol", "PowerExp", "Eexp_Pt", "Eexp_sumtrap", "Eexp_sum", "Eexp_trap" }; String[] Units = { GetHeaderItem("hunit")[1], "A", "V", "mm", "W", "W", "W", "J", "J", "J", "J" }; String[] Dates = new string[Columns.Length]; String[] Times = new string[Columns.Length]; HOffset = Helper.ParseDouble(GetHeaderItem("hoffset")[1]); HRes = Helper.ParseDouble(GetHeaderItem("hresolution")[1]); String tempPath; int fileNo = 0; String[] TempLines = new string[BlockSize]; for (int i = 0; i < Lines.Length - HeaderSize; i++) { if (i % BlockSize == 0) { fileNo++; tempPath = (isLi) ? PathOut + fName + "_" + fileNo + ".txt" : PathOut + fName + ".txt"; String[] Names = new string[Columns.Length]; for (int j = 0; j < Names.Length; j++) { Names[j] = fName + "_" + fileNo; Dates[j] = isLi ? GetHeaderItem("date" + fileNo)[1] : GetHeaderItem("date")[1]; Times[j] = isLi ? GetHeaderItem("time" + fileNo)[1] : GetHeaderItem("time")[1]; } String[] Temp = Lines[(i + HeaderSize)..(i + BlockSize + HeaderSize)];
private void GenerateHeaderItems() { foreach (OmfSegment.NameValueNote nvn in mOmfSeg.RawValues) { string value; if (nvn.Value is int) { int byteWidth = nvn.Width; if (byteWidth > 3) { byteWidth = 3; } value = mFormatter.FormatHexValue((int)nvn.Value, byteWidth * 2); } else { value = nvn.Value.ToString(); } HeaderItems.Add(new HeaderItem(nvn.Name, value, nvn.Note)); } }
//overriding the default empty constructor as we want to create default header items in the header upon initialization public Header() { //Applicant's name item HeaderItem applicant = new HeaderItem("Applicant:", "Query", new List <string> { "<Applicant Name>" }); HeaderItem job = new HeaderItem("Job applied:", "Query", new List <string> { "<Applied Position>" }); HeaderItem reviewer = new HeaderItem("Reviewer:", "Query", new List <string> { "<Reviewer Name>" }); HeaderItem applicationType = new HeaderItem("Application Type:", "Query", new List <string> { "<Application Type>" }); this.HeaderItems = new List <HeaderItem>(); HeaderItems.Add(applicant); HeaderItems.Add(job); HeaderItems.Add(reviewer); HeaderItems.Add(applicationType); }