public static Jxx Create(ILineInfo line) { var command = line.Command.ToUpper(); if (line.NumberOfArguments != 1) { throw new Exceptions.ArgumentNumberException(command, line.NumberOfArguments); } var cmd = new Jxx() { LineNumber = line.LineNumber, CommandName = command }; switch (line.TypeOfArgument(1)) { case Lexer.ArgumentType.Name: cmd.LabelName = line.Argument(1).ToLower(); cmd.Capture = line.LastCapture; cmd.Assemble = cmd.assemble; break; } if (cmd.Assemble == null) { throw new Exceptions.ArgumentException(command, line.TypeOfArgument(1)); } return(cmd); }
public ValidationError(string message, ValidationCategory category, ILineInfo lineInfo = null, ErrorLevel errorLevel = ErrorLevel.ERROR) { Message = EnsureArg.IsNotNullOrWhiteSpace(message, nameof(message)); Level = errorLevel; Category = category; LineInfo = lineInfo; }
private TemplateExpression CreateExpression(string value, ILineInfo lineAwareJsonObject) { if (!string.IsNullOrWhiteSpace(value)) { if (lineAwareJsonObject == null) { return(new TemplateExpression(value, TemplateExpressionLanguage.JsonPath)); } var templateExpression = new TemplateExpression(value, TemplateExpressionLanguage.JsonPath) { LineNumber = lineAwareJsonObject.LineNumber, LinePosition = lineAwareJsonObject.LinePosition, }; templateExpression.LineInfoForProperties[nameof(TemplateExpression.Value)] = new LineInfo() { LineNumber = lineAwareJsonObject.LineNumber, LinePosition = lineAwareJsonObject.LinePosition, }; return(templateExpression); } return(null); }
internal DataFormatException(ILineInfo info, string text, params object[] args) : base(string.Format("({1}, {2}): {0}", string.Format(text, args), info.LineNumber, info.LinePosition)) { // init this.LineNumber = info.LineNumber; this.LinePosition = info.LinePosition; }
public static INT Create(ILineInfo line) { if (line.NumberOfArguments != 1) { throw new Exceptions.ArgumentNumberException("INT", line.NumberOfArguments); } var cmd = new INT() { LineNumber = line.LineNumber }; switch (line.TypeOfArgument(1)) { case Lexer.ArgumentType.Number: cmd.Argument1 = new Number((Int16)line.ArgumentAsNumber(1)); if (cmd.Argument1.IsWord) { throw new Exceptions.ArgumentSizeException("INT"); } cmd.Assemble = cmd.assemble; break; } if (cmd.Assemble == null) { throw new Exceptions.ArgumentException("INT", line.TypeOfArgument(1)); } return(cmd); }
public static RET Create(ILineInfo line) { if (line.NumberOfArguments > 1) { throw new Exceptions.ArgumentNumberException("RET", line.NumberOfArguments); } var cmd = new RET() { LineNumber = line.LineNumber }; switch (line.TypeOfArgument(1)) { case Lexer.ArgumentType.Number: cmd.Argument1 = new Number((Int16)line.ArgumentAsNumber(1)); cmd.Assemble = cmd.assemble; break; case Lexer.ArgumentType.None: cmd.Assemble = cmd.assemble; break; } if (cmd.Assemble == null) { throw new Exceptions.ArgumentException("RET", line.TypeOfArgument(1)); } return(cmd); }
private void SaveTextInCurrentLine(ILineInfo linfo, string newLineText) { if (newLineText != "" && linfo.Line != newLineText) { linfo.Line = newLineText; } }
public static DEC Create(ILineInfo line) { if (line.NumberOfArguments != 1) { throw new Exceptions.ArgumentNumberException("DEC", line.NumberOfArguments); } var cmd = new DEC() { LineNumber = line.LineNumber }; switch (line.TypeOfArgument(1)) { case Lexer.ArgumentType.Register: cmd.Argument1 = new Register(line.Argument(1)); cmd.Assemble = cmd.assembleR; break; case Lexer.ArgumentType.Name: case Lexer.ArgumentType.Indirect: cmd.Argument1 = new MemoryIndirect( line.NameInArgument(1), line.RegistersInArgument(1), line.NumbersInArgument(1), line.LastCapture ); cmd.Assemble = cmd.FactoryAssemble(0xfe); break; } if (cmd.Assemble == null) { throw new Exceptions.ArgumentException("DEC", line.TypeOfArgument(1)); } return(cmd); }
/// <summary> /// Extracts begin and end time values from text and assign them to properties of ILineInfo item /// </summary> /// <param fileName="text">Text to extract values from</param> /// <param fileName="linfo">Item to which properties values are assigned</param> /// <returns>LineNumber of last char in timeinfo sequence</returns> public void AssignTimeProperies(string text, ref ILineInfo linfo) { text = text.Trim(); linfo.Begin = text.Substring(1, text.IndexOf('}') - 1).Trim(); int i; for (i = 1; i < text.Length; i++) { if (text[i] == '{') { break; } } int start = i + 1; for (; i < text.Length; i++) { if (text[i] == '}') { break; } } int end = i; linfo.End = text.Substring(start, end - start).Trim(); }
public void SetTimeRelatedLabels(ILineInfo lineInfo, string text) { int chars; if (!String.IsNullOrEmpty(text)) { chars = text.Count(x => (x != ' ' && x != '|')); } else { chars = lineInfo.Line.Count(x => (x != ' ' && x != '|')); } double secs = (lineInfo.TimeToSeconds(lineInfo.End) - lineInfo.TimeToSeconds(lineInfo.Begin)); lbLineTimeValue.Text = String.Format("{0:0.000}s", secs); double cpsRatio = Math.Round(chars / secs, 3); if (cpsRatio > 20) { lbCharsPerSecValue.BackColor = Color.IndianRed; lbCharsPerSecValue.BackColor = Color.Red; } else { lbCharsPerSecValue.BackColor = SystemColors.Control; lbCharsPerSecValue.ForeColor = Color.Black; } lbCharsPerSecValue.Text = String.Format("{0:0.00}", cpsRatio); }
public static CALL Create(ILineInfo line) { if (line.NumberOfArguments != 1) { throw new Exceptions.ArgumentNumberException("CALL", line.NumberOfArguments); } var cmd = new CALL() { LineNumber = line.LineNumber }; switch (line.TypeOfArgument(1)) { case Lexer.ArgumentType.Name: cmd.ProcedureName = line.Argument(1).ToLower(); cmd.Capture = line.LastCapture; cmd.Assemble = cmd.assemble; break; } if (cmd.Assemble == null) { throw new Exceptions.ArgumentException("CALL", line.TypeOfArgument(1)); } return(cmd); }
public static Command Create(string command, ILineInfo line) { if (!commands.ContainsKey(command)) { throw new Exceptions.NotACommandException(command); } return(commands[command](line)); }
private void SaveFile(FileHelper helper, ILineInfo linfo, string path, bool saveCurrentLine) { if (saveCurrentLine) { SaveTextInCurrentLine(linfo, tbLineText.Text.Trim()); } helper.UpdateLineList(linfo); helper.SaveFile(path); }
/// <inheritdoc /> public bool Equals(ILineInfo other) { if (other == null) { return(false); } return(this.LineNumber == other.GetLineNumber() && this.ColumnNumber == other.GetColumnNumber() && this.TokenLength == other.GetTokenLength()); }
public static RET CreateEmpty(ILineInfo line) { var cmd = new RET() { LineNumber = line.LineNumber }; cmd.Assemble = cmd.assembleEmpty; return(cmd); }
/// <summary> /// Puts changed ILineInfo item into list at proper index, and save temporary file /// </summary> /// <param fileName="li">ILineInfo to update</param> public void UpdateLineList(ILineInfo li) { if (li == null) { throw new ArgumentNullException("List item cannot be null."); } int index = navigator.Lines.FindIndex(v => v.LineNumber == li.LineNumber); navigator.Lines[index] = li; SaveFile(tempFilePath); }
public static Definition Create(ILineInfo line) { var def = new Definition() { LineNumber = line.LineNumber }; def.Name = line.GetName(); switch (line.Definition) { case "db": def.Type = DefinitionType.Byte; break; case "dw": def.Type = DefinitionType.Word; break; } switch (line.TypeOfValue()) { case Lexer.ValueType.Number: var arg = new Arguments.Number((Int16)line.ValueAsNumber()); if (arg.IsWord && def.Type == DefinitionType.Byte) { throw new Exceptions.ArgumentSizeException(line.Definition); } def.Value = arg.GetValue(def.Type == DefinitionType.Word); break; case Lexer.ValueType.String: var val = line.ValueAsString(); while (val.Length < (int)def.Type + 1) { val += '\0'; } def.Value = line.ValueAsString().Select(c => (byte)c).ToArray(); break; case Lexer.ValueType.None: switch (def.Type) { case DefinitionType.Byte: def.Value = new byte[] { 0x00 }; break; case DefinitionType.Word: def.Value = new byte[] { 0x00, 0x00 }; break; } break; } line.GetName(); // can be RedefinedException later, point to variable name return(def); }
private void CheckLineInfo(ILineInfo lineInfo, int expectedLine, int expectedPos = -1) { Assert.NotNull(lineInfo); Assert.True(lineInfo.HasLineInfo()); Assert.Equal(expectedLine, lineInfo.LineNumber); if (expectedPos > -1) { Assert.Equal(expectedPos, lineInfo.LinePosition); } }
public override void OnApplyTemplate() { base.OnApplyTemplate(); this.dataTableControl.ApplyTemplate(); this.gridControl = this.dataTableControl.Template.FindName("PART_DataGridControl", this.dataTableControl) as ModernDataGridControl; if (this.gridControl != null) { this.gridControl.ItemsSourceChangeCompleted += GridControl_ItemsSourceChangeCompleted; this.lineInfo = new GridControlLineInfo(this.gridControl); } }
protected virtual IList <SOPackageEngine.PackSet> CalculatePackages(Document doc, string carrierID) { Dictionary <string, SOPackageEngine.ItemStats> stats = new Dictionary <string, SOPackageEngine.ItemStats>(); SOPackageEngine.OrderInfo orderInfo = new SOPackageEngine.OrderInfo(carrierID); foreach (Tuple <ILineInfo, InventoryItem> res in GetLines(doc)) { ILineInfo line = res.Item1; InventoryItem item = res.Item2; if (item.PackageOption == INPackageOption.Manual) { continue; } orderInfo.AddLine(item, line.BaseQty); int inventoryID = item.PackSeparately == true ? item.InventoryID.Value : SOPackageEngine.ItemStats.Mixed; string key = string.Format("{0}.{1}.{2}.{3}", line.SiteID, inventoryID, item.PackageOption, line.Operation); SOPackageEngine.ItemStats stat; if (stats.ContainsKey(key)) { stat = stats[key]; stat.BaseQty += line.BaseQty.GetValueOrDefault(); stat.BaseWeight += line.ExtWeight.GetValueOrDefault(); stat.DeclaredValue += line.CuryLineAmt.GetValueOrDefault(); stat.AddLine(item, line.BaseQty); } else { stat = new SOPackageEngine.ItemStats(); stat.SiteID = line.SiteID; stat.InventoryID = inventoryID; stat.Operation = line.Operation; stat.PackOption = item.PackageOption; stat.BaseQty += line.BaseQty.GetValueOrDefault(); stat.BaseWeight += line.ExtWeight.GetValueOrDefault(); stat.DeclaredValue += line.CuryLineAmt.GetValueOrDefault(); stat.AddLine(item, line.BaseQty); stats.Add(key, stat); } } orderInfo.Stats.AddRange(stats.Values); SOPackageEngine engine = CreatePackageEngine(); return(engine.Pack(orderInfo)); }
internal ExpressionParserException(string message, Exception innerException, ILineInfo lineInfo) : base(message, innerException) { if (lineInfo == null) { return; } this.LineNumber = lineInfo.GetLineNumber(); this.ColumnNumber = lineInfo.GetColumnNumber(); this.TokenLength = lineInfo.GetTokenLength(); }
internal ExpressionParserException(string message, ILineInfo lineInfo) : base(message) { if (lineInfo == null) { return; } this.LineNumber = lineInfo.LineNumber; this.ColumnNumber = lineInfo.ColumnNumber; this.TokenLength = lineInfo.TokenLength; }
public override void OnApplyTemplate() { base.OnApplyTemplate(); if (this.gridControl != null) { this.lineInfo = new GridControlLineInfo(this.gridControl); this.gridControl.CurrentChanged += (s, e) => this.RefreshLineInfo(); } this.FindingText.ApplyTemplate(); this.editableTextBox = this.FindingText.Template.FindName("PART_EditableTextBox", this.FindingText) as TextBox; }
public JmesPathExpressionEvaluator(JmesPath jmesPath, string expression, ILineInfo lineInfo) { EnsureArg.IsNotNull(jmesPath, nameof(jmesPath)); EnsureArg.IsNotNullOrWhiteSpace(expression, nameof(expression)); _lineInfo = EnsureArg.IsNotNull(lineInfo, nameof(lineInfo)); try { _jmespathExpression = jmesPath.Parse(expression); } catch (Exception e) { throw new TemplateExpressionException($"The following JmesPath expression could not be parsed: {expression}. Cause: {e.Message}", e, _lineInfo); } }
public override void OnApplyTemplate() { base.OnApplyTemplate(); var isNumberFormatting = (bool)(this.configService[typeof(NumberCellFormattingMenuItem), nameof(NumberCellFormattingMenuItem.IsNumberFormatting)] ?? false); this.dataTableControl.ApplyTemplate(); this.gridControl = this.dataTableControl.Template.FindName("PART_DataGridControl", this.dataTableControl) as ModernDataGridControl; this.gridControl.IsNumberFormatting = isNumberFormatting; if (this.gridControl != null) { this.gridControl.ItemsSourceChangeCompleted += GridControl_ItemsSourceChangeCompleted; this.lineInfo = new GridControlLineInfo(this.gridControl); } }
public ILineInfo getLineInfo() { ILineInfo lineInfo = null; try { IDataBase db = new DatabaseODBC(); lineInfo = LineInfoModel.Builder.Build(db, _custumerId); } catch (Exception ex) { throw new Exception(ex.Message); } return(lineInfo); }
private void LoadLine(out ILineInfo lineInfo, Func <int, ILineInfo> func, int funcParam) { lineInfo = null; try { lineInfo = func(funcParam); Settings.Default.LineNumber = lineInfo.LineNumber; Settings.Default.Save(); } catch (ArgumentOutOfRangeException ex) { MessageBox.Show("Nie udało się wczytać linii.\r\n" + ex.Message); } UpdateGUI(); tbLineText.Focus(); }
private void AddExpression( IDictionary <string, IExpressionEvaluator> cache, TemplateExpression expression, string expressionName, ILineInfo templateLineInfo, bool isRequired = false) { if (expression != null) { cache[expression.GetId()] = _expressionEvaluatorFactory.Create(expression); _logger.LogTrace($"Using {expression.Value} for expression [{expressionName}]"); } else if (isRequired) { throw new TemplateExpressionException($"Unable to create the template; the expression for [{expressionName}] is missing", templateLineInfo); } }
public static PUSH Create(ILineInfo line) { if (line.NumberOfArguments != 1) { throw new Exceptions.ArgumentNumberException("PUSH", line.NumberOfArguments); } var cmd = new PUSH() { LineNumber = line.LineNumber }; bool isMem = false; switch (line.TypeOfArgument(1)) { case Lexer.ArgumentType.Register: cmd.Argument1 = new Register(line.Argument(1)); cmd.Assemble = cmd.assembleR; break; case Lexer.ArgumentType.Number: cmd.Argument1 = new Number((Int16)line.ArgumentAsNumber(1)); cmd.Assemble = cmd.assembleI; break; case Lexer.ArgumentType.Name: case Lexer.ArgumentType.Indirect: cmd.Argument1 = new MemoryIndirect( line.NameInArgument(1), line.RegistersInArgument(1), line.NumbersInArgument(1), line.LastCapture ); isMem = true; cmd.Assemble = cmd.assembleM; break; } if (cmd.Assemble == null) { throw new Exceptions.ArgumentException("PUSH", line.TypeOfArgument(1)); } if (!isMem) { cmd.CheckArgumentSize(); } return(cmd); }
/// <summary> /// Extract fields from record and assign values to the object /// </summary> /// <param name="record">Object to assign to</param> /// <param name="line">Line of data</param> /// <param name="values">Array of values extracted</param> /// <returns>true if we processed the line and updated object</returns> public bool StringToRecord(object record, ILineInfo line, object[] values) { if (MustIgnoreLine(line.LineString)) { return(false); } for (int i = 0; i < RecordInfo.FieldCount; i++) { values[i] = RecordInfo.Fields[i].ExtractFieldValue(line); } try { // Assign all values via dynamic method that AssignHandler(record, values); return(true); } catch (InvalidCastException ex) { // Occurs when a custom converter returns an invalid value for the field. for (int i = 0; i < RecordInfo.FieldCount; i++) { if (values[i] != null && !RecordInfo.Fields[i].FieldTypeInternal.IsInstanceOfType(values[i])) { throw new ConvertException(null, RecordInfo.Fields[i].FieldTypeInternal, RecordInfo.Fields[i].FieldInfo.Name, line.Number, -1, Messages.Errors .WrongConverter .FieldName(RecordInfo.Fields[i].FieldInfo.Name) .ConverterReturnedType(values[i].GetType().Name) .FieldType(RecordInfo.Fields[i].FieldInfo.FieldType.Name) .Text, ex); } } throw; } }
internal SqlParseException(string message, ILineInfo lineInfo) : this(message, lineInfo.Line, lineInfo.Column) { }