Skip to content

API reference

Class ListedContentSource

Namespace: MicroEngine.Content
Assembly: MicroEngine.Content.dll
Guide: Assets

Content files a host lists and opens itself, where the files are not a folder .NET can read: an Android app’s packaged assets (opened through the platform’s asset manager), files a browser page fetched. The listing is fixed when the source is made; names follow the folder rules (exact letter case everywhere, ‘/’ separators).

C#
public sealed class ListedContentSource : IContentSource

Inheritance

object ← ListedContentSource

Implements

IContentSource

Extension Methods

ContentSources.ReadAllBytes(IContentSource, string)

Constructors

ListedContentSource(string, IEnumerable<string>, Func<string, Stream>)

A source over files, read with open.

C#
public ListedContentSource(string location, IEnumerable<string> files, Func<string, Stream> open)

Parameters

location string

A description of where the files are, for messages.

files IEnumerable<string>

Every file, relative to the source with ‘/’ separators.

open Func<string, Stream>

Opens one of files (given exactly as listed); called from any thread.

Exceptions

ArgumentException

location is null, empty or white space.

Properties

Location

Where the files are (a folder’s absolute path, or a description), for diagnostics.

C#
public string Location { get; }

Property Value

string

Methods

Exists(string)

Whether a file exists at path. False for a missing file and for a path outside the source.

C#
public bool Exists(string path)

Parameters

path string

Returns

bool

Files(string)

The files directly inside folder (“” for the top), as paths relative to the source, in ordinal order.

C#
public IReadOnlyList<string> Files(string folder)

Parameters

folder string

Returns

IReadOnlyList<string>

Exceptions

DirectoryNotFoundException

The folder does not exist.

Open(string)

Opens the file at path for reading; the caller disposes the stream.

C#
public Stream Open(string path)

Parameters

path string

Returns

Stream

Exceptions

ArgumentException

The path leaves the source.

FileNotFoundException

No such file, or its name is spelled with another letter case.