Exemple #1
0
        /// <summary>
        /// For Realms using query-based synchronization, fetches and synchronizes the objects that match the query.
        /// </summary>
        /// <typeparam name="T">The type of the objects making up the query.</typeparam>
        /// <param name="query">
        /// A query, obtained by calling <see cref="Realm.All{T}"/> with or without additional filtering applied.
        /// </param>
        /// <param name="options">
        /// Options that configure some metadata of the subscription, such as its name or time to live.
        /// </param>
        /// <param name="includedBacklinks">
        /// An array of property expressions which specifies which linkingObjects relationships should be included in
        /// the subscription. Subscriptions already include link and list properties (in the forward direction)
        /// automatically by default.
        /// </param>
        /// <returns>
        /// A <see cref="Subscription{T}"/> instance that contains information and methods for monitoring
        /// the state of the subscription.
        /// </returns>
        /// <exception cref="ArgumentNullException">Thrown if <c>query</c> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">
        /// Thrown if the <c>query</c> was not obtained from a query-based synchronized Realm.
        /// </exception>
        public static Subscription <T> Subscribe <T>(
            this IQueryable <T> query,
            SubscriptionOptions options = null,
            params Expression <Func <T, IQueryable> >[] includedBacklinks)
        {
            Argument.NotNull(query, nameof(query));

            var results = query as RealmResults <T>;

            Argument.Ensure(results != null, $"{nameof(query)} must be an instance of IRealmCollection<{typeof(T).Name}>.", nameof(query));

            options = options ?? new SubscriptionOptions();

            var syncConfig = results.Realm.Config as SyncConfigurationBase;

            Argument.Ensure(syncConfig?.IsFullSync == false, $"{nameof(query)} must be obtained from a synchronized Realm using query-based synchronization.", nameof(query));

            var handle = SubscriptionHandle.Create(
                results.ResultsHandle,
                options.Name,
                (long?)options.TimeToLive?.TotalMilliseconds,
                options.ShouldUpdate,
                includedBacklinks.ToStringPaths());

            return(new Subscription <T>(handle, results));
        }
Exemple #2
0
        /// <summary>
        /// For Realms using query-based synchronization, fetches and synchronizes the objects that match the query.
        /// </summary>
        /// <typeparam name="T">The type of the objects making up the query.</typeparam>
        /// <param name="query">
        /// A query, obtained by calling <see cref="Realm.All{T}"/> with or without additional filtering applied.
        /// </param>
        /// <param name="name">The name of this query that can be used to unsubscribe from.</param>
        /// <returns>
        /// A <see cref="Subscription{T}"/> instance that contains information and methods for monitoring
        /// the state of the subscription.
        /// </returns>
        /// <exception cref="ArgumentNullException">Thrown if <c>query</c> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">
        /// Thrown if the <c>query</c> was not obtained from a query-based synchronized Realm.
        /// </exception>
        public static Subscription <T> Subscribe <T>(this IQueryable <T> query, string name = null)
        {
            Argument.NotNull(query, nameof(query));

            var results = query as RealmResults <T>;

            Argument.Ensure(results != null, $"{nameof(query)} must be an instance of IRealmCollection<{typeof(T).Name}>.", nameof(query));

            var syncConfig = results.Realm.Config as SyncConfigurationBase;

            Argument.Ensure(syncConfig?.IsFullSync == false, $"{nameof(query)} must be obtained from a synchronized Realm using query-based synchronization.", nameof(query));

            var handle = SubscriptionHandle.Create(results.ResultsHandle, name);

            return(new Subscription <T>(handle, results));
        }
 public SubscriptionTokenHandle(SubscriptionHandle root, IntPtr handle) : base(root, handle)
 {
     // We save this because RealmHandle doesn't support a parent chain like
     // SubscriptionToken -> Subscription -> Realm
     _subscriptionHandle = root;
 }
Exemple #4
0
 public static extern void unsubscribe(SubscriptionHandle subscription, out NativeException ex);
Exemple #5
0
 public static extern IntPtr add_notification_callback(SubscriptionHandle subscription, IntPtr managedSubscriptionHandle, SubscriptionCallbackDelegate callback, out NativeException ex);
Exemple #6
0
 public static extern NativeException get_error(SubscriptionHandle subscription);
Exemple #7
0
 public static extern sbyte get_state(SubscriptionHandle subscription, out NativeException ex);
 public SubscriptionTokenHandle(SubscriptionHandle root, IntPtr handle) : base(root, handle)
 {
 }