Ejemplo n.º 1
0
        /// <summary>
        /// Opens the <see cref="AppStoreClient" /> instance so that it is ready to
        /// process requests.
        /// </summary>
        /// <param name="router">The <see cref="MsgRouter" /> to be associated with the client.</param>
        /// <param name="settings">The <see cref="AppStoreClientSettings" /> to be used.</param>
        /// <exception cref="InvalidOperationException">Thrown if the instance is already open.</exception>
        public void Open(MsgRouter router, AppStoreClientSettings settings)
        {
            if (this.syncLock != null)
            {
                throw new InvalidOperationException("AppStoreClient is already open.");
            }

            // Make sure that the LillTek.Datacenter message types have been
            // registered with the LillTek.Messaging subsystem.

            LillTek.Datacenter.Global.RegisterMsgTypes();

            // Initialize

            using (TimedLock.Lock(router.SyncRoot))
            {
                this.syncLock      = router.SyncRoot;
                this.router        = router;
                this.settings      = settings;
                this.bkTimer       = new GatedTimer(new System.Threading.TimerCallback(OnBkTimer), null, settings.BkTaskInterval);
                this.nextPurgeTime = SysTime.Now;

                if (settings.LocalCache)
                {
                    this.packageFolder = new AppPackageFolder(syncLock, settings.PackageFolder);
                }
                else
                {
                    this.packageFolder = null;
                }

                router.Dispatcher.AddTarget(this);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Releases all resources associated with the instance.
        /// </summary>
        public void Close()
        {
            using (TimedLock.Lock(syncLock))
            {
                if (syncLock == null)
                {
                    return;
                }

                router.Dispatcher.RemoveTarget(this);

                if (packageFolder != null)
                {
                    packageFolder.Dispose();
                    packageFolder = null;
                }

                if (bkTimer != null)
                {
                    bkTimer.Dispose();
                    bkTimer = null;
                }

                router   = null;
                syncLock = null;
            }
        }
Ejemplo n.º 3
0
        private DateTime nextPurgeTime;                     // Next scheduled package folder purge time (SYS)

        /// <summary>
        /// Constructor.
        /// </summary>
        public AppStoreClient()
        {
            this.syncLock      = null;
            this.router        = null;
            this.packageFolder = null;
            this.bkTimer       = null;
        }