Table of Contents

Class Dataset

Namespace
ROCrates.Models
Assembly
ROCrates.Net.dll
public class Dataset : FileOrDir
Inheritance
Dataset
Derived
Inherited Members

Constructors

Dataset()

public Dataset()

Dataset(ROCrate?, string?, JsonObject?, string?, string?, bool, bool)

public Dataset(ROCrate? crate = null, string? identifier = null, JsonObject? properties = null, string? source = null, string? destPath = null, bool fetchRemote = false, bool validateUrl = false)

Parameters

crate ROCrate
identifier string
properties JsonObject
source string
destPath string
fetchRemote bool
validateUrl bool

Methods

Deserialize(string, ROCrate)

Create a Dataset from JSON properties.

public static Dataset? Deserialize(string entityJson, ROCrate roCrate)

Parameters

entityJson string

The JSON representing the Dataset

roCrate ROCrate

The RO-Crate for the Dataset

Returns

Dataset

The deserialised Dataset

Serialize()

Convert Dataset to JSON string.

public override string Serialize()

Returns

string

The Dataset as a JSON string.

Write(string)

Write the contents of a Dataset to disk.

If the Dataset's source is remote, the contents will be downloaded to basePath.

If the source is on disk, the contents will be copied under basePath.

public override void Write(string basePath)

Parameters

basePath string

The path under which the Dataset's parts will be written.

Examples

var url = "https://hdruk.github.io/hutch/docs/devs";
var dirName = url.Split('/').Last();
var dataset = new Models.Dataset(
   new ROCrate("myCrate.zip"),
   source: url,
   validateUrl: true,
   fetchRemote: true);
dataset.Write("myCrate");
Assert.True(Directory.Exists(Path.Combine("myCrate", dirName)));

Exceptions

DirectoryNotFoundException

Thrown when the source directory is not a URL, but it doesn't exist.

_empty()

protected JsonObject _empty()

Returns

JsonObject