コード例 #1
0
        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
ファイル: ExpressionFinder.cs プロジェクト: setindustry/PTVS
 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);
 }