Example #1
0
        internal RealmObject MakeObjectForRow(RealmObject.Metadata metadata, RowHandle row)
        {
            RealmObject ret = metadata.Helper.CreateInstance();

            ret._Manage(this, row, metadata);
            return(ret);
        }
Example #2
0
 internal RealmObject MakeObject(RealmObject.Metadata metadata, ObjectHandle objectHandle)
 {
     var ret = metadata.Helper.CreateInstance();
     ret._SetOwner(this, objectHandle, metadata);
     ret.OnManaged();
     return ret;
 }
Example #3
0
        private RealmObject CreateObject(string className, object primaryKey, out RealmObject.Metadata metadata)
        {
            if (!Metadata.TryGetValue(className, out metadata))
            {
                throw new ArgumentException($"The class {className} is not in the limited set of classes for this realm");
            }

            var result = metadata.Helper.CreateInstance();

            ObjectHandle objectHandle;
            var          pkProperty = metadata.Schema.PrimaryKeyProperty;

            if (pkProperty.HasValue)
            {
                objectHandle = SharedRealmHandle.CreateObjectWithPrimaryKey(pkProperty.Value, primaryKey, metadata.Table, className, update: false, isNew: out var _);
            }
            else
            {
                objectHandle = SharedRealmHandle.CreateObject(metadata.Table);
            }

            result._SetOwner(this, objectHandle, metadata);
            result.OnManaged();
            return(result);
        }
Example #4
0
 internal RealmResults(Realm realm, RealmResultsProvider realmResultsProvider, Expression expression, RealmObject.Metadata metadata, bool createdByAll)
 {
     _realm          = realm;
     _provider       = realmResultsProvider;
     Expression      = expression ?? Expression.Constant(this);
     _targetMetadata = metadata;
     _allRecords     = createdByAll;
 }
Example #5
0
        private RealmObject CreateObject(string className, out RealmObject.Metadata metadata)
        {
            if (!Metadata.TryGetValue(className, out metadata))
            {
                throw new ArgumentException($"The class {className} is not in the limited set of classes for this realm");
            }

            var result = metadata.Helper.CreateInstance();

            var objectPtr = metadata.Table.AddEmptyObject(SharedRealmHandle);
            var objectHandle = CreateObjectHandle(objectPtr, SharedRealmHandle);
            result._SetOwner(this, objectHandle, metadata);
            result.OnManaged();
            return result;
        }
Example #6
0
        private RealmObject CreateObject(string className, out RealmObject.Metadata metadata)
        {
            if (!IsInTransaction)
            {
                throw new RealmOutsideTransactionException("Cannot create Realm object outside write transactions");
            }

            if (!Metadata.TryGetValue(className, out metadata))
            {
                throw new ArgumentException($"The class {className} is not in the limited set of classes for this realm");
            }

            var result = metadata.Helper.CreateInstance();

            var rowPtr    = NativeTable.AddEmptyRow(metadata.Table);
            var rowHandle = CreateRowHandle(rowPtr, SharedRealmHandle);

            result._Manage(this, rowHandle, metadata);
            return(result);
        }
        internal ThreadSafeReference(IThreadConfined value, Type type)
        {
            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }

            if (!value.IsManaged)
            {
                throw new RealmException("Cannot construct reference to unmanaged object, which can be passed across threads directly.");
            }

            if (!value.IsValid)
            {
                throw new RealmException("Cannot construct reference to invalidated object.");
            }

            Handle        = value.Handle.GetThreadSafeReference();
            Metadata      = value.Metadata;
            ReferenceType = type;
        }
Example #8
0
 internal RealmResults(Realm realm, RealmObject.Metadata metadata, ResultsHandle handle = null)
     : this(realm, metadata, new RealmResultsProvider(realm, metadata), null)
 {
     _handle = handle ?? metadata.Table.CreateResults(realm.SharedRealmHandle);
 }
Example #9
0
 internal RealmList(Realm realm, ListHandle adoptedList, RealmObject.Metadata metadata) : base(realm, metadata)
 {
     _realm      = realm;
     _listHandle = adoptedList;
 }
Example #10
0
 internal RealmObject MakeObject(RealmObject.Metadata metadata, IntPtr objectPtr)
 {
     return(MakeObject(metadata, CreateObjectHandle(objectPtr, SharedRealmHandle)));
 }
Example #11
0
        internal ResultsHandle MakeResultsForTable(RealmObject.Metadata metadata)
        {
            var resultsPtr = metadata.Table.CreateResults(SharedRealmHandle);

            return(CreateResultsHandle(resultsPtr));
        }
Example #12
0
 internal RealmResults(Realm realm, RealmResultsProvider realmResultsProvider, Expression expression, RealmObject.Metadata metadata, bool createdByAll) : base(realm, metadata)
 {
     _provider   = realmResultsProvider;
     Expression  = expression ?? Expression.Constant(this);
     _allRecords = createdByAll;
 }
Example #13
0
 internal RealmResults(Realm realm, RealmObject.Metadata metadata, bool createdByAll)
     : this(realm, new RealmResultsProvider(realm, metadata), null, metadata, createdByAll)
 {
 }
Example #14
0
 internal RealmResults(Realm realm, RealmObject.Metadata metadata, ResultsHandle handle = null)
     : this(realm, metadata, new RealmResultsProvider(realm, metadata), null)
 {
     _handle = handle ?? realm.MakeResultsForTable(metadata);
 }
Example #15
0
 internal RealmResults(Realm realm, RealmObject.Metadata metadata, RealmResultsProvider realmResultsProvider, Expression expression) : base(realm, metadata)
 {
     Provider   = realmResultsProvider;
     Expression = expression ?? Expression.Constant(this);
 }
Example #16
0
 internal RealmList(Realm realm, LinkListHandle adoptedList, RealmObject.Metadata metadata)
 {
     _realm          = realm;
     _listHandle     = adoptedList;
     _targetMetadata = metadata;
 }
Example #17
0
 protected RealmCollectionBase(Realm realm, RealmObject.Metadata metadata)
 {
     Realm    = realm;
     Handle   = new Lazy <CollectionHandleBase>(CreateHandle);
     Metadata = metadata;
 }
Example #18
0
 internal SortDescriptorBuilder CreateSortDescriptorForTable(RealmObject.Metadata metadata)
 {
     return(new SortDescriptorBuilder(metadata));
 }
Example #19
0
 internal RealmResults(Realm realm, ResultsHandle handle, RealmObject.Metadata metadata)
     : this(realm, new RealmResultsProvider(realm, metadata), null, metadata, false)
 {
     _handle = handle;
 }
Example #20
0
 internal RealmObject MakeObjectForRow(RealmObject.Metadata metadata, IntPtr rowPtr)
 {
     return(MakeObjectForRow(metadata, CreateRowHandle(rowPtr, SharedRealmHandle)));
 }
 internal RealmResultsVisitor(Realm realm, RealmObject.Metadata metadata)
 {
     _realm    = realm;
     _metadata = metadata;
 }
 internal RealmResultsProvider(Realm realm, RealmObject.Metadata metadata)
 {
     _realm    = realm;
     _metadata = metadata;
 }