Exemple #1
0
        public override void Write(Utf8JsonWriter writer, UserFilesInfoFolder value, JsonSerializerOptions options)
        {
            writer.WriteStartObject();
            writer.WriteString("id", value.Id.ToString());
            writer.WriteBoolean("favourite", value.IsFavourite);
            writer.WriteString("name", value.Name);
            writer.WritePropertyName("children");
            writer.WriteStartArray();
            foreach (UserFilesInfoFolder child in value.Children)
            {
                Write(writer, child, new JsonSerializerOptions());
            }
            writer.WriteEndArray();

            UserFilesInfoFileSerializer fileSerializer = new UserFilesInfoFileSerializer();

            writer.WritePropertyName("files");
            writer.WriteStartArray();
            foreach (UserFilesInfoFile file in value.Files)
            {
                fileSerializer.Write(writer, file, new JsonSerializerOptions());
            }
            writer.WriteEndArray();

            writer.WriteEndObject();
        }
Exemple #2
0
        public override void Write(Utf8JsonWriter writer, UserFilesInfo value, JsonSerializerOptions options)
        {
            //ObjectIdSerializer objectIdSerializer = new ObjectIdSerializer();
            UserFilesInfoFolderSerializer folderSerializer           = new UserFilesInfoFolderSerializer();
            UserFilesInfoFileSerializer   fileSerializer             = new UserFilesInfoFileSerializer();
            FileInfoWithUserSerializer    fileInfoWithUserSerializer = new FileInfoWithUserSerializer();

            writer.WriteStartObject();
            writer.WriteString("owner_id", value.OwnerId.ToString());
            //objectIdSerializer.Write(writer, value.OwnerId, new JsonSerializerOptions());
            writer.WritePropertyName("root_folder");
            folderSerializer.Write(writer, value.RootFolder, new JsonSerializerOptions());
            writer.WritePropertyName("available_files");
            writer.WriteStartArray();
            foreach (var file in value.AvailableFiles)
            {
                fileInfoWithUserSerializer.Write(writer, file, new JsonSerializerOptions());
            }
            writer.WriteEndArray();
            writer.WriteEndObject();
        }