internal sealed override void WriteChanges(EmberWriter writer, IInvocationCollection pendingInvocations) { if (this.HasChanges) { writer.WriteStartApplicationDefinedType( GlowElementCollection.Element.OuterId, GlowQualifiedParameter.InnerNumber); writer.WriteValue(GlowQualifiedParameter.Path.OuterId, this.NumberPath); writer.WriteStartSet(GlowQualifiedParameter.Contents.OuterId); if (this.theValue == null) { // This can only happen when the parameter happens to be a trigger. writer.WriteValue(GlowParameterContents.Value.OuterId, 0); } else { this.WriteValue(writer, this.theValue); } writer.WriteEndContainer(); writer.WriteEndContainer(); this.HasChanges = false; } }
private void ReadChildContents( EmberReader reader, ElementType actualType, int number, ref Element child, out RetrievalState childRetrievalState) { reader.AssertInnerNumber(InnerNumber.Set); if (child != null) { childRetrievalState = child.ReadContents(reader, actualType); } else { using (var stream = new MemoryStream()) using (var writer = new EmberWriter(stream)) { // Since EmberReader checks that every end of a container is matched by a start, we need to write // this dummy here. writer.WriteStartSet(GlowNode.Contents.OuterId); var identifier = reader.CopyToEndContainer(writer, GlowNodeContents.Identifier.OuterId) as string; if (identifier != null) { writer.Flush(); stream.Position = 0; using (var contentsReader = new EmberReader(stream)) { contentsReader.Read(); // Read what we have written with WriteStartSet above var newPolicy = this.childrenRetrievalPolicy == ChildrenRetrievalPolicy.All ? ChildrenRetrievalPolicy.All : ChildrenRetrievalPolicy.None; var context = new Context(this, number, identifier, newPolicy); child = this.ReadNewChildContents(contentsReader, actualType, context, out childRetrievalState); if (child != null) { this.children.Add(number, child); } } } else { childRetrievalState = RetrievalState.Complete; child = null; } } } }