Class CollectionNotificationsExtensions
A set of extensions methods exposing notification-related functionality over collections.
Inherited Members
Namespace: Realms
Assembly: Realm.dll
Syntax
public static class CollectionNotificationsExtensions
Methods
| Improve this Doc View SourceAsRealmCollection<T>(IList<T>)
A convenience method that casts IList<T> to IRealmCollection<T> which implements INotifyCollectionChanged.
Declaration
public static IRealmCollection<T> AsRealmCollection<T>(this IList<T> list)
Parameters
Type | Name | Description |
---|---|---|
IList<T> | list | The IList<T> to observe for changes. |
Returns
Type | Description |
---|---|
IRealmCollection<T> | The collection, implementing INotifyCollectionChanged. |
Type Parameters
Name | Description |
---|---|
T | Type of the objects in the list. |
See Also
| Improve this Doc View SourceAsRealmCollection<T>(IQueryable<T>)
A convenience method that casts IQueryable<T> to IRealmCollection<T> which implements INotifyCollectionChanged.
Declaration
public static IRealmCollection<T> AsRealmCollection<T>(this IQueryable<T> results)where T : RealmObject
Parameters
Type | Name | Description |
---|---|---|
IQueryable<T> | results | The IQueryable<T> to observe for changes. |
Returns
Type | Description |
---|---|
IRealmCollection<T> | The collection, implementing INotifyCollectionChanged. |
Type Parameters
Name | Description |
---|---|
T | Type of the RealmObject in the results. |
See Also
| Improve this Doc View SourceMove<T>(IList<T>, T, Int32)
Move the specified item to a new position within the list.
Declaration
public static void Move<T>(this IList<T> list, T item, int index)
Parameters
Type | Name | Description |
---|---|---|
IList<T> | list | The list where the move should occur. |
T | item | The item that will be moved. |
Int32 | index | The new position to which the item will be moved. |
Type Parameters
Name | Description |
---|---|
T | Type of the objects in the list. |
Remarks
This extension method will work for standalone lists as well by calling System.Collections.Generic.ICollection`1.Remove(`0) and then System.Collections.Generic.IList`1.Insert(System.Int32,`0).
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | Thrown if the index is less than 0 or greater than System.Collections.Generic.ICollection`1.Count - 1. |
Move<T>(IList<T>, Int32, Int32)
Move the specified item to a new position within the list.
Declaration
public static void Move<T>(this IList<T> list, int from, int to)
Parameters
Type | Name | Description |
---|---|---|
IList<T> | list | The list where the move should occur. |
Int32 | from | The index of the item that will be moved. |
Int32 | to | The new position to which the item will be moved. |
Type Parameters
Name | Description |
---|---|
T | Type of the objects in the list. |
Remarks
This extension method will work for standalone lists as well by calling System.Collections.Generic.IList`1.RemoveAt(System.Int32) and then System.Collections.Generic.IList`1.Insert(System.Int32,`0).
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | Thrown if the index is less than 0 or greater than System.Collections.Generic.ICollection`1.Count - 1. |
SubscribeForNotifications<T>(IList<T>, NotificationCallbackDelegate<T>)
A convenience method that casts IList<T> to IRealmCollection<T> and subscribes for change notifications.
Declaration
public static IDisposable SubscribeForNotifications<T>(this IList<T> list, NotificationCallbackDelegate<T> callback)
Parameters
Type | Name | Description |
---|---|---|
IList<T> | list | The IList<T> to observe for changes. |
NotificationCallbackDelegate<T> | callback | The callback to be invoked with the updated IRealmCollection<T>. |
Returns
Type | Description |
---|---|
IDisposable | A subscription token. It must be kept alive for as long as you want to receive change notifications. To stop receiving notifications, call Dispose(). |
Type Parameters
Name | Description |
---|---|
T | Type of the objects in the list. |
See Also
| Improve this Doc View SourceSubscribeForNotifications<T>(IQueryable<T>, NotificationCallbackDelegate<T>)
A convenience method that casts IQueryable<T> to IRealmCollection<T> and subscribes for change notifications.
Declaration
public static IDisposable SubscribeForNotifications<T>(this IQueryable<T> results, NotificationCallbackDelegate<T> callback)where T : RealmObject
Parameters
Type | Name | Description |
---|---|---|
IQueryable<T> | results | The IQueryable<T> to observe for changes. |
NotificationCallbackDelegate<T> | callback | The callback to be invoked with the updated IRealmCollection<T>. |
Returns
Type | Description |
---|---|
IDisposable | A subscription token. It must be kept alive for as long as you want to receive change notifications. To stop receiving notifications, call Dispose(). |
Type Parameters
Name | Description |
---|---|
T | Type of the RealmObject in the results. |