예제 #1
0
        public RegisterChangeNotifications(IDataChangeNotification notifications)
        {
            var target = typeof(TSource);

            if (target.IsGenericType && target.GetGenericTypeDefinition() == typeof(Lazy <>))
            {
                target = target.GetGenericArguments()[0];
                if (target.IsArray)
                {
                    target = target.GetElementType();
                    dynamic cn = Activator.CreateInstance(typeof(ChangeNotifications <>).MakeGenericType(target), new object[] { notifications });
                    Register           = cn.SubscribeBulk;
                    ChangeNotification = cn;
                }
                else
                {
                    dynamic cn = Activator.CreateInstance(typeof(ChangeNotifications <>).MakeGenericType(target), new object[] { notifications });
                    Register           = cn.SubscribeLazy;
                    ChangeNotification = cn;
                }
            }
            else
            {
                var cn = new ChangeNotifications <TSource>(notifications);
                Register           = cn.SubscribeEager;
                ChangeNotification = cn;
            }
        }
예제 #2
0
        public IObservable <NotifyInfo> Track <T>() where T : IIdentifiable
        {
            if (Changes == null)
            {
                Changes = Locator.Resolve <IDataChangeNotification>();
            }
            var name = typeof(T).FullName;

            return(Changes.Notifications.Where(ni => ni.Name == name));
        }
예제 #3
0
        public LookupCache(
            IRepository <TValue> repository,
            IDataChangeNotification notifications)
        {
            Contract.Requires(repository != null);
            Contract.Requires(notifications != null);

            this.Repository = repository;
            Subscription    = notifications.Notifications.Subscribe(CheckInvalidate);
        }
예제 #4
0
		public QueueProcessor(
			IMailService mailService,
			IQueryableRepository<IMailMessage> repository,
			IDataChangeNotification changeNotification)
		{
			Contract.Requires(mailService != null);
			Contract.Requires(repository != null);
			Contract.Requires(changeNotification != null);

			this.MailService = mailService;
			this.Repository = repository;
			this.ChangeNotification = changeNotification;
		}
예제 #5
0
        public LazyCache(
            IQueryableRepository <TValue> repository,
            IDataChangeNotification notifications)
        {
            Contract.Requires(repository != null);
            Contract.Requires(notifications != null);

            this.Repository = repository;

            Subscription = notifications.Notifications.Subscribe(Synchronize);
            Data         = new Dictionary <string, TValue>();
            Invalid      = true;
        }
예제 #6
0
        public QueueProcessor(
            IMailService mailService,
            IQueryableRepository <IMailMessage> repository,
            IDataChangeNotification changeNotification)
        {
            Contract.Requires(mailService != null);
            Contract.Requires(repository != null);
            Contract.Requires(changeNotification != null);

            this.MailService        = mailService;
            this.Repository         = repository;
            this.ChangeNotification = changeNotification;
        }
예제 #7
0
        public SingleDomainEventSource(IDataChangeNotification notifications)
        {
            Contract.Requires(notifications != null);

            Subscription =
                notifications.Track <TEvent>().Subscribe(kv =>
            {
                foreach (var ev in kv.Value.Value)
                {
                    Subject.OnNext(ev);
                }
            });
            Events = Subject.AsObservable();
        }
예제 #8
0
        public QueueProcessor(
            IMailService mailService,
            IQueryableRepository<IMailMessage> repository,
            IDataChangeNotification changeNotification,
            ILogFactory logFactory)
        {
            Contract.Requires(mailService != null);
            Contract.Requires(repository != null);
            Contract.Requires(changeNotification != null);
            Contract.Requires(logFactory != null);

            this.MailService = mailService;
            this.Repository = repository;
            this.ChangeNotification = changeNotification;
            this.Logger = logFactory.Create("Mail Queue processor");
        }
예제 #9
0
        public QueueProcessor(
            IMailService mailService,
            IQueryableRepository <IMailMessage> repository,
            IDataChangeNotification changeNotification,
            ILogFactory logFactory)
        {
            Contract.Requires(mailService != null);
            Contract.Requires(repository != null);
            Contract.Requires(changeNotification != null);
            Contract.Requires(logFactory != null);

            this.MailService        = mailService;
            this.Repository         = repository;
            this.ChangeNotification = changeNotification;
            this.Logger             = logFactory.Create("Mail Queue processor");
        }
예제 #10
0
        public ChangeNotifications(IDataChangeNotification notifications)
        {
            Subscription = notifications.Track <TSource>().Subscribe(kv => Subject.OnNext(kv));
            var source = Subject.AsObservable();

            BulkChanges = source.Select(it => it.Value);
            LazyChanges =
                from it in source
                let lazy = it.Value
                           from i in Enumerable.Range(0, it.Key.Length)
                           select new Lazy <TSource>(() => lazy.Value[i]);

            EagerChanges =
                from it in source
                from v in it.Value.Value
                select v;
        }
예제 #11
0
        public EagerCache(
            IRepository <TValue> lookup,
            IQueryableRepository <TValue> repository,
            IDataChangeNotification notifications)
        {
            Contract.Requires(lookup != null);
            Contract.Requires(repository != null);
            Contract.Requires(notifications != null);

            this.Lookup     = lookup;
            this.Repository = repository;

            Subscription = notifications.Notifications.Subscribe(Synchronize);
            var found = repository.Search();

            Data = new ConcurrentDictionary <string, TValue>(1, found.Length);
            foreach (var f in found)
            {
                Data.TryAdd(f.URI, f);
            }
        }