コード例 #1
0
		public SubscriptionResource(Subscription subscription, Publication publication, IEnumerable<string> categories, ExpiresList expiresList, uint expires)
        {
			this.proccessingSubscribe = true;
            this.Subscription = subscription;
            this.Publication = publication;
            this.SubsCategories = new List<string>(categories);
            this.expiresList = expiresList;
            this.expires = expires;
            this.tickCount = Environment.TickCount;

            this.Subscription.AddResource(this);
            this.Publication.AddResource(this);
            this.expiresList.AddResource(this);
        }
コード例 #2
0
		private Publication ResolvePublication(string uri)
		{
			Publication publication = FindPublication(uri);

			if (publication == null)
			{
				publication = new Publication(uri);
				this.publications.Add(publication.Uri, publication);
			}

			return publication;
		}
コード例 #3
0
        public void Process(BatchSubscribe batchSubs, ExpiresList expireList, uint expires, out Rlmi rlmi, out List <Categories> categories)
        {
            rlmi       = null;
            categories = null;

            if (batchSubs == null && expires == 0)
            {
                List <SubscriptionResource> resources = new List <SubscriptionResource>(Resources.Values);

                foreach (SubscriptionResource resource in resources)
                {
                    resource.Destroy();
                }
            }

            else if (batchSubs.Action == BatchSubscribeAction.Unsubscribe || expires == 0)
            {
                rlmi = Rlmi.Create(this.Uri);

                foreach (string uri in batchSubs.Resources)
                {
                    SubscriptionResource resource;

                    if (Resources.TryGetValue(uri, out resource))
                    {
                        resource.Destroy();
                    }
                }
            }

            else if (batchSubs.Action == BatchSubscribeAction.Subscribe && expires > 0)
            {
                rlmi       = Rlmi.Create(this.Uri);
                categories = new List <Categories>();

                foreach (string uri in batchSubs.Resources)
                {
                    SubscriptionResource resource;
                    if (Resources.TryGetValue(uri, out resource))
                    {
                        resource.SubsCategories = batchSubs.Сategories;
                        resource.Expires        = expires;
                    }
                    else
                    {
                        Publication publication = null;
                        if (ResolvePublicationEvent != null)
                        {
                            publication = ResolvePublicationEvent(uri);
                        }

                        if (publication != null)
                        {
                            resource = new SubscriptionResource(this, publication, batchSubs.Сategories, expireList, expires);
                        }
                        else
                        {
                            rlmi.AddResubscribe(uri);
                        }
                    }

                    if (resource != null)
                    {
                        categories.Add(
                            resource.EndSubscribeProccessing()
                            );
                    }
                }
            }
        }