Class FrozenObjectsExtensions
A set of extension methods on top of RealmObjectBase.
Namespace: Realms
Assembly: Realm.dll
Syntax
public static class FrozenObjectsExtensions
Methods
| Edit this page View SourceFreeze<TValue>(IDictionary<string, TValue>)
Creates a frozen snapshot of this dictionary. The frozen copy can be read from any thread. If the dictionary is not managed, a RealmException will be thrown.
Freezing a dictionary also creates a frozen Realm which has its own lifecycle, but if the live Realm that spawned the original set is fully closed (i.e. all instances across all threads are closed), the frozen Realm and dictionary will be closed as well. Frozen dictionaries can be read and iterated as normal, but trying to mutate it in any way or attempting to subscribe for notifications will throw a RealmFrozenException. Note: Keeping a large number of frozen objects with different versions alive can have a negative impact on the filesize of the Realm. In order to avoid such a situation it is possible to set MaxNumberOfActiveVersions.Declaration
public static IDictionary<string, TValue> Freeze<TValue>(this IDictionary<string, TValue> dictionary)
Parameters
Type | Name | Description |
---|---|---|
IDictionary<string, TValue> | dictionary | The dictionary you want to create a frozen copy of. |
Returns
Type | Description |
---|---|
IDictionary<string, TValue> | A frozen copy of this dictionary. |
Type Parameters
Name | Description |
---|---|
TValue | The type of the values stored in the dictionary. |
Freeze<T>(IList<T>)
Creates a frozen snapshot of this list. The frozen copy can be read and iterated over from any thread. If the list is not managed, a RealmException will be thrown.
Freezing a list also creates a frozen Realm which has its own lifecycle, but if the live Realm that spawned the original list is fully closed (i.e. all instances across all threads are closed), the frozen Realm and list will be closed as well. Frozen lists can be read and iterated as normal, but trying to mutate it in any way or attempting to subscribe for notifications will throw a RealmFrozenException. Note: Keeping a large number of frozen objects with different versions alive can have a negative impact on the filesize of the Realm. In order to avoid such a situation it is possible to set MaxNumberOfActiveVersions.Declaration
public static IList<T> Freeze<T>(this IList<T> list)
Parameters
Type | Name | Description |
---|---|---|
IList<T> | list | The list you want to create a frozen copy of. |
Returns
Type | Description |
---|---|
IList<T> | A frozen copy of this list. |
Type Parameters
Name | Description |
---|---|
T | Type of the elements in the list. |
Freeze<T>(ISet<T>)
Creates a frozen snapshot of this set. The frozen copy can be read from any thread. If the set is not managed, a RealmException will be thrown.
Freezing a set also creates a frozen Realm which has its own lifecycle, but if the live Realm that spawned the original set is fully closed (i.e. all instances across all threads are closed), the frozen Realm and set will be closed as well. Frozen sets can be read and iterated as normal, but trying to mutate it in any way or attempting to subscribe for notifications will throw a RealmFrozenException. Note: Keeping a large number of frozen objects with different versions alive can have a negative impact on the filesize of the Realm. In order to avoid such a situation it is possible to set MaxNumberOfActiveVersions.Declaration
public static ISet<T> Freeze<T>(this ISet<T> set)
Parameters
Type | Name | Description |
---|---|---|
ISet<T> | set | The set you want to create a frozen copy of. |
Returns
Type | Description |
---|---|
ISet<T> | A frozen copy of this set. |
Type Parameters
Name | Description |
---|---|
T | The type of the elements in the set. |
Freeze<T>(IQueryable<T>)
Creates a frozen snapshot of this query. The frozen copy can be read and queried from any thread. If the query is not managed (i.e. not a result of All<T>() invocation), a RealmException will be thrown.
Freezing a query also creates a frozen Realm which has its own lifecycle, but if the live Realm that spawned the original query is fully closed (i.e. all instances across all threads are closed), the frozen Realm and query will be closed as well. Frozen queries can be read and iterated as normal, but trying to mutate it in any way or attempting to subscribe for notifications will throw a RealmFrozenException. Note: Keeping a large number of frozen objects with different versions alive can have a negative impact on the filesize of the Realm. In order to avoid such a situation it is possible to set MaxNumberOfActiveVersions.Declaration
public static IQueryable<T> Freeze<T>(this IQueryable<T> query) where T : IRealmObjectBase
Parameters
Type | Name | Description |
---|---|---|
IQueryable<T> | query | The query you want to create a frozen copy of. |
Returns
Type | Description |
---|---|
IQueryable<T> | A frozen copy of this query. |
Type Parameters
Name | Description |
---|---|
T | The type of the elements in the query. |
Freeze<T>(T)
Returns a frozen snapshot of this object. The frozen copy can be read and queried from any thread without throwing an exception.
Freezing a RealmObjectBase also creates a frozen Realm which has its own lifecycle, but if the live Realm that spawned the original object is fully closed (i.e. all instances across all threads are closed), the frozen Realm and object will be closed as well. Frozen objects can be queried as normal, but trying to mutate it in any way or attempting to subscribe for notifications will throw a RealmFrozenException. Note: Keeping a large number of frozen objects with different versions alive can have a negative impact on the filesize of the Realm. In order to avoid such a situation it is possible to set MaxNumberOfActiveVersions.Declaration
public static T Freeze<T>(this T realmObj) where T : IRealmObjectBase
Parameters
Type | Name | Description |
---|---|---|
T | realmObj | The IRealmObject, IEmbeddedObject, or IAsymmetricObject instance that you want to create a frozen version of. |
Returns
Type | Description |
---|---|
T | A new frozen instance of the passed in object or the object itself if it was already frozen. |
Type Parameters
Name | Description |
---|---|
T | The type of the IRealmObject/IEmbeddedObject/IAsymmetricObject. |