예제 #1
0
        public TopicInfoArray Intersect(ArrayList topicInfoArrayToIntersect)
        {
            TopicInfoArray answer = new TopicInfoArray();
            this.Array.Sort(null);
            topicInfoArrayToIntersect.Sort(null);

            foreach(TopicVersionInfo topicInfo in this.Array)
            {
                if(topicInfoArrayToIntersect.BinarySearch(topicInfo) >= 0)
                {
                    if( answer.Array.BinarySearch(topicInfo) < 0 )
                    {
                        answer.Add(topicInfo);
                    }
                }
            }

            return answer;
        }
예제 #2
0
        public void TestDifference()
        {
            TopicInfoArray list = new TopicInfoArray();
            TopicInfoArray listToCompare = new TopicInfoArray();

            list.Add(new TopicVersionInfo(Federation, new QualifiedTopicRevision("topicName", "testnamespace")));
            list.Add(new TopicVersionInfo(Federation, new QualifiedTopicRevision("topic3", "testnamespace")));
            list.Add(new TopicVersionInfo(Federation, new QualifiedTopicRevision("topic1", "testnamespace")));
            list.Add(new TopicVersionInfo(Federation, new QualifiedTopicRevision("topic4", "testnamespace")));

            listToCompare.Add(new TopicVersionInfo(Federation, new QualifiedTopicRevision("topicName", "testnamespace")));
            listToCompare.Add(new TopicVersionInfo(Federation, new QualifiedTopicRevision("topic3", "testnamespace")));
            listToCompare.Add(new TopicVersionInfo(Federation, new QualifiedTopicRevision("topic1", "testnamespace")));
            listToCompare.Add(new TopicVersionInfo(Federation, new QualifiedTopicRevision("topic2", "testnamespace")));
            listToCompare.Add(new TopicVersionInfo(Federation, new QualifiedTopicRevision("topic5", "testnamespace")));
            listToCompare.Add(new TopicVersionInfo(Federation, new QualifiedTopicRevision("topic6", "testnamespace")));
            listToCompare.Add(new TopicVersionInfo(Federation, new QualifiedTopicRevision("topic7", "testnamespace")));

            Assert.AreEqual(1, list.Difference(listToCompare.Array).Count, "Comparing number of elements in list and listToCompare after Difference");
        }
예제 #3
0
		private TopicInfoArray RetrieveAllTopicsWith(string property, string desiredValue, bool includeImports)
		{
			// First, get all topics that have the property at all -- that's the hard work talking to the store
			TopicInfoArray all = Federation.CacheManager.GetTopicsWithProperty(property);
			if (all == null)
			{
				all = new TopicInfoArray();
				foreach (AbsoluteTopicName topic in AllTopics(true))
				{
					if (this.Federation.GetTopicProperty(topic, property) != "")
					{
						all.Add(new TopicInfo(Federation, topic));
					}
				}
				Federation.CacheManager.PutCachedTopicsWithProperty(property, all, new PropertyCacheRule(this.Federation, property));
			}

			// OK.  Now we've got the baseline set (and it's cached for future use).  Now filter out if needed based on desiredValue and includeImports
			if (desiredValue == null && includeImports)
				return all;	// quick exit -- no filtering needed

			TopicInfoArray answer = new TopicInfoArray();
			for (int i = 0; i < all.Count; i++)
			{
				TopicInfo each = (TopicInfo)(all.Item(i));
				if (!includeImports && (each.Fullname.Namespace != Namespace))
					continue;
				if (desiredValue == null)
				{
					answer.Add(each);
					continue;
				}
				object propertyValue = Federation.GetTopicProperty(each.Fullname, property);
				if (propertyValue == null)
					continue;
				if (((string)(propertyValue)).ToLower() != desiredValue.ToLower())
					continue;
				answer.Add(each);
			}
			return answer;
		}
예제 #4
0
        }///// <summary>
        ///// Write a new version of the topic (doesn't write a new version).  Generate all needed federation update changes via the supplied generator.
        ///// </summary>
        ///// <param name="topic">Topic to write</param>
        ///// <param name="content">New content</param>
        ///// <param name="sink">Object to recieve change info about the topic</param>
        //private void WriteTopic(LocalTopicName topic, string content, FederationUpdateGenerator gen)
        //{
        //}
        private TopicInfoArray RetrieveAllTopicsWith(string propertyName, string desiredValue, ImportPolicy importPolicy)
        {
            TopicInfoArray topicInfos = new TopicInfoArray();
            foreach (QualifiedTopicName namespaceQualifiedTopicName in AllTopics(importPolicy))
            {
                TopicProperty property = Federation.GetTopicProperty(namespaceQualifiedTopicName, 
                    propertyName);

                if (property != null)
                {
                    if (property.HasValue)
                    {
                        foreach (TopicPropertyValue propertyValue in property.Values)
                        {
                            string value = propertyValue.RawValue; 
                            if (desiredValue == null || (0 == String.Compare(desiredValue, value, true)))
                            {
                                topicInfos.Add(new TopicVersionInfo(this.Federation,
                                    new QualifiedTopicRevision(namespaceQualifiedTopicName)));
                                break;
                            }
                        }
                    }
                }
            }

            return topicInfos;

        }
예제 #5
0
		public void PutCachedTopicsWithProperty(string propertyName, TopicInfoArray val, CacheRule rule)
		{
			string key = KeyForProperty(propertyName);
			Put(key, val, rule);
			rule.SetupInvalidation(this, key);
		}