Class RealmSchema
Describes the complete set of classes which may be stored in a Realm, either from assembly declarations or,
dynamically, by evaluating a Realm from disk. To construct a new RealmSchema instance, use the
RealmSchema.Builder API.
By default this will be all the IRealmObjects, IEmbeddedObjects and IAsymmetricObjects
in all your assemblies. Unless you restrict with Schema. Just because a given class may
be stored in a Realm doesn't imply much overhead. There will be a small amount of metadata but objects only start to
take up space once written.
Namespace: Realms.Schema
Assembly: Realm.dll
Syntax
public class RealmSchema : IReadOnlyCollection<ObjectSchema>, IEnumerable<ObjectSchema>, IEnumerable
Properties
| Edit this page View SourceCount
Gets the number of known classes in the schema.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
int | The number of known classes. |
Methods
| Edit this page View SourceAddDefaultTypes(IEnumerable<Type>)
Adds a collection of types to the default schema.
Declaration
public static void AddDefaultTypes(IEnumerable<Type> types)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<Type> | types | Types to be added to the default schema. |
Exceptions
Type | Condition |
---|---|
NotSupportedException | Thrown if the schema has already materialized. |
GetBuilder()
Create a mutable RealmSchema.Builder containing the object schemas in this Realm schema.
Declaration
public RealmSchema.Builder GetBuilder()
Returns
Type | Description |
---|---|
RealmSchema.Builder | A RealmSchema.Builder instance that can be used to mutate the schema and eventually produce a new one by calling Build(). |
TryFindObjectSchema(string, out ObjectSchema)
Attempts to find the definition of a class in this schema.
Declaration
public bool TryFindObjectSchema(string name, out ObjectSchema schema)
Parameters
Type | Name | Description |
---|---|---|
string | name | A valid class name which may be in this schema. |
ObjectSchema | schema | The schema corresponding to the provided |
Returns
Type | Description |
---|---|
bool |
|
Exceptions
Type | Condition |
---|---|
ArgumentException | Thrown if a name is not supplied. |
Operators
| Edit this page View Sourceimplicit operator RealmSchema?(ObjectSchema[]?)
Constructs a RealmSchema from an array of ObjectSchema instances.
Declaration
public static implicit operator RealmSchema?(ObjectSchema[]? objects)
Parameters
Type | Name | Description |
---|---|---|
ObjectSchema[] | objects | The object schemas that will be contained in the newly constructed RealmSchema. |
Returns
Type | Description |
---|---|
RealmSchema |
|
Exceptions
Type | Condition |
---|---|
ArgumentException | Thrown if the array contains multiple ObjectSchema instances with the same Name. |
implicit operator RealmSchema?(Builder?)
A convenience operator to construct a RealmSchema from a RealmSchema.Builder by calling the Build() method.
Declaration
public static implicit operator RealmSchema?(RealmSchema.Builder? builder)
Parameters
Type | Name | Description |
---|---|---|
RealmSchema.Builder | builder | The builder that describes the newly created schema. |
Returns
Type | Description |
---|---|
RealmSchema |
|
implicit operator RealmSchema?(HashSet<Type>?)
Constructs a RealmSchema from a HashSet of Type instances.
Declaration
public static implicit operator RealmSchema?(HashSet<Type>? objects)
Parameters
Type | Name | Description |
---|---|---|
HashSet<Type> | objects | The Types that will be converted to ObjectSchema and added to the resulting RealmSchema. |
Returns
Type | Description |
---|---|
RealmSchema |
|
See Also
| Edit this page View Sourceimplicit operator RealmSchema?(List<ObjectSchema>?)
Constructs a RealmSchema from a list of ObjectSchema instances.
Declaration
public static implicit operator RealmSchema?(List<ObjectSchema>? objects)
Parameters
Type | Name | Description |
---|---|---|
List<ObjectSchema> | objects | The object schemas that will be contained in the newly constructed RealmSchema. |
Returns
Type | Description |
---|---|
RealmSchema |
|
Exceptions
Type | Condition |
---|---|
ArgumentException | Thrown if the list contains multiple ObjectSchema instances with the same Name. |
implicit operator RealmSchema?(List<Type>?)
Constructs a RealmSchema from a List of Type instances.
Declaration
public static implicit operator RealmSchema?(List<Type>? objects)
Parameters
Type | Name | Description |
---|---|---|
List<Type> | objects | The Types that will be converted to ObjectSchema and added to the resulting RealmSchema. |
Returns
Type | Description |
---|---|
RealmSchema |
|
See Also
| Edit this page View Sourceimplicit operator RealmSchema?(Type[]?)
Constructs a RealmSchema from an array of Type instances.
Declaration
public static implicit operator RealmSchema?(Type[]? objects)
Parameters
Type | Name | Description |
---|---|---|
Type[] | objects | The Types that will be converted to ObjectSchema and added to the resulting RealmSchema. |
Returns
Type | Description |
---|---|
RealmSchema |
|