コード例 #1
0
        private IStalkNode NewExternalNode(XmlElement fragment)
        {
            var extNode = new ExternalNode();

            if (fragment.Attributes["provider"] != null)
            {
                extNode.Provider = fragment.Attributes["provider"].Value;
            }

            if (fragment.Attributes["location"] != null)
            {
                extNode.Location = fragment.Attributes["location"].Value;
            }

            if (extNode.Provider == null || extNode.Location == null)
            {
                throw new XmlException("Could not determine location of external XML fragment");
            }

            IExternalProvider provider;

            switch (extNode.Provider)
            {
            case "phabricator":
                provider = this.phabricatorExternalProvider;
                break;

            default:
                throw new XmlException("Unknown external handler type");
            }

            extNode.ChildNode = this.NewFromXmlFragment(provider.PopulateFromExternalSource(extNode));
            return(extNode);
        }
コード例 #2
0
ファイル: TestNodes.cs プロジェクト: kingreatwill/fubumvc
        public static ExternalNode AddNode(string name, ExternalNode node)
        {
            ExternalNode actualNode;
            if (Nodes.TryGetValue(name, out actualNode))
                return actualNode;

            node.Start();
            Nodes[name] = node;
            return node;
        }
コード例 #3
0
        private XmlElement ExternalNodeToXml(XmlDocument doc, ExternalNode node)
        {
            var elem = this.CreateElement(doc, node);

            elem.SetAttribute("provider", node.Provider);
            elem.SetAttribute("location", node.Location);
            elem.SetAttribute("comment", node.Comment);

            return(elem);
        }
コード例 #4
0
        public XmlElement PopulateFromExternalSource(ExternalNode node)
        {
            if (!this.active)
            {
                throw new InvalidOperationException(
                          "Cannot retrieve external resources from Phabricator as this is not configured.");
            }

            string location = node.Location;

            if (node.Location.StartsWith("P"))
            {
                location = node.Location.Substring(1);
            }

            var document = new XmlDocument();

            try
            {
                var pasteId = new ApplicationEditorSearchConstraint("ids", new List <int> {
                    int.Parse(location)
                });
                var pasteItems = this.paste.Search(constraints: new[] { pasteId }, attachments: new[] { "content" });

                var pasteItem = pasteItems.First();

                document.LoadXml(pasteItem.Text);
                node.Comment = pasteItem.Title;

                return(document.DocumentElement);
            }
            catch (WebException ex)
            {
                this.logger.ErrorFormat(ex, "Exception encountered while trying to retrieve remote stalk configuration");

                document.LoadXml("<false />");
                node.Comment = "Error loading fragment from remote source.";

                return(document.DocumentElement);
            }
        }
コード例 #5
0
 public override string Visit(ExternalNode node)
 {
     return(node.Body);
 }
コード例 #6
0
 public void AddToExternalNodes(ExternalNode externalNode)
 {
     base.AddObject("ExternalNodes", externalNode);
 }
コード例 #7
0
 public static ExternalNode CreateExternalNode(long nodeId, string externalType, string externalId, long ID, global::System.Guid tid, string name, long createdById, long modifiedById, global::System.DateTimeOffset created, global::System.DateTimeOffset modified)
 {
     ExternalNode externalNode = new ExternalNode();
     externalNode.NodeId = nodeId;
     externalNode.ExternalType = externalType;
     externalNode.ExternalId = externalId;
     externalNode.Id = ID;
     externalNode.Tid = tid;
     externalNode.Name = name;
     externalNode.CreatedById = createdById;
     externalNode.ModifiedById = modifiedById;
     externalNode.Created = created;
     externalNode.Modified = modified;
     return externalNode;
 }