Esempio n. 1
0
 internal Notebook(string description, BigDataPoolReference bigDataPool, NotebookSessionProperties sessionProperties, NotebookMetadata metadata, int notebookFormat, int notebookFormatMinor, IList <NotebookCell> cells, NotebookFolder folder, IDictionary <string, object> additionalProperties)
 {
     Description         = description;
     BigDataPool         = bigDataPool;
     SessionProperties   = sessionProperties;
     Metadata            = metadata;
     NotebookFormat      = notebookFormat;
     NotebookFormatMinor = notebookFormatMinor;
     Cells  = cells;
     Folder = folder;
     AdditionalProperties = additionalProperties;
 }
        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;
            Optional <NotebookFolder>    folder = default;
            IDictionary <string, object> additionalProperties           = default;
            Dictionary <string, object>  additionalPropertiesDictionary = new Dictionary <string, object>();

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("description"))
                {
                    description = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("bigDataPool"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        bigDataPool = null;
                        continue;
                    }
                    bigDataPool = BigDataPoolReference.DeserializeBigDataPoolReference(property.Value);
                    continue;
                }
                if (property.NameEquals("sessionProperties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        sessionProperties = null;
                        continue;
                    }
                    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;
                }
                if (property.NameEquals("folder"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        folder = null;
                        continue;
                    }
                    folder = NotebookFolder.DeserializeNotebookFolder(property.Value);
                    continue;
                }
                additionalPropertiesDictionary.Add(property.Name, property.Value.GetObject());
            }
            additionalProperties = additionalPropertiesDictionary;
            return(new Notebook(description.Value, bigDataPool.Value, sessionProperties.Value, metadata, nbformat, nbformatMinor, cells, folder.Value, additionalProperties));
        }