/// <summary> /// Returns a list of all topics in the namespace, sorted using the specified comparison. /// </summary> /// <param name="importPolicy">Indicates whether topics in imported namespaces /// should be included in the details.</param> /// <param name="sortCriterion">A <see cref="Comparision>QualifiedTopicName<"/> to use to /// sort the output, or null not to sort.</param> /// <returns>A (potentially sorted) list of <see cref="QualifiedTopicName"/> objects.</returns> /// <remarks>Order is not guaranteed in the absence of a sortCriteria.</remarks> public QualifiedTopicNameCollection AllTopics(ImportPolicy importPolicy, Comparison<QualifiedTopicName> sortCriterion) { QualifiedTopicNameCollection answer = new QualifiedTopicNameCollection(); QualifiedTopicNameCollection unsortedTopics = ContentProviderChain.AllTopics(); answer.AddRange(unsortedTopics); if (importPolicy == ImportPolicy.IncludeImports) { foreach (NamespaceManager namespaceManager in ImportedNamespaceManagers) { answer.AddRange(namespaceManager.AllTopics(ImportPolicy.DoNotIncludeImports)); } } if (sortCriterion != null) { answer.Sort(sortCriterion); } return answer; }
/// <summary> /// Answer the DateTime of when any of the topics in the ContentProviderChain where last modified. /// </summary> /// <param name="includeImports">true if you also want to include all imported namespaces</param> /// <returns></returns> public DateTime LastModified(ImportPolicy importPolicy) { DateTime lastModified = DateTime.MinValue; foreach (TopicName topic in AllTopics(importPolicy)) { DateTime modified = Federation.GetTopicLastModificationTime(topic); if (modified > lastModified) { lastModified = modified; } } return lastModified; }
}///// <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; }
/// <summary> /// Answer an (unsorted) enumeration of all topic in the ContentProviderChain (possibly including those in imported namespaces, too) /// </summary> /// <param name="importPolicy">Indicates whether topics in imported namespaces /// should be included in the details.</param> /// <returns>A collection of <see cref="QualifiedTopicName" /> objects.</returns> public QualifiedTopicNameCollection AllTopics(ImportPolicy importPolicy) { return AllTopics(importPolicy, null); }
/// <summary> /// Answer true if the given topic exists in this namespace or in an imported namespace (if it's relative), or in the given namespace (if it's qualified) /// </summary> /// <param name="topic">The topic to check for</param> /// <returns>true if the topic exists</returns> /// <remarks>importPolicy is ignored if the topic name is qualified.</remarks> public bool TopicExists(TopicRevision topic, ImportPolicy importPolicy) { if (topic.IsQualified) { return Federation.TopicExists(new QualifiedTopicRevision(topic.LocalName, topic.Namespace)); } else { return TopicExists(topic.LocalName, importPolicy); } }
public bool TopicExists(UnqualifiedTopicName topic, ImportPolicy importPolicy) { bool existsLocally = ContentProviderChain.TopicExists(topic); if (importPolicy == ImportPolicy.DoNotIncludeImports) { return existsLocally; } else { if (existsLocally) { return true; } else { foreach (NamespaceManager importedManager in ImportedNamespaceManagers) { if (importedManager.TopicExists(topic, ImportPolicy.DoNotIncludeImports)) { return true; } } } return false; } }
public bool TopicExists(string topic, ImportPolicy importPolicy) { return TopicExists(new UnqualifiedTopicName(topic), importPolicy); }
/// <summary> /// Returns a list of all topics in the namespace, sorted using the specified comparison. /// </summary> /// <param name="importPolicy">Indicates whether topics in imported namespaces /// should be included in the details.</param> /// <param name="sortCriterion">A <see cref="Comparision>QualifiedTopicName<"/> to use to /// sort the output, or null not to sort.</param> /// <returns>A (potentially sorted) list of <see cref="QualifiedTopicName"/> objects.</returns> /// <remarks>Order is not guaranteed in the absence of a sortCriteria.</remarks> public QualifiedTopicNameCollection AllTopics(ImportPolicy importPolicy, Comparison<QualifiedTopicName> sortCriterion) { return AllTopics(importPolicy, sortCriterion, null); }
// Internal methods internal QualifiedTopicNameCollection AllQualifiedTopicNamesThatExist(string topicName, ImportPolicy importPolicy) { QualifiedTopicNameCollection answer = new QualifiedTopicNameCollection(); if (TopicExists(topicName, ImportPolicy.DoNotIncludeImports)) { answer.Add(QualifiedTopicNameFor(topicName)); } if (importPolicy == ImportPolicy.IncludeImports) { foreach (NamespaceManager manager in ImportedNamespaceManagers) { if (manager.TopicExists(topicName, ImportPolicy.DoNotIncludeImports)) { answer.Add(manager.QualifiedTopicNameFor(topicName)); } } } return answer; }