Esempio n. 1
0
        protected void DoSearch()
        {
            string defaultNamespace = Request.QueryString["QuickLinkNamespace"];

            LinkMaker lm = TheLinkMaker;

            string topic = Request.Form["QuickLink"];
            QualifiedTopicNameCollection hits = Federation.AllQualifiedTopicNamesThatExist(new TopicName(topic), defaultNamespace);

            string target = null;
            if (hits.Count == 0)
            {
                // No hits, create it in the default namespace, or the namespace that was specified
                TopicName topicName = new TopicName(topic);
                QualifiedTopicName qualifiedTopicName = topicName.ResolveRelativeTo(defaultNamespace);
                target = lm.LinkToEditTopic(qualifiedTopicName);
            }
            else if (hits.Count == 1)
            {
                // 1 hit; take it!
                NameValueCollection extras = new NameValueCollection();
                extras.Add("DelayRedirect", "1");
                target = lm.LinkToTopic(new QualifiedTopicRevision(hits[0]), false, extras);
            }

            // If we have a target, go there
            if (target != null)
            {
                // Response.Write(target);
                Response.Redirect(target);
                return;
            }

            // Uh, oh -- we're here because the name is ambiguous
            Response.Write(@"
            <!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN"" >
            <HTML>
            <HEAD>
            <title id='title'>Topic is ambiguous</title>
            <LINK href='<%= RootUrl(Request) %>wiki.css' type='text/css' rel='stylesheet'>
            </HEAD>
            <p>The topic name you selected is ambiguous because it already exists in multiple namespaces.  Please select the one you want:
            <ul>");
            foreach (TopicName each in hits)
            {
                Response.Write("<li><a href='" + lm.LinkToTopic(each) + "'>" + each.DottedName + "</a></li>");
            }
            Response.Write(@"
            </ul>
            </body>
            </HTML>
            ");
        }
Esempio n. 2
0
        public void ResolveRelativeToFromUnqualified()
        {
            TopicName topicName = new TopicName("TopicName");

            QualifiedTopicName qualifiedName = topicName.ResolveRelativeTo("SomeNamespace");

            Assert.AreEqual("SomeNamespace.TopicName", qualifiedName.DottedName,
                "Checking that the new namespace is used when resolving an unqualified name.");
        }
Esempio n. 3
0
        public void ResolveRelativeToFromQualified()
        {
            TopicName topicName = new TopicName("Namespace.TopicName");

            QualifiedTopicName qualifiedName = topicName.ResolveRelativeTo("SomeNamespace");

            Assert.AreEqual("Namespace.TopicName", qualifiedName.DottedName,
                "Checking that the original namespace is kept when resolving an already-qualified name.");
        }