Пример #1
0
        internal static NotebookMetadata DeserializeNotebookMetadata(JsonElement element)
        {
            Optional <NotebookKernelSpec>   kernelspec                     = default;
            Optional <NotebookLanguageInfo> languageInfo                   = default;
            IDictionary <string, object>    additionalProperties           = default;
            Dictionary <string, object>     additionalPropertiesDictionary = new Dictionary <string, object>();

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("kernelspec"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    kernelspec = NotebookKernelSpec.DeserializeNotebookKernelSpec(property.Value);
                    continue;
                }
                if (property.NameEquals("language_info"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    languageInfo = NotebookLanguageInfo.DeserializeNotebookLanguageInfo(property.Value);
                    continue;
                }
                additionalPropertiesDictionary.Add(property.Name, property.Value.GetObject());
            }
            additionalProperties = additionalPropertiesDictionary;
            return(new NotebookMetadata(kernelspec.Value, languageInfo.Value, additionalProperties));
        }
Пример #2
0
        internal static NotebookMetadata DeserializeNotebookMetadata(JsonElement element)
        {
            NotebookKernelSpec           kernelspec                     = default;
            NotebookLanguageInfo         languageInfo                   = default;
            IDictionary <string, object> additionalProperties           = default;
            Dictionary <string, object>  additionalPropertiesDictionary = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("kernelspec"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    kernelspec = NotebookKernelSpec.DeserializeNotebookKernelSpec(property.Value);
                    continue;
                }
                if (property.NameEquals("language_info"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    languageInfo = NotebookLanguageInfo.DeserializeNotebookLanguageInfo(property.Value);
                    continue;
                }
                additionalPropertiesDictionary ??= new Dictionary <string, object>();
                if (property.Value.ValueKind == JsonValueKind.Null)
                {
                    additionalPropertiesDictionary.Add(property.Name, null);
                }
                else
                {
                    additionalPropertiesDictionary.Add(property.Name, property.Value.GetObject());
                }
            }
            additionalProperties = additionalPropertiesDictionary;
            return(new NotebookMetadata(kernelspec, languageInfo, additionalProperties));
        }
 internal NotebookMetadata(NotebookKernelSpec kernelspec, NotebookLanguageInfo languageInfo, IDictionary <string, object> additionalProperties)
 {
     Kernelspec           = kernelspec;
     LanguageInfo         = languageInfo;
     AdditionalProperties = additionalProperties ?? new Dictionary <string, object>();
 }