internal virtual Element ReadNewChildContents(
     EmberReader reader, ElementType actualType, Context context, out RetrievalState childRetrievalState)
 {
     reader.SkipToEndContainer();
     childRetrievalState = RetrievalState.Complete;
     return(null);
 }
Exemple #2
0
        internal static TMostDerived ReadContents(
            EmberReader reader, ElementType actualType, Context context, out RetrievalState retrievalState)
        {
            var result = Construct(context);

            retrievalState = result.ReadContents(reader, actualType);
            return(result);
        }
 internal void WriteCommandCollection(
     EmberWriter writer, GlowCommandNumber commandNumber, RetrievalState retrievalState)
 {
     writer.WriteStartApplicationDefinedType(GlowElementCollection.Element.OuterId, GlowCommand.InnerNumber);
     writer.WriteValue(GlowCommand.Number.OuterId, (long)commandNumber);
     writer.WriteEndContainer();
     this.RetrievalState = retrievalState;
 }
        internal sealed override Element ReadNewChildContents(
            EmberReader reader, ElementType actualType, Context context, out RetrievalState childRetrievalState)
        {
            MetaElement metaChild;

            return(MetaChildren.TryGetValue(context.Identifier, out metaChild) ?
                   metaChild.ReadContents(reader, actualType, context, out childRetrievalState) :
                   this.ReadNewDynamicChildContents(reader, actualType, context, out childRetrievalState));
        }
        internal override RetrievalState UpdateRetrievalState(bool throwForMissingRequiredChildren)
        {
            if (!this.RetrieveDetails || (this.RetrievalState.Equals(RetrievalState.Complete) &&
                                          this.AreRequiredChildrenAvailable(throwForMissingRequiredChildren)))
            {
                this.RetrievalState = base.UpdateRetrievalState(throwForMissingRequiredChildren);
            }

            return(this.RetrievalState);
        }
Exemple #6
0
        internal sealed override Element ReadNewDynamicChildContents(
            EmberReader reader, ElementType actualType, Context context, out RetrievalState childRetrievalState)
        {
            if (ReadContentsCallback == null)
            {
                const string Format = "The type argument passed to CollectionNode<TElement> with the path {0} is neither " +
                                      "an Element<TMostDerived> subclass nor IParameter nor INode nor IFunction.";
                throw new ModelException(string.Format(CultureInfo.InvariantCulture, Format, this.GetPath()));
            }

            return(ReadContentsCallback(reader, actualType, context, out childRetrievalState));
        }
 private RetrievalState GetRetrievalState(
     bool throwForMissingRequiredChildren, RetrievalState accumulatedChildRetrievalState)
 {
     if (accumulatedChildRetrievalState.Equals(RetrievalState.Verified))
     {
         return(this.AreRequiredChildrenAvailable(throwForMissingRequiredChildren) ?
                RetrievalState.Verified : RetrievalState.Complete);
     }
     else
     {
         return(accumulatedChildRetrievalState);
     }
 }
        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;
                        }
                    }
            }
        }
        internal static Element ReadDynamicChildContents(
            EmberReader reader,
            ElementType actualType,
            Context context,
            out RetrievalState childRetrievalState)
        {
            switch (actualType)
            {
            case ElementType.Parameter:
                return(DynamicParameter.ReadContents(reader, actualType, context, out childRetrievalState));

            case ElementType.Node:
                return(DynamicNode.ReadContents(reader, actualType, context, out childRetrievalState));

            case ElementType.Function:
                return(DynamicFunction.ReadContents(reader, actualType, context, out childRetrievalState));

            default:
                return(DynamicMatrix.ReadContents(reader, actualType, context, out childRetrievalState));
            }
        }
 internal sealed override Element ReadContents(
     EmberReader reader, ElementType actualType, Context context, out RetrievalState retrievalState)
 {
     return(Element <TProperty> .ReadContents(reader, actualType, context, out retrievalState));
 }
 internal virtual void ResetRetrievalState()
 {
     this.RetrievalState = RetrievalState.None;
     this.parent.ResetRetrievalState();
 }
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        internal sealed override Element ReadNewDynamicChildContents(
            EmberReader reader, ElementType actualType, Context context, out RetrievalState childRetrievalState)
        {
            return(DynamicNodeHelper.ReadDynamicChildContents(reader, actualType, context, out childRetrievalState));
        }
 internal virtual Element ReadNewDynamicChildContents(
     EmberReader reader, ElementType actualType, Context context, out RetrievalState childRetrievalState)
 {
     return(base.ReadNewChildContents(reader, actualType, context, out childRetrievalState));
 }
 internal override void SetComplete()
 {
     this.RetrievalState = RetrievalState.Complete;
     base.SetComplete();
 }
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        internal ElementWithSchemas(RetrievalState detailsRetrievalState)
        {
            this.detailsRetrievalState = detailsRetrievalState;
        }
Exemple #16
0
 internal abstract Element ReadContents(
     EmberReader reader, ElementType actualType, Context context, out RetrievalState retrievalState);