private void AddBoolean(bool value) { if (!IsDisposed) { CurrentNode.Add(value); } }
private void AddNumber(double value) { if (!IsDisposed) { CurrentNode.Add(value); } }
public void SerializeVector3(string name, Vector3 value) { CurrentNode.Add(name, new JSONClass() { AsVector3 = value }); }
public void SerializeQuaternion(string name, Quaternion value) { CurrentNode.Add(name, new JSONClass() { AsQuaternion = value }); }
private void AddObject(IDictionary value) { if (!IsDisposed) { CurrentNode.Add(value ?? new Dictionary <string, object>()); } }
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); }
private void AddString(string value) { if (!IsDisposed) { CurrentNode.Add(value ?? String.Empty); } }
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); }
private void AddArray <T>(IEnumerable <T> value, Func <T, object> selector) { if (IsDisposed) { return; } var o = value.Select(selector).ToArray(); CurrentNode.Add(o); }
/// <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); } } }
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(); }
/// <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)); }
public void SerializeBool(string name, bool value) { CurrentNode.Add(name, new JSONData(value)); }
public void SerializeInt(string name, int value) { CurrentNode.Add(name, new JSONData(value)); }
public void SerializeString(string name, string value) { CurrentNode.Add(name, new JSONData(value)); }
public void SerializeDouble(string name, double value) { CurrentNode.Add(name, new JSONData(value)); }
public void SerializeFloat(string name, float value) { CurrentNode.Add(name, new JSONData(value)); }
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(); }
/// <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)); }