internal static Notebook DeserializeNotebook(JsonElement element)
        {
            Optional <string> description = default;
            Optional <BigDataPoolReference>      bigDataPool       = default;
            Optional <NotebookSessionProperties> sessionProperties = default;
            NotebookMetadata metadata = default;
            int nbformat      = default;
            int nbformatMinor = default;
            IList <NotebookCell>         cells = default;
            IDictionary <string, object> additionalProperties           = default;
            Dictionary <string, object>  additionalPropertiesDictionary = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("description"))
                {
                    description = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("bigDataPool"))
                {
                    bigDataPool = BigDataPoolReference.DeserializeBigDataPoolReference(property.Value);
                    continue;
                }
                if (property.NameEquals("sessionProperties"))
                {
                    sessionProperties = NotebookSessionProperties.DeserializeNotebookSessionProperties(property.Value);
                    continue;
                }
                if (property.NameEquals("metadata"))
                {
                    metadata = NotebookMetadata.DeserializeNotebookMetadata(property.Value);
                    continue;
                }
                if (property.NameEquals("nbformat"))
                {
                    nbformat = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("nbformat_minor"))
                {
                    nbformatMinor = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("cells"))
                {
                    List <NotebookCell> array = new List <NotebookCell>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(NotebookCell.DeserializeNotebookCell(item));
                    }
                    cells = array;
                    continue;
                }
                additionalPropertiesDictionary ??= new Dictionary <string, object>();
                additionalPropertiesDictionary.Add(property.Name, property.Value.GetObject());
            }
            additionalProperties = additionalPropertiesDictionary;
            return(new Notebook(description.Value, bigDataPool.Value, sessionProperties.Value, metadata, nbformat, nbformatMinor, cells, additionalProperties));
        }
Exemple #2
0
 internal Notebook(string description, BigDataPoolReference bigDataPool, NotebookSessionProperties sessionProperties, NotebookMetadata metadata, int nbformat, int nbformatMinor, IList <NotebookCell> cells, IDictionary <string, object> additionalProperties)
 {
     Description          = description;
     BigDataPool          = bigDataPool;
     SessionProperties    = sessionProperties;
     Metadata             = metadata;
     Nbformat             = nbformat;
     NbformatMinor        = nbformatMinor;
     Cells                = cells;
     AdditionalProperties = additionalProperties;
 }
Exemple #3
0
        public Notebook(NotebookMetadata metadata, int nbformat, int nbformatMinor, IEnumerable <NotebookCell> cells)
        {
            if (metadata == null)
            {
                throw new ArgumentNullException(nameof(metadata));
            }
            if (cells == null)
            {
                throw new ArgumentNullException(nameof(cells));
            }

            Metadata             = metadata;
            Nbformat             = nbformat;
            NbformatMinor        = nbformatMinor;
            Cells                = cells.ToList();
            AdditionalProperties = new ChangeTrackingDictionary <string, object>();
        }