Exemple #1
0
        private void ReadQualifiedChild(EmberReader reader, ElementType actualType)
        {
            reader.ReadAndAssertOuter(GlowQualifiedNode.Path.OuterId);
            var path = reader.AssertAndReadContentsAsInt32Array();

            if (path.Length == 0)
            {
                throw new ModelException("Invalid path for a qualified element.");
            }

            this.ReadQualifiedChild(reader, actualType, path, 0);
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        private static IReadOnlyList <MatrixLabel> ReadLabels(EmberReader reader)
        {
            reader.AssertInnerNumber(GlowLabelCollection.InnerNumber);
            var result = new List <MatrixLabel>();

            while (reader.Read() && (reader.InnerNumber != InnerNumber.EndContainer))
            {
                switch (reader.GetContextSpecificOuterNumber())
                {
                case GlowLabelCollection.Label.OuterNumber:
                    reader.AssertInnerNumber(GlowLabel.InnerNumber);

                    int[]  basePath    = null;
                    string description = null;

                    while (reader.Read() && (reader.InnerNumber != InnerNumber.EndContainer))
                    {
                        switch (reader.GetContextSpecificOuterNumber())
                        {
                        case GlowLabel.BasePath.OuterNumber:
                            basePath = reader.AssertAndReadContentsAsInt32Array();
                            break;

                        case GlowLabel.Description.OuterNumber:
                            description = reader.AssertAndReadContentsAsString();
                            break;

                        default:
                            reader.Skip();
                            break;
                        }
                    }

                    if ((basePath != null) && (description != null))
                    {
                        result.Add(new MatrixLabel(basePath, description));
                    }

                    break;

                default:
                    reader.Skip();
                    break;
                }
            }

            return(result);
        }
        private void ReadConnections(EmberReader reader)
        {
            reader.AssertInnerNumber(GlowConnectionCollection.InnerNumber);

            while (reader.Read() && (reader.InnerNumber != InnerNumber.EndContainer))
            {
                switch (reader.GetContextSpecificOuterNumber())
                {
                case GlowConnectionCollection.Connection.OuterNumber:
                    reader.AssertInnerNumber(GlowConnection.InnerNumber);
                    int?  target                      = null;
                    int[] connectedSources            = new int[0];
                    ConnectionOperation   operation   = ConnectionOperation.Absolute;
                    ConnectionDisposition disposition = ConnectionDisposition.Tally;

                    while (reader.Read() && (reader.InnerNumber != InnerNumber.EndContainer))
                    {
                        switch (reader.GetContextSpecificOuterNumber())
                        {
                        case GlowConnection.Target.OuterNumber:
                            target = this.ReadInt(reader, GlowConnection.Target.Name);
                            break;

                        case GlowConnection.Sources.OuterNumber:
                            connectedSources = reader.AssertAndReadContentsAsInt32Array();
                            break;

                        case GlowConnection.Operation.OuterNumber:
                            operation =
                                this.ReadEnum <ConnectionOperation>(reader, GlowConnection.Operation.Name);
                            break;

                        case GlowConnection.Disposition.OuterNumber:
                            disposition =
                                this.ReadEnum <ConnectionDisposition>(reader, GlowConnection.Disposition.Name);
                            break;

                        default:
                            reader.Skip();
                            break;
                        }
                    }

                    if (target.HasValue && (disposition != ConnectionDisposition.Pending) && !this.HasChanges)
                    {
                        var existingConnectedSources = this.Connections[target.Value];

                        switch (operation)
                        {
                        case ConnectionOperation.Absolute:
                            Insert(existingConnectedSources, connectedSources, true);
                            break;

                        case ConnectionOperation.Connect:
                            Insert(existingConnectedSources, connectedSources, false);
                            break;

                        case ConnectionOperation.Disconnect:
                            foreach (var source in connectedSources)
                            {
                                existingConnectedSources.Remove(source);
                            }

                            break;
                        }
                    }

                    break;

                default:
                    reader.Skip();
                    break;
                }
            }
        }