private static ChatMessage Deserialize(JObject json) { ChatMessage ChatComponent = new ChatMessage(); if (json != null && json.Count == 0) { return(null); } foreach (JProperty Property in json.Children()) { switch (Property.Name) { case "bold": ChatComponent.Bold = (bool)Property.Value; continue; case "italic": ChatComponent.Italic = (bool)Property.Value; continue; case "underlined": ChatComponent.Underline = (bool)Property.Value; continue; case "strikethrough": ChatComponent.Strikethrough = (bool)Property.Value; continue; case "obfuscated": ChatComponent.Obfuscated = (bool)Property.Value; continue; case "text": ChatComponent.Text = Property.Value.ToString(); continue; case "color": ChatComponent.Color = Property.Value.ToString(); continue; case "insertion": ChatComponent.Insertion = Property.Value.ToString(); continue; case "translate": ChatComponent.Translate = Property.Value.ToString(); continue; } if (Property.Name == "with") { ChatComponent.With = new List <object>(); foreach (var WithItem in Property.Value) { if (WithItem.Type == JTokenType.String) { ChatComponent.With.Add(WithItem.Value <string>()); } else if (WithItem.Type == JTokenType.Object && WithItem is JObject jo && jo.Count > 0) { if (jo.Count == 1 && jo.First is JProperty jp && jp.Name == "translate") { ChatComponent.With.Add(new SimpleTranslateComponent(jp.Value.ToString())); } else { ChatComponent.With.Add(Deserialize(jo)); } }
private CodeStatement Translate(WithItem wi) { CodeExpression e1 = wi.t.Accept(xlat); CodeExpression e2 = wi.e?.Accept(xlat); if (e2 != null) { return(new CodeAssignStatement(e2, e1)); } else { return(new CodeExpressionStatement(e1)); } }
public override bool Walk(WithItem node) => Save(node.AsIndex, base.Walk(node), "as");
public virtual void PostWalk(WithItem node) { }
// WithItem public virtual bool Walk(WithItem node) { return(true); }
// WithItem public override bool Walk(WithItem node) { return(Location >= node.StartIndex && Location <= node.EndIndex); }
public override void PostWalk(WithItem node) { }
// WithItem public override bool Walk(WithItem node) { return(false); }