Class converting Context objects to string ant the other way.
        /// <summary>
        /// Subscribe to project level notifications - will get all notifications in contained collections.
        /// <remarks>User API key usage permitted with context session or connection if subscribe permission is added through apikey.authorize() and read_data permission is added to specified project through project.authorize().</remarks>
        /// </summary>
        /// <param name="projectId">Project id.</param>
        /// <param name="context">Context to subscribe within.</param>
        /// <returns>Boolen value indicating success of method.</returns>
        public Task <bool> SubscribeProject(string projectId, Context context = Context.Client)
        {
            if (projectId == null)
            {
                throw new ArgumentNullException();
            }

            return(_syncanoClient.GetAsync("subscription.subscribe_project",
                                           new { project_id = projectId, context = ContextEnumStringConverter.GetString(context) }));
        }
        /// <summary>
        /// Subscribe to collection level notifications within a specified project.
        /// <remarks>Collection_id/collection_key parameter means that one can use either one of them - collection_id or collection_key.</remarks>
        /// <remarks>User API key usage permitted with context session or connection if subscribe permission is added through apikey.authorize() and read_data permission is added to specified collection through collection.authorize() or project.authorize().</remarks>
        /// </summary>
        /// <param name="projectId">Project id.</param>
        /// <param name="collectionId">Collection id defining collection.</param>
        /// <param name="collectionKey">Collection key defining collection.</param>
        /// <param name="context">Context to subscribe within. </param>
        /// <returns>Boolen value indicating success of method.</returns>
        public Task <bool> SubscribeCollection(string projectId, string collectionId = null, string collectionKey = null,
                                               Context context = Context.Client)
        {
            if (projectId == null)
            {
                throw new ArgumentNullException();
            }

            if (collectionId == null && collectionKey == null)
            {
                throw new ArgumentNullException();
            }

            return(_syncanoClient.GetAsync("subscription.subscribe_collection",
                                           new
            {
                project_id = projectId,
                collection_id = collectionId,
                collection_key = collectionKey,
                context = ContextEnumStringConverter.GetString(context)
            }));
        }
Exemplo n.º 3
0
        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            var context = (Context)value;

            writer.WriteValue(ContextEnumStringConverter.GetString(context));
        }
Exemplo n.º 4
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            var enumString = (string)reader.Value;

            return(ContextEnumStringConverter.GetContext(enumString));
        }