示例#1
0
 private void AddBoolean(bool value)
 {
     if (!IsDisposed)
     {
         CurrentNode.Add(value);
     }
 }
示例#2
0
 private void AddNumber(double value)
 {
     if (!IsDisposed)
     {
         CurrentNode.Add(value);
     }
 }
示例#3
0
 public void SerializeVector3(string name, Vector3 value)
 {
     CurrentNode.Add(name, new JSONClass()
     {
         AsVector3 = value
     });
 }
示例#4
0
 public void SerializeQuaternion(string name, Quaternion value)
 {
     CurrentNode.Add(name, new JSONClass()
     {
         AsQuaternion = value
     });
 }
示例#5
0
 private void AddObject(IDictionary value)
 {
     if (!IsDisposed)
     {
         CurrentNode.Add(value ?? new Dictionary <string, object>());
     }
 }
示例#6
0
        private void ContextMenuCommand_Execute(object sender, EventArgs args)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            var command = (OleMenuCommand)sender;
            var isRoot  = command.MatchedCommandId == 0;
            var index   = isRoot ? 0 : command.MatchedCommandId - CommandId_ContextMenuStart;

            var attribute = CurrentNode.Attributes[index];

            if (attribute.IsChecked)
            {
                TryApplyChanges(CurrentNode.Remove(attribute));
            }
            else
            {
                TryApplyChanges(CurrentNode.Add(attribute, out var textSpan));
                if (textSpan.HasValue)
#pragma warning disable VSTHRD001 // Avoid legacy thread switching APIs
                {
                    Dispatcher.CurrentDispatcher.BeginInvoke(new Action(() =>
                    {
                        NavigateToSource(textSpan.Value);
                        EnsureDocumentActivated();
                    }));
                }
#pragma warning restore VSTHRD001 // Avoid legacy thread switching APIs
            }

            NavigatableMarker = CurrentNode.CreateMarker(navigationSuggested: false);
        }
示例#7
0
 private void AddString(string value)
 {
     if (!IsDisposed)
     {
         CurrentNode.Add(value ?? String.Empty);
     }
 }
示例#8
0
        public void SerializeColor(string name, Color value)
        {
            var node = new JSONClass();

            node.Add("r", new JSONData(value.r));
            node.Add("g", new JSONData(value.g));
            node.Add("b", new JSONData(value.b));
            node.Add("a", new JSONData(value.a));
            CurrentNode.Add(name, node.AsObject);
        }
示例#9
0
        private void AddArray <T>(IEnumerable <T> value, Func <T, object> selector)
        {
            if (IsDisposed)
            {
                return;
            }

            var o = value.Select(selector).ToArray();

            CurrentNode.Add(o);
        }
示例#10
0
 /// <summary>
 /// Checks if the last statement being entered must leads to the start of a sentence.
 /// </summary>
 public virtual void CheckStartSentenceLastStatement()
 {
     if (LastEnteredNode != null)
     {
         Node parent = LastEnteredNode.Parent;
         if (parent is Paragraph || parent is ProcedureDivision)
         {   //JCM Hack: So in this case the statement must be given as parent a Sentence Node.
             //This hack is perform because using the Enter/Exit mechanism to create a Syntax Tree
             //Is not appropriate with LALR(1) grammar, because there is not start token that can telle
             //The beginning of  list of statement that belongs to a sentence.
             //So we check if the statement is part of a paragraph or a procedure division.
             parent.Remove(LastEnteredNode);
             //Start a sentence
             StartSentence();
             CurrentNode.Add(LastEnteredNode);
         }
     }
 }
示例#11
0
        public void SerializeObjectArray(string name, IEnumerable <object> items)
        {
            var array = new JSONArray();

            if (name == null)
            {
                CurrentNode.Add(array);
            }
            else
            {
                CurrentNode.Add(name, array);
            }
            Push(name, array);
            foreach (var item in items)
            {
                SerializeObject(null, item);
            }
            Pop();
        }
示例#12
0
 /// <summary>Add a node as the Head's first child.</summary>
 /// <param name="child">Node to add</param>
 /// <param name="context">Context child was created from</param>
 public void Enter(Node child, ParserRuleContext context)
 {
     CurrentNode.Add(child);
     Branch.Push(new Tuple <Node, ParserRuleContext>(child, context));
 }
示例#13
0
 public void SerializeBool(string name, bool value)
 {
     CurrentNode.Add(name, new JSONData(value));
 }
示例#14
0
 public void SerializeInt(string name, int value)
 {
     CurrentNode.Add(name, new JSONData(value));
 }
示例#15
0
 public void SerializeString(string name, string value)
 {
     CurrentNode.Add(name, new JSONData(value));
 }
示例#16
0
 public void SerializeDouble(string name, double value)
 {
     CurrentNode.Add(name, new JSONData(value));
 }
示例#17
0
 public void SerializeFloat(string name, float value)
 {
     CurrentNode.Add(name, new JSONData(value));
 }
示例#18
0
        public void SerializeObject(string name, object value)
        {
            if (value is int)
            {
                SerializeInt(name, (int)value);
                return;
            }
            if (value is string)
            {
                SerializeString(name, (string)value);
                return;
            }
            if (value is bool)
            {
                SerializeBool(name, (bool)value);
                return;
            }
            if (value is Vector2)
            {
                SerializeVector2(name, (Vector2)value);
                return;
            }
            if (value is Vector3)
            {
                SerializeVector3(name, (Vector3)value);
                return;
            }
            if (value is Quaternion)
            {
                SerializeQuaternion(name, (Quaternion)value);
                return;
            }
            if (value is double)
            {
                SerializeDouble(name, (double)value);
                return;
            }
            var cls = new JSONClass();

            if (name == null)
            {
                CurrentNode.Add(cls);
            }
            else
            {
                CurrentNode.Add(name, cls);
            }
            Push(name, cls);

            var serializable = value as IUFSerializable;

            if (serializable != null)
            {
                SerializeString("Identifier", serializable.Identifier);
                if (!UseReferences || !ReferenceObjects.ContainsKey(serializable.Identifier))
                {
                    SerializeString("CLRType", TypeResolver.SetType(value.GetType()));

                    if (UseReferences)
                    {
                        ReferenceObjects.Add(serializable.Identifier, serializable);
                    }

                    serializable.Write(this);
                }
            }
            Pop();
        }
示例#19
0
 /// <summary>Add a node as the Head's first child.</summary>
 /// <param name="child">Node to add</param>
 /// <param name="context">Context child was created from</param>
 public void Enter(Node child, TCtx context)
 {
     CurrentNode.Add(child);
     Branch.Push(new Tuple <Node, TCtx>(child, context));
 }