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.
Namespace: Realms.Schema
Assembly: Realm.dll
Syntax
public class RealmSchema : IReadOnlyCollection<ObjectSchema>, IEnumerable<ObjectSchema>, IEnumerable
Remarks
By default this will be all the RealmObjects and EmbeddedObjects 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.
Properties
| Improve this Doc View SourceCount
Gets the number of known classes in the schema.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
Int32 | The number of known classes. |
Methods
| Improve this Doc 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. |
Find(String)
Finds the definition of a class in this schema.
Declaration
[Obsolete("This method is obsolete. Use TryFindObjectSchema instead.")]
public ObjectSchema Find(string name)
Parameters
Type | Name | Description |
---|---|---|
String | name | A valid class name which may be in this schema. |
Returns
Type | Description |
---|---|
ObjectSchema | An ObjectSchema or |
Exceptions
Type | Condition |
---|---|
ArgumentException | Thrown if a name is not supplied. |
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 |
---|---|
Boolean |
|
Exceptions
Type | Condition |
---|---|
ArgumentException | Thrown if a name is not supplied. |
Operators
| Improve this Doc View SourceImplicit(ObjectSchema[] to RealmSchema)
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(RealmSchema.Builder to RealmSchema)
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(HashSet<Type> to RealmSchema)
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
| Improve this Doc View SourceImplicit(List<ObjectSchema> to RealmSchema)
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(List<Type> to RealmSchema)
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
| Improve this Doc View SourceImplicit(Type[] to RealmSchema)
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 |
|