public void Serialize <T>(IWriteVisitor visitor, T graph) { if (visitor == null) { throw new ArgumentNullException(nameof(visitor)); } if (graph == null) { throw new ArgumentNullException(nameof(graph)); } var traveller = _rootTravellers.GetOrAdd <T>(out var level); if (level == LevelType.Value) { var valueVisitor = ValueVisitor.Create <T>(); valueVisitor.VisitValue(visitor, VisitArgs.CreateRoot(level), graph); } else { var rootArgs = VisitArgs.CreateRoot(level); visitor.Visit(graph, rootArgs); traveller.Travel(visitor, graph); visitor.Leave(graph, rootArgs); } }
private IValue InternalVisitExpression(SyntaxNode n) { var vv = new ValueVisitor(state); var tmp = vv.Visit(n); return(tmp); }
public UIElement ProcessFormObject(UIElement form) { Value value = Processor.Evaluate(this.conditionalNode.Condition); Widget stackPanelWidget = new StackPanelWidget(); UIElement customStackPanel = stackPanelWidget.CreateUIControl(ValueVisitor.Visit((dynamic)value)); return(AddChildren(Processor.ProcessBody(conditionalNode.GetBody(), customStackPanel), form)); }
public void ForEachValue <TValue>(ValueVisitor <TValue> visitor) where TValue : Value { foreach (Value value in values) { if (value is TValue matchedValue) { visitor(matchedValue); } } }
void VisitAddOrDeleteMethodCall(MethodCallExpression node, ChildChangeType changeType) { var instance = node.Object as MemberExpression ?? throw new NotSupportedException($"{changeType.ToString()} method is only supported when called on an object child property, eg. object.ChildProperty.{changeType.ToString()}(...)."); var value = ValueVisitor.ExtractValue(node.Arguments[0]) as IMetadataObject ?? throw new NotSupportedException("The parameter provided for the Add method call could not be extracted as a non-nullable instance."); var changes = GetChildChangeList(instance.Member.Name); changes.Add(new ChildChange(value, changeType)); }
public UIElement ProcessFormObject(UIElement form) { Widget widget = new TypeToWidgetVisitor(questionNode.Identifier.Name).VisitValue(questionNode.RetrieveType()); Widget labelWidget = new LabelVisitor().VisitValue(questionNode.Label); Values.Value widgetValue = Processor.GetObjectValue(questionNode.Identifier); widgetValue = ProcessComputation(widgetValue); AddChildren(labelWidget.CreateUIControl(questionNode.Label.Value), form); AddChildren(widget.CreateUIControl(ValueVisitor.Visit((dynamic)widgetValue)), form); return(form); }
public object Deserialize(IReadVisitor visitor, Type type) { if (visitor == null) { throw new ArgumentNullException(nameof(visitor)); } if (type == null) { throw new ArgumentNullException(nameof(type)); } var traveller = _rootTravellers.GetOrAdd(type, out var level); if (level == LevelType.Value) { var valueVisitor = ValueVisitor.Create(type); return(valueVisitor.TryVisitValue(visitor, VisitArgs.CreateRoot(level), out var value) ? value : default);
protected override Expression VisitBinary(BinaryExpression node) { if (node == null) { throw new ArgumentNullException(nameof(node)); } switch (node.NodeType) { case ExpressionType.Equal: case ExpressionType.TypeEqual: var member = ExtractMember(node.Left); Values[member.Name] = ValueVisitor.ExtractValue(node.Right); return(node); case ExpressionType.And: case ExpressionType.AndAlso: return(base.VisitBinary(node)); } ThrowNotSupported(node.NodeType.ToString()); return(node); }