コード例 #1
0
ファイル: Phabricator.cs プロジェクト: duaneking/Tychaia
        public dynamic GetWikiHierarchy(ConduitClient client, string slug)
        {
            var hierarchy = this.WikiHierarchyCache.Get(slug);

            if (hierarchy == null)
            {
                try
                {
                    hierarchy = client.Do("phriction.hierarchy", new {
                        slug  = slug,
                        depth = 2
                    });
                }
                catch (ConduitException)
                {
                    // Ignore this error; Phabricator might not support
                    // the phriction.hierarchy method.
                    hierarchy = new List <object>();
                }
                if (hierarchy == null)
                {
                    throw new NotImplementedException(slug);
                }
                this.WikiHierarchyCache.Add(
                    new CacheItem(slug, hierarchy),
                    new CacheItemPolicy {
                    AbsoluteExpiration = DateTimeOffset.Now.AddMinutes(15)
                }
                    );
            }
            return(hierarchy);
        }
コード例 #2
0
ファイル: Phabricator.cs プロジェクト: duaneking/Tychaia
        public dynamic GetWikiPage(ConduitClient client, string slug)
        {
            var page = this.WikiPageCache.Get(slug);

            if (page == null)
            {
                page = client.Do("phriction.info", new {
                    slug = slug
                });
                this.WikiPageCache.Add(
                    new CacheItem(slug, page),
                    new CacheItemPolicy {
                    AbsoluteExpiration = DateTimeOffset.Now.AddMinutes(15)
                }
                    );
            }
            return(page);
        }
コード例 #3
0
ファイル: Phabricator.cs プロジェクト: duaneking/Tychaia
        public string ProcessRemarkup(ConduitClient client, string remarkup)
        {
            var sha1 = SHA1(remarkup);
            var html = RemarkupCache.Get(sha1) as string;

            if (html == null)
            {
                html = client.Do("remarkup.process", new {
                    context = "phriction",
                    content = remarkup
                }).content;
                this.RemarkupCache.Add(
                    new CacheItem(sha1, html),
                    new CacheItemPolicy {
                    SlidingExpiration = new TimeSpan(1, 0, 0)
                }
                    );
            }
            return(html);
        }