Realm Xamarin  v0.77.1
Realm for Xamarin
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Properties | List of all members
RealmConfiguration Class Reference

Realm configuration specifying settings that affect your Realm behaviour. More...

Public Member Functions

 RealmConfiguration (string optionalPath=null, bool shouldDeleteIfMigrationNeeded=false)
 Constructor allowing path override. More...
 
RealmConfiguration ConfigWithPath (string newConfigPath)
 Clone method allowing you to override or customise the current path. More...
 
override bool Equals (Object rhs)
 Generic override determines whether the specified System.Object is equal to the current RealmConfiguration. More...
 
bool Equals (RealmConfiguration rhs)
 Determines whether the specified RealmConfiguration is equal to the current RealmConfiguration. More...
 
override int GetHashCode ()
 Serves as a hash function for a RealmConfiguration based on its path. More...
 

Static Public Member Functions

static string PathToRealm (string optionalPath=null)
 Utility to build a path in which a realm will be created so can consistently use filenames and relative paths. More...
 

Public Attributes

bool ReadOnly
 Flag to indicate Realm is opened readonly so can open from locked locations such as bundled with an application. More...
 
readonly bool ShouldDeleteIfMigrationNeeded
 Flag mainly to help with temp databases and testing, indicates content can be abandoned when you change the schema. More...
 

Static Public Attributes

static string DefaultRealmName => "default.realm"
 Standard filename to be combined with the platform-specific document directory. More...
 
static UInt64 NotVersioned => UInt64.MaxValue
 Constant used for SchemaVersion to indicate is not versioned. More...
 

Properties

string DatabasePath [get]
 The full path of any realms opened with this configuration, may be overriden by passing in a separate name. More...
 
static RealmConfiguration DefaultConfiguration [get, set]
 Configuration you can override which is used when you create a new Realm without specifying a configuration. More...
 
byte[] EncryptionKey [get, set]
 Specify the key used to encrypt the entire Realm. Once set, must be specified each time file is used. More...
 
Type[] ObjectClasses [get, set]
 The list of classes persisted in a Realm opened with this configuration. More...
 
UInt64 SchemaVersion [get, set]
 Number indicating the version, can be used to arbitrarily distinguish between schemas even if they have the same objects and properties. More...
 

Detailed Description

Realm configuration specifying settings that affect your Realm behaviour.

Main role is generating a canonical path from whatever absolute, relative subdir or just filename user supplies.

Constructor & Destructor Documentation

RealmConfiguration ( string  optionalPath = null,
bool  shouldDeleteIfMigrationNeeded = false 
)

Constructor allowing path override.

Parameters
optionalPathPath to the realm, must be a valid full path for the current platform, relative subdir, or just filename.
shouldDeleteIfMigrationNeededOptional Flag mainly to help with temp databases and testing, indicates content can be abandoned when you change the schema.

References RealmConfiguration.DatabasePath, and RealmConfiguration.PathToRealm().

Referenced by RealmConfiguration.ConfigWithPath().

Member Function Documentation

RealmConfiguration ConfigWithPath ( string  newConfigPath)

Clone method allowing you to override or customise the current path.

Returns
An object with a fully-specified, canonical path.
Parameters
newConfigPathPath to the realm, must be a valid full path for the current platform, relative subdir, or just filename.

References RealmConfiguration.DatabasePath, and RealmConfiguration.RealmConfiguration().

Referenced by Realm.GetInstance().

override bool Equals ( Object  rhs)

Generic override determines whether the specified System.Object is equal to the current RealmConfiguration.

Parameters
rhsThe System.Object to compare with the current RealmConfiguration.
Returns
true if the specified System.Object is equal to the current Realms.RealmConfiguration; otherwise, false.

Referenced by Realm.Equals().

bool Equals ( RealmConfiguration  rhs)

Determines whether the specified RealmConfiguration is equal to the current RealmConfiguration.

Parameters
rhsThe System.Object to compare with the current RealmConfiguration.
Returns
true if the specified System.Object is equal to the current Realms.RealmConfiguration; otherwise, false.

References RealmConfiguration.DatabasePath, RealmConfiguration.EncryptionKey, and RealmConfiguration.ShouldDeleteIfMigrationNeeded.

override int GetHashCode ( )

Serves as a hash function for a RealmConfiguration based on its path.

Returns
A hash code for this instance that is suitable for use in hashing algorithms and data structures such as a hash table.

References RealmConfiguration.DatabasePath.

static string PathToRealm ( string  optionalPath = null)
static

Utility to build a path in which a realm will be created so can consistently use filenames and relative paths.

References RealmConfiguration.DefaultRealmName.

Referenced by RealmConfiguration.RealmConfiguration().

Member Data Documentation

string DefaultRealmName => "default.realm"
static

Standard filename to be combined with the platform-specific document directory.

A string representing a filename only, no path.

Referenced by RealmConfiguration.PathToRealm().

UInt64 NotVersioned => UInt64.MaxValue
static

Constant used for SchemaVersion to indicate is not versioned.

Must be maintained to match an internal ObjectStore::NotVersioned.

Maximum value of UInt64.

bool ReadOnly

Flag to indicate Realm is opened readonly so can open from locked locations such as bundled with an application.

Referenced by Realm.GetInstance().

readonly bool ShouldDeleteIfMigrationNeeded

Flag mainly to help with temp databases and testing, indicates content can be abandoned when you change the schema.

Referenced by RealmConfiguration.Equals(), and Realm.GetInstance().

Property Documentation

string DatabasePath
get

The full path of any realms opened with this configuration, may be overriden by passing in a separate name.

Referenced by RealmConfiguration.ConfigWithPath(), Realm.DeleteRealm(), RealmConfiguration.Equals(), RealmConfiguration.GetHashCode(), Realm.GetInstance(), and RealmConfiguration.RealmConfiguration().

RealmConfiguration DefaultConfiguration
staticgetset

Configuration you can override which is used when you create a new Realm without specifying a configuration.

Referenced by Realm.GetInstance().

byte [] EncryptionKey
getset

Specify the key used to encrypt the entire Realm. Once set, must be specified each time file is used.

Full 64byte (512bit) key for AES-256 encryption.

Referenced by RealmConfiguration.Equals(), and Realm.GetInstance().

Type [] ObjectClasses
getset

The list of classes persisted in a Realm opened with this configuration.

Specify classes by type. Searched linearly so order in decreasing frequency of creating objects.

eg: config.ObjectClasses = new Type[] { typeof(CommonClass), typeof(RareClass) };

Typically left null so by default all RealmObjects will be able to be stored in all realms.

Referenced by Realm.GetInstance().

UInt64 SchemaVersion
getset

Number indicating the version, can be used to arbitrarily distinguish between schemas even if they have the same objects and properties.

0-based value initially set to indicate user is not versioning.

Referenced by Realm.GetInstance().