bool ReadYamlManifest(WorkbookDocument document)
        {
            var manifestCell = document.FirstCell as YamlMetadataCell;

            if (manifestCell == null)
            {
                return(false);
            }

            Read(new StringReader(manifestCell.Buffer.Value));

            document.RemoveCell(manifestCell);

            return(true);
        }
        bool ReadLegacyJsonManifest(WorkbookDocument document)
        {
            var manifestCell = document.FirstCell as CodeCell;

            if (manifestCell?.LanguageName != "json")
            {
                return(false);
            }

            ReadProperties(LegacyJsonWorkbookDocumentManifest.Read(manifestCell.Buffer.Value));

            document.RemoveCell(manifestCell);

            return(true);
        }
        public void Read(WorkbookDocument document)
        {
            if (document == null)
            {
                throw new ArgumentNullException(nameof(document));
            }

            try {
                if (ReadYamlManifest(document) || ReadLegacyJsonManifest(document))
                {
                    return;
                }
            } catch (Exception e) when(!(e is InvalidManifestException))
            {
                throw new InvalidManifestException(e);
            }

            throw new InvalidManifestException();
        }
Esempio n. 4
0
        public WorkbookPage(WorkbookPackage workbook, params AgentType [] platformTargets)
        {
            if (workbook == null)
            {
                throw new ArgumentNullException(nameof(workbook));
            }

            Workbook = workbook;
            Manifest.PlatformTargets = platformTargets.ToImmutableArray();
            Contents = new WorkbookDocument();

            TableOfContents = new TableOfContentsNode();

            TreeNode = new WorkbookTitledNode(this)
            {
                FileName     = ".workbook",
                Children     = TableOfContents.Children,
                IsSelectable = true
            };
        }