Table of Contents

Class DesignTimeDataContext

Namespace
BSGameLib.UI.Internal
Assembly
BSGameLib.UI.dll

A IDataContext backed by a flat name/value map loaded from a DesignData file, for previewing a view without its real view model. See DesignData for why this exists rather than instantiating the real thing.

public sealed class DesignTimeDataContext : IDataContext, IDynamicDataContext
Inheritance
DesignTimeDataContext
Implements
Inherited Members

Constructors

DesignTimeDataContext(IEnumerable<DesignDataProperty>)

Creates a context from the properties of a design-data file. Used by the design-time host; not for direct use.

public DesignTimeDataContext(IEnumerable<DesignDataProperty> properties)

Parameters

properties IEnumerable<DesignDataProperty>

DesignTimeDataContext(IEnumerable<DesignDataProperty>, IEnumerable<DesignDataItems>)

Creates a context from the properties and the collections of a design-data file. Each row of a collection is a context of its own. Used by the design-time host; not for direct use.

public DesignTimeDataContext(IEnumerable<DesignDataProperty> properties, IEnumerable<DesignDataItems> collections)

Parameters

properties IEnumerable<DesignDataProperty>
collections IEnumerable<DesignDataItems>

Properties

PropertyNames

The property names this context supplies, for coverage reporting.

public IReadOnlyCollection<string> PropertyNames { get; }

Property Value

IReadOnlyCollection<string>

Methods

GetDesignDataPathForView(string)

Returns the path of the design-data file for the view file at viewPath: Foo.view.xml gives Foo.designdata.xml. Returns null when the path is empty.

public static string GetDesignDataPathForView(string viewPath)

Parameters

viewPath string

Returns

string

LoadForView(IFileSystem, string)

Loads the design data paired with a view file, by the Foo.view.xml → Foo.designdata.xml convention. Returns null when there is no such file; throws with the parse error if the file exists but is malformed, since a design data file that silently does nothing is exactly the failure this feature exists to stop.

public static DesignTimeDataContext LoadForView(IFileSystem fileSystem, string viewPath)

Parameters

fileSystem IFileSystem
viewPath string

Returns

DesignTimeDataContext

TryGetValue(string, out object)

Gets the value of the property propertyName. Returns false when the context does not supply it.

public bool TryGetValue(string propertyName, out object value)

Parameters

propertyName string
value object

Returns

bool

TrySetValue(string, object)

Accepts a value for propertyName, so that a two-way bound control in a preview can write to it. The value is kept only while the preview runs. Returns false when the name is empty.

public bool TrySetValue(string propertyName, object value)

Parameters

propertyName string
value object

Returns

bool