public RepeatableOptionViewModel(RepeatableViewModel owner) : base(owner) { if (owner == null) { throw new ArgumentNullException(nameof(owner)); } _presentation = owner.PropertyBinding; }
public void RemoveRepeatableConcept(RepeatableViewModel repeatable) { // removes THIS concept from owning THIS concept repeatable // TODO: move the code below to SyntaxTreeManager PropertyInfo property = repeatable.Owner.SyntaxNode.GetPropertyInfo(repeatable.PropertyBinding); IList list; if (property.IsOptional()) { IOptional optional = (IOptional)property.GetValue(repeatable.Owner.SyntaxNode); if (!optional.HasValue) { return; } list = (IList)optional.Value; } else { list = (IList)property.GetValue(repeatable.Owner.SyntaxNode); } list.Remove(SyntaxNode); // TODO: move the code below to SyntaxNodeExtentions for (int l = 0; l < repeatable.Lines.Count; l++) { var line = repeatable.Lines[l]; for (int i = 0; i < line.Nodes.Count; i++) { if (line.Nodes[i] == this) { repeatable.Lines.RemoveAt(l); return; } } } }