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));
                            }
                        }
示例#2
0
        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));
            }
        }
示例#3
0
 public override bool Walk(WithItem node) => Save(node.AsIndex, base.Walk(node), "as");
示例#4
0
 public virtual void PostWalk(WithItem node)
 {
 }
示例#5
0
 // WithItem
 public virtual bool Walk(WithItem node)
 {
     return(true);
 }
示例#6
0
 // WithItem
 public override bool Walk(WithItem node)
 {
     return(Location >= node.StartIndex && Location <= node.EndIndex);
 }
示例#7
0
 public override void PostWalk(WithItem node)
 {
 }
示例#8
0
 // WithItem
 public override bool Walk(WithItem node)
 {
     return(false);
 }