public string GetInfo(int indent, RolandMemory memory = null) { string pad = ""; for (var i = 0; i < indent; i++) { pad = pad + " "; } var desc = $"{GetTypeName()} {Name} ({Type})"; var data = GetDumpData(memory); var dataStr = ""; if (data != null) { dataStr = $"Data: {data}"; } var sizeFlag = "[O]"; if (IsAutoCalculatedSize) { sizeFlag = "[A]"; } return($"{pad}{desc}".PadRight(60) + $"{ValuePath.PadRight(40)}" + $"0x{StringUtils.Int32ToHexString(StartAddress)} - 0x{StringUtils.Int32ToHexString(EndAddress)} (Len {sizeFlag} 0x{Size:x8} FileAddr: 0x{FileAddress:x8} FileLen: 0x{FileSize:x4} {dataStr}"); }
public static List <ValuePath> ParsePropertyPaths(this ParseContext context) { List <ValuePath> names = new List <ValuePath>(); while (context.NotEnd()) { var name = ParseName(context); context.SkipWhiteSpace(); if (context.End()) { names.Add(new ValuePath { Name = name }); break; } else if (context.Current() == '.') { // a.b names.Add(new ValuePath { Name = name }); context.Index++; } else if (context.Current() == '(') { var args = IFilterFunction.ParseFunctionArgument(name, context); var nameInfo = new ValuePath { Name = name, IsFunction = true, FunctionArgs = args }; context.SkipWhiteSpace(); names.Add(nameInfo); if (context.NotEnd()) { if (context.Current() == '.') { context.Index++; } else { break; } } } else { names.Add(new ValuePath { Name = name }); break; } } return(names); }
private Path Path() { var attributePath = this.AttributePath(); var token = this.lexer.Token; if (token != null && token.Is(TokenType.OpenBracket)) { this.Match(TokenType.OpenBracket); var valueFilter = this.Expression(); this.Match(TokenType.CloseBracket); var valuePath = new ValuePath(attributePath, valueFilter); token = this.lexer.Token; if (token != null && token.Is(TokenType.DotOperator)) { this.Match(TokenType.DotOperator); string subAttribute = null; token = this.lexer.Token; if (token != null && token.Is(TokenType.Name)) { subAttribute = this.lexer.Token.Value; this.Match(TokenType.Name); } return(new Path(valuePath, subAttribute)); } return(new Path(valuePath)); } else if (token != null) { this.SyntaxError("Path"); } return(new Path(attributePath)); }
protected override void Execute(Context context) { HasValue.Set(context, false); StringValue.Set(context, null); BooleanValue.Set(context, default(bool)); DateTimeValue.Set(context, default(DateTime)); DecimalValue.Set(context, default(decimal)); MoneyValue.Set(context, default(Money)); DoubleValue.Set(context, default(double)); IntegerValue.Set(context, default(int)); var json = Json.Get(context); Dictionary <string, object> node; try { node = JsonConvert.DeserializeObject <Dictionary <string, object> >(json); } catch (Exception ex) { throw new InvalidWorkflowExecutionException($"Не удалось произвести разбор строки JSON. {ex.Message}", ex); } var names = ValuePath.Get(context).Split('.').ToArray(); foreach (var name in names.Take(names.Length - 1)) { if (!node.ContainsKey(name)) { return; } var jObj = node[name] as JObject; if (jObj == null) { return; } node = jObj.ToObject <Dictionary <string, object> >(); if (node == null) { return; } } var lastName = names.Last(); if (!node.ContainsKey(lastName)) { return; } var value = node[lastName]; if (value == null) { return; } HasValue.Set(context, true); var stringValue = value.ToString().Trim(); StringValue.Set(context, stringValue); var booleanValue = !(stringValue.Equals("false", StringComparison.OrdinalIgnoreCase) || stringValue.Equals("0") || stringValue.Equals("+0") || stringValue.Equals("-0")); BooleanValue.Set(context, booleanValue); DateTime dateTimeValue; if (DateTime.TryParse(stringValue, out dateTimeValue)) { DateTimeValue.Set(context, dateTimeValue); } decimal decimalValue; if (decimal.TryParse(stringValue, out decimalValue)) { DecimalValue.Set(context, decimalValue); MoneyValue.Set(context, new Money(decimalValue)); } double doubleValue; if (double.TryParse(stringValue, out doubleValue)) { DoubleValue.Set(context, doubleValue); } int integerValue; if (int.TryParse(stringValue, out integerValue)) { IntegerValue.Set(context, integerValue); } }
private void Draw() { if (ActualHeight > 0) { FreeLabel.FontSize = ActualHeight * 0.25; } var value = double.NaN; var lot = ParkingLot; if (lot != null && lot.TotalLots != 0) { value = ((double)lot.FreeLots) / ((double)lot.TotalLots); } if (double.IsNaN(value) || double.IsInfinity(value)) { ValueInvertedCircle.Visibility = ValuePath.Visibility = Visibility.Collapsed; FreeLabel.Text = "?"; if (lot != null) { PlayAnimation(); } return; } if (value < 0) { value = 0; } else if (value > 1) { value = 1; } ValueInvertedCircle.Visibility = ValuePath.Visibility = Visibility.Visible; FreeLabel.Text = Math.Round(value * 100) + "%"; ValuePath.SetValue(Path.DataProperty, null); var pg = new PathGeometry(); var fig = new PathFigure(); var height = ActualHeight; var width = ActualWidth; var radius = height / 2; var theta = (360 * value) - 90; var xC = radius; var yC = radius; if (value == 1) { theta += 1; } var finalPointX = xC + (radius * Math.Cos(theta * 0.0174)); var finalPointY = yC + (radius * Math.Sin(theta * 0.0174)); fig.StartPoint = new Point(radius, radius); var firstLine = new LineSegment { Point = new Point(radius, 0) }; fig.Segments.Add(firstLine); if (value > 0.25) { var firstQuart = new ArcSegment { Point = new Point(width, radius), SweepDirection = SweepDirection.Clockwise, Size = new Size(radius, radius) }; fig.Segments.Add(firstQuart); } if (value > 0.5) { var secondQuart = new ArcSegment { Point = new Point(radius, height), SweepDirection = SweepDirection.Clockwise, Size = new Size(radius, radius) }; fig.Segments.Add(secondQuart); } if (value > 0.75) { var thirdQuart = new ArcSegment { Point = new Point(0, radius), SweepDirection = SweepDirection.Clockwise, Size = new Size(radius, radius) }; fig.Segments.Add(thirdQuart); } var finalQuart = new ArcSegment { Point = new Point(finalPointX, finalPointY), SweepDirection = SweepDirection.Clockwise, Size = new Size(radius, radius) }; fig.Segments.Add(finalQuart); var lastLine = new LineSegment { Point = new Point(radius, radius) }; fig.Segments.Add(lastLine); pg.Figures.Add(fig); ValuePath.SetValue(Path.DataProperty, pg); PlayAnimation(); }