Table of Contents

Class MarkupImporter

Namespace
Icy.Markup
Assembly
IcyUI.dll

Loads markup documents through the asset pipeline, so a UI file is requested by name like any other asset.

public class MarkupImporter : IAssetImporter<UIElement>, IFormatReadChecker
Inheritance
MarkupImporter
Implements
Inherited Members
Extension Methods

Remarks

Register it with AddMarkupSupport(IConfigurationBuilder), after which assets.Load<UIElement>("UI/MainMenu.xml") returns a built tree.

Each import produces a fresh tree - two loads of the same file give two independent element graphs, which is what a UI asset has to do, since elements are stateful and belong to exactly one place in one tree. Whether the underlying file is re-read is the asset scope's business, not this importer's.

Constructors

MarkupImporter(IcyConfiguration)

Loads markup documents through the asset pipeline, so a UI file is requested by name like any other asset.

public MarkupImporter(IcyConfiguration configuration)

Parameters

configuration IcyConfiguration

The configuration whose markup, conversion, and property services are used.

Remarks

Register it with AddMarkupSupport(IConfigurationBuilder), after which assets.Load<UIElement>("UI/MainMenu.xml") returns a built tree.

Each import produces a fresh tree - two loads of the same file give two independent element graphs, which is what a UI asset has to do, since elements are stateful and belong to exactly one place in one tree. Whether the underlying file is re-read is the asset scope's business, not this importer's.

Fields

MarkupMimeType

The MIME type markup documents are served as.

public const string MarkupMimeType = "application/xml"

Field Value

string

TextMarkupMimeType

The alternative MIME type XML files are commonly reported as.

public const string TextMarkupMimeType = "text/xml"

Field Value

string

Methods

CanRead(string?)

Checks if the importer can read assets in the specified data format.

public bool CanRead(string? format)

Parameters

format string

A string with MIME-type for the format of the loaded asset.

Returns

bool

true if the asset can be loaded by this asset reader; otherwise false.

Import(Stream, IImportContext)

Performs asset loading from the specified data stream.

public UIElement Import(Stream stream, IImportContext importContext)

Parameters

stream Stream

Data stream to read asset from.

importContext IImportContext

Context to import the asset.

Returns

UIElement

An instance of the asset of type UIElement loaded from the specified stream.

Exceptions

MarkupException

The document is malformed, or breaks a rule of the language.