コード例 #1
0
        private MockTopic GetTopic(string topicName, ExistencePolicy existencePolicy)
        {
            if (!_topics.Contains(topicName))
            {
                return null;
            }

            MockTopic topic = _topics[topicName];

            if (topic.IsDeleted && existencePolicy == ExistencePolicy.ExistingOnly)
            {
                return null;
            }

            return topic;
        }
コード例 #2
0
 private IEnumerable<MockTopic> AllTopics(ExistencePolicy existencePolicy)
 {
     foreach (MockTopic topic in _topics)
     {
         if (existencePolicy == ExistencePolicy.All || topic.IsDeleted == false)
         {
             yield return topic;
         }
     }
 }
コード例 #3
0
 private MockTopic GetTopic(UnqualifiedTopicName topicName, ExistencePolicy existencePolicy)
 {
     return GetTopic(topicName.LocalName, existencePolicy);
 }
コード例 #4
0
ファイル: NamespaceManager.cs プロジェクト: nuxleus/flexwiki
        /// <summary>
        /// Returns a list of all references from all topics in this namespace. 
        /// </summary>
        /// <param name="includeImports">Indicates whether topics should be filtered only
        /// to those that actually exist.</param>
        /// <returns>A map of topic names to the list of topics they reference.</returns>
        public ReferenceMap GetReferenceMap(ExistencePolicy existencePolicy)
        {
            ReferenceMap map = new ReferenceMap();

            foreach (TopicName topicName in AllTopics(ImportPolicy.DoNotIncludeImports))
            {
                map[topicName.LocalName] = AllReferencesByTopic(topicName.LocalName, existencePolicy);
            }

            return map;
        }
コード例 #5
0
ファイル: NamespaceManager.cs プロジェクト: nuxleus/flexwiki
        public QualifiedTopicRevisionCollection AllReferencesByTopic(UnqualifiedTopicName referencingTopic, ExistencePolicy existencePolicy)
        {
            if (referencingTopic == null)
            {
                throw new ArgumentNullException("referencingTopic");
            }

            TopicRevisionCollection references = ContentProviderChain.GetParsedTopic(new UnqualifiedTopicRevision(referencingTopic.LocalName)).TopicLinks;

            // In-scope namespaces include this namespace and every imported namespace.
            IList<string> inScopeNamespaces = new List<string>();
            inScopeNamespaces.Add(Namespace);
            foreach (string importedNamespace in ImportedNamespaces)
            {
                inScopeNamespaces.Add(importedNamespace);
            }

            // Since the list that comes back might be read-only, we make a new one. 
            QualifiedTopicRevisionCollection resolvedReferences = new QualifiedTopicRevisionCollection();
            foreach (TopicRevision reference in references)
            {
                // If the reference has no namespace, consider it to be relative to 
                // every in-scope namespace
                if (reference.Namespace == null)
                {
                    foreach (string inScopeNamespace in inScopeNamespaces)
                    {
                        resolvedReferences.Add(reference.ResolveRelativeTo(inScopeNamespace));
                    }
                }
                else
                {
                    resolvedReferences.Add(new QualifiedTopicRevision(reference.LocalName, reference.Namespace));
                }
            }

            if (existencePolicy == ExistencePolicy.ExistingOnly)
            {
                // We can't remove items from a list we're iterating over, so 
                // we need to make a new list. 
                QualifiedTopicRevisionCollection filteredReferences = new QualifiedTopicRevisionCollection();

                foreach (QualifiedTopicRevision resolvedReference in resolvedReferences)
                {
                    NamespaceManager manager = Federation.NamespaceManagerForNamespace(resolvedReference.Namespace);

                    if (manager != null)
                    {
                        if (manager.Exists)
                        {
                            if (manager.TopicExists(resolvedReference.LocalName, ImportPolicy.DoNotIncludeImports))
                            {
                                filteredReferences.Add(resolvedReference);
                            }
                        }
                    }
                }

                resolvedReferences = filteredReferences;
            }

            return resolvedReferences;

        }
コード例 #6
0
ファイル: NamespaceManager.cs プロジェクト: nuxleus/flexwiki
 /// <summary>
 /// Answer a hash: keys are topic; values are an array of topic names for referenced topic (in this namespace)
 /// </summary>
 /// <param name="referencing">Specific topic for which reference information is desired</param>
 /// <param name="existencePolicy">Specifies whether to only return the referenced topics that actually exist</param>
 /// <returns>A list of topics referenced by the specified topic.</returns>
 public QualifiedTopicRevisionCollection AllReferencesByTopic(string referencingTopic, ExistencePolicy existencePolicy)
 {
     return AllReferencesByTopic(new UnqualifiedTopicName(referencingTopic), existencePolicy); 
 }
コード例 #7
0
        /// <summary>
        /// Returns a list of all references from all topics in this namespace. 
        /// </summary>
        /// <param name="includeImports">Indicates whether topics should be filtered only
        /// to those that actually exist.</param>
        /// <returns>A map of topic names to the list of topics they reference.</returns>
        public ReferenceMap GetReferenceMap(ExistencePolicy existencePolicy)
        {
            ReferenceMap map = new ReferenceMap();

            foreach (QualifiedTopicName topicName in AllTopics(ImportPolicy.DoNotIncludeImports))
            {
                // We don't try to map topics that don't grant read permission - we're not
                // going to be able to parse them anyway.
                if (HasPermission(new UnqualifiedTopicName(topicName.LocalName), TopicPermission.Read))
                {
                    map[topicName.LocalName] = AllReferencesByTopic(topicName.LocalName, existencePolicy);
                }
            }

            return map;
        }
コード例 #8
0
ファイル: MockContentStore.cs プロジェクト: nuxleus/flexwiki
        private IEnumerable<MockTopic> AllTopics(ExistencePolicy existencePolicy)
        {
            MockTopicCollection topics = new MockTopicCollection(); 
            foreach (MockTopic topic in _topics)
            {
                if (existencePolicy == ExistencePolicy.All || topic.IsDeleted == false)
                {
                    topics.Add(topic); 
                }
            }

            return topics; 
        }