Class ControllerExtensions
Inheritance
System.Object
ControllerExtensions
Assembly: Eco.Core.dll
Syntax
public static class ControllerExtensions : Object
Methods
Changed(IController, String)
Declaration
public static void Changed(this IController controller, [ControllerPropertyName(null)] string name)
Parameters
Type |
Name |
Description |
IController |
controller |
|
System.String |
name |
|
ChangedSafe(IController, String)
Alternative to Changed(IController, String) with null check for property name. It should be removed when all places which may pass null as property name fixed,
Declaration
public static void ChangedSafe(this IController controller, [ControllerPropertyName(null)] string name)
Parameters
Type |
Name |
Description |
IController |
controller |
|
System.String |
name |
|
CheckChangedEnumerables(IController, String, Object, Object)
Declaration
public static void CheckChangedEnumerables(IController controller, [ControllerPropertyName(null)] string propertyName, object before, object after)
Parameters
Type |
Name |
Description |
IController |
controller |
|
System.String |
propertyName |
|
System.Object |
before |
|
System.Object |
after |
|
CheckScanIntoPropAttr(PropertyInfo, PropertyInfo)
Declaration
public static bool CheckScanIntoPropAttr(PropertyInfo parentProp, PropertyInfo prop)
Parameters
Type |
Name |
Description |
System.Reflection.PropertyInfo |
parentProp |
|
System.Reflection.PropertyInfo |
prop |
|
Returns
Type |
Description |
System.Boolean |
|
OnPropertyChanged(IController, String, ISaveablePlugin)
Declaration
public static void OnPropertyChanged(this IController controller, [ControllerPropertyName(null)] string name, ISaveablePlugin savePlugin)
Parameters
OnPropertyChanged<T>(Object, PropertyChangedEventArgs)
Declaration
public static void OnPropertyChanged<T>(object sender, PropertyChangedEventArgs args)
where T : ISaveablePlugin
Parameters
Type |
Name |
Description |
System.Object |
sender |
|
System.ComponentModel.PropertyChangedEventArgs |
args |
|
Type Parameters
Package(IController, INetClient)
Declaration
public static BSONValue Package(this IController controller, INetClient boundClient)
Parameters
Returns
SetProperty<T>(IController, ref T, T, String)
Set a property if it's changed and notify it's changed. No need to set name if used in a propery.
Declaration
public static void SetProperty<T>(this IController controller, ref T propertyStore, T value, [ControllerPropertyName(null)] string name = null)
Parameters
Type |
Name |
Description |
IController |
controller |
|
T |
propertyStore |
|
T |
value |
|
System.String |
name |
|
Type Parameters
Subscribe(IController, ISubscriptions<ThreadSafeSubscriptions>, String, Action)
Subscribes to controller and registers subscription in subscriptions
.
Declaration
public static void Subscribe(this IController controller, ISubscriptions<ThreadSafeSubscriptions> subscriptions, [ControllerPropertyName("controller")] string propname, Action changedCallback)
Parameters
Subscribe(IController, String, Action)
Relay subscription calls to the controller object.
Declaration
public static void Subscribe(this IController controller, [ControllerPropertyName(null)] string propname, Action changedCallback)
Parameters
Type |
Name |
Description |
IController |
controller |
|
System.String |
propname |
|
System.Action |
changedCallback |
|
SubscribeAllPropsRecursive(IEnumerable<IController>, TrackingCallbacks, ISubscriptions<ThreadSafeSubscriptions>, Action<PropertyInfo, Object>)
Watch of changes of all properties marked with ScanPropAttribute in the collection recursively, which can be useful for updates in complex structures with nested objects, like Election. NOTE: As it subscribes for everything it's very ineffective method. Avoid if possible.
Declaration
public static void SubscribeAllPropsRecursive(this IEnumerable<IController> collection, TrackingCallbacks callbacks, ISubscriptions<ThreadSafeSubscriptions> subscriptions, Action<PropertyInfo, object> onChange)
Parameters
SubscribeAllRecursive(ISubscriptions<ThreadSafeSubscriptions>, IController, Action<PropertyInfo, Object>, Func<PropertyInfo, Boolean>, PropertyInfo)
Subscribe to ALL sync parameters, and ALL the children of those sync parameters that are also controllers.
Declaration
public static void SubscribeAllRecursive(this ISubscriptions<ThreadSafeSubscriptions> subs, IController controller, Action<PropertyInfo, object> changedCallback, Func<PropertyInfo, bool> filter = null, PropertyInfo parentProp = null)
Parameters
Type |
Name |
Description |
ISubscriptions<ThreadSafeSubscriptions> |
subs |
|
IController |
controller |
|
System.Action<System.Reflection.PropertyInfo, System.Object> |
changedCallback |
|
System.Func<System.Reflection.PropertyInfo, System.Boolean> |
filter |
|
System.Reflection.PropertyInfo |
parentProp |
|
SubscribeAndCall(IController, ISubscriptions<ThreadSafeSubscriptions>, String, Action)
Subscribes to controller, registers subscription in subscriptions
and calls changedCallback
.
Declaration
public static void SubscribeAndCall(this IController controller, ISubscriptions<ThreadSafeSubscriptions> subscriptions, [ControllerPropertyName("controller")] string propname, Action changedCallback)
Parameters
SubscribeAndCall(IController, String, Action)
Relay subscription calls to the controller object, then call the method.
Declaration
public static void SubscribeAndCall(this IController controller, [ControllerPropertyName(null)] string propname, Action changedCallback)
Parameters
Type |
Name |
Description |
IController |
controller |
|
System.String |
propname |
|
System.Action |
changedCallback |
|
Remarks
SubscribeUnique(IController, ISubscriptions<ThreadSafeSubscriptions>, String, Action)
Subscribes to controller (unique) and registers subscription in subscriptions
.
Declaration
public static void SubscribeUnique(this IController controller, ISubscriptions<ThreadSafeSubscriptions> subscriptions, [ControllerPropertyName("controller")] string propname, Action changedCallback)
Parameters
SubscribeUnique(IController, String, Action)
Relay subscription calls to the controller object, if a subscription with the same callback is not already bound.
Declaration
public static void SubscribeUnique(this IController controller, [ControllerPropertyName(null)] string propname, Action changedCallback)
Parameters
Type |
Name |
Description |
IController |
controller |
|
System.String |
propname |
|
System.Action |
changedCallback |
|
SubscribeUniqueAndCall(IController, ISubscriptions<ThreadSafeSubscriptions>, String, Action)
Subscribes to controller, registers subscription in subscriptions
and calls changedCallback
.
Declaration
public static void SubscribeUniqueAndCall(this IController controller, ISubscriptions<ThreadSafeSubscriptions> subscriptions, [ControllerPropertyName("controller")] string propname, Action changedCallback)
Parameters
Unsubscribe(IController, String, Action)
Unsubscribe previously subscribed controller. Returns false if there wasn't such subscription.
Declaration
public static bool Unsubscribe(this IController controller, [ControllerPropertyName(null)] string propname, Action changedCallback)
Parameters
Type |
Name |
Description |
IController |
controller |
|
System.String |
propname |
|
System.Action |
changedCallback |
|
Returns
Type |
Description |
System.Boolean |
|
UnwatchAll(IEnumerable<PropertyChangedEventHandler>, INotifyPropertyChanged)
Unsubsribe to all event handlers on the given property notifier.
Declaration
public static void UnwatchAll(this IEnumerable<PropertyChangedEventHandler> list, INotifyPropertyChanged watch)
Parameters
Type |
Name |
Description |
System.Collections.Generic.IEnumerable<System.ComponentModel.PropertyChangedEventHandler> |
list |
|
System.ComponentModel.INotifyPropertyChanged |
watch |
|
UnwatchProp(INotifyPropertyChanged, PropertyChangedEventHandler)
Declaration
public static void UnwatchProp(this INotifyPropertyChanged watch, PropertyChangedEventHandler handler)
Parameters
Type |
Name |
Description |
System.ComponentModel.INotifyPropertyChanged |
watch |
|
System.ComponentModel.PropertyChangedEventHandler |
handler |
|
WatchPropDeprecated(INotifyPropertyChanged, PropertyChangedEventHandler)
Watch for a property changing through the fody system, using a passed handler.
DEPRECATED. Use ChangeWatcher class.
Declaration
public static void WatchPropDeprecated(this INotifyPropertyChanged watch, PropertyChangedEventHandler handler)
Parameters
Type |
Name |
Description |
System.ComponentModel.INotifyPropertyChanged |
watch |
|
System.ComponentModel.PropertyChangedEventHandler |
handler |
|
WatchPropDeprecated(INotifyPropertyChanged, String, Action<Object>)
Watch for a property changing through the fody system.
DEPRECATED. Use ChangeWatcher class.
Declaration
public static PropertyChangedEventHandler WatchPropDeprecated(this INotifyPropertyChanged watch, [ControllerPropertyName(null)] string name, Action<object> func)
Parameters
Type |
Name |
Description |
System.ComponentModel.INotifyPropertyChanged |
watch |
|
System.String |
name |
|
System.Action<System.Object> |
func |
|
Returns
Type |
Description |
System.ComponentModel.PropertyChangedEventHandler |
|
WatchPropertyOnAllEntries<T>(IEnumerable<T>, TrackingCallbacks, PropertyChangedEventHandler)
Makes sure handler
is called whenever value of any property changes in any element of collection
Declaration
public static void WatchPropertyOnAllEntries<T>(this IEnumerable<T> collection, TrackingCallbacks callbacks, PropertyChangedEventHandler handler)
where T : INotifyPropertyChanged
Parameters
Type |
Name |
Description |
System.Collections.Generic.IEnumerable<T> |
collection |
|
TrackingCallbacks |
callbacks |
TrackingCallbacks for collection
|
System.ComponentModel.PropertyChangedEventHandler |
handler |
|
Type Parameters
WatchPropertyOnAllEntries<T>(IEnumerable<T>, TrackingCallbacks, String, Action<Object>)
Makes sure onChange
is called whenever value of property with name propertyName
changes in any element of collection
Declaration
public static void WatchPropertyOnAllEntries<T>(this IEnumerable<T> collection, TrackingCallbacks callbacks, [ControllerPropertyName("T")] string propertyName, Action<object> onChange)
where T : INotifyPropertyChanged
Parameters
Type |
Name |
Description |
System.Collections.Generic.IEnumerable<T> |
collection |
|
TrackingCallbacks |
callbacks |
TrackingCallbacks for collection
|
System.String |
propertyName |
|
System.Action<System.Object> |
onChange |
|
Type Parameters