Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance.
        /// </summary>
        /// <param name="state"></param>
        public ActivityActorInstanceStore(ActivityActorStateManager state)
        {
            Contract.Requires <ArgumentNullException>(state != null);

            this.state      = state;
            this.serializer = new NetDataContractSerializer(new StreamingContext(StreamingContextStates.All), int.MaxValue, false, FormatterAssemblyStyle.Full, new ActivitySurrogateSelector());
        }
        /// <summary>
        /// Creates a new <see cref="ActivityActorStateManager"/>.
        /// </summary>
        Task CreateStateManager()
        {
            state = new ActivityActorStateManager(this);

            state.Persisted = () =>
            {
                pump.Enqueue(async() =>
                {
                    await state.SaveAsync();
                    await SaveReminderAsync();
                    await actor.OnPersistedAsync();
                });
            };

            state.Completed = () =>
            {
                pump.Enqueue(async() =>
                {
                    await state.SaveAsync();
                    await SaveReminderAsync();
                });
            };

            return(Task.FromResult(true));
        }