콘텐츠로 이동

TemplateContext class

이 콘텐츠는 아직 번역되지 않았습니다.

Per-container companion to a template: names the elements built once, and owns the bindings and event subscriptions made each time an item is bound so they are undone when it is unbound.

Guide: C# Markup guide

public sealed class TemplateContext : IDisposable
name description
TemplateContext() The default constructor.
Bind<T>(…) Binds a property to an observable value and clears that binding on the next Reset. Binding the same target property twice registers one cleanup.
Bind<TRoot,T>(…) Binds a property along a path from a source root and clears the whole path on the next Reset.
Bind<TProp,TSource>(…) Binds a property to a converted observable value and clears that binding on the next Reset.
Bind<TProp,T1,T2>(…) Binds a property to a value that combine computes from two inputs and clears that binding and its input subscriptions on the next Reset. The binding is always OneWay and shows the default value of TProp while any input is unavailable. (2 methods)
Bind<TProp,TRoot,TSource>(…) Binds a property along a converted path from a source root and clears the whole path on the next Reset.
Bind<TProp,T1,T2,T3>(…) Binds a property to a value that combine computes from three inputs and clears that binding and its input subscriptions on the next Reset. The binding is always OneWay and shows the default value of TProp while any input is unavailable. (2 methods)
Bind<TProp,T1,T2,T3,T4>(…) Binds a property to a value that combine computes from four inputs and clears that binding and its input subscriptions on the next Reset. The binding is always OneWay and shows the default value of TProp while any input is unavailable. (2 methods)
Dispose() Equivalent to Reset; the context stays usable afterwards.
Get<T>(…) Returns the element registered under name.
Register<T>(…) Names an element for later Get. Names are unique within one context and outlive Reset, so register once from the build step.
Reset() Undoes every binding and subscription registered since the last reset, in reverse order of registration, then forgets them. Registered names are kept.
Subscribe(…) Subscribes to an object’s property changes now and unsubscribes on the next Reset.
Subscribe<TSource>(…)
Subscribe<TSource,TArg>(…)
Subscribe<TSource,TEventArgs>(…)
Subscribe<TSource,THandler>(…) Runs add now and remove on the next Reset. Subscribing from the bind step every time is correct: a rebind unsubscribes first, so handlers do not accumulate.

A container gets one context for its lifetime. Registered names survive rebinding; bindings and subscriptions do not, so register them from Bind rather than Build.