• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Dream.Plug类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中MindTouch.Dream.Plug的典型用法代码示例。如果您正苦于以下问题:C# Plug类的具体用法?C# Plug怎么用?C# Plug使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Plug类属于MindTouch.Dream命名空间,在下文中一共展示了Plug类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Invoke

        public Yield Invoke(Plug plug, string verb, XUri uri, DreamMessage request, Result<DreamMessage> response)
        {
            // NOTE (steveb): we convert 'xri://@name/path?params' into 'http://xri.net/@name/path?params'

            // prepend segments with authority
            List<string> segments = new List<string>();
            segments.Add(uri.Authority);
            if(uri.Segments != null) {
                segments.AddRange(uri.Segments);
            }

            // build new plug
            List<PlugHandler> preHandlers = (plug.PreHandlers != null) ? new List<PlugHandler>(plug.PreHandlers) : null;
            List<PlugHandler> postHandlers = (plug.PostHandlers != null) ? new List<PlugHandler>(plug.PostHandlers) : null;
            Plug xri = new Plug(new XUri("http", null, null, "xri.net", 80, segments.ToArray(), uri.TrailingSlash, uri.Params, uri.Fragment), plug.Timeout, request.Headers, preHandlers, postHandlers, plug.Credentials, plug.CookieJar, plug.MaxAutoRedirects);

            // add 'Accept' header for 'application/xrds+xml' mime-type
            if((xri.Headers == null) || (xri.Headers.Accept == null)) {
                xri = xri.WithHeader(DreamHeaders.ACCEPT, MimeType.RenderAcceptHeader(MimeType.XRDS));
            }

            // BUGBUGBUG (steveb): this will probably fail in some cases since we may exit this coroutine before the call has completed!

            xri.InvokeEx(verb, request, response);
            yield break;
        }
开发者ID:maximmass,项目名称:DReAM,代码行数:26,代码来源:XriPlugEndpoint.cs


示例2: CouchBase

        protected CouchBase(XUri aBaseUri, string aUserName = null, string aPassword = null)
        {
            if (aBaseUri == null)
                throw new ArgumentNullException("aBaseUri");

            BasePlug = Plug.New(aBaseUri).WithCredentials(aUserName, aPassword);
        }
开发者ID:willemda,项目名称:DreamSeat,代码行数:7,代码来源:CouchBase.cs


示例3: RemoteInstanceManager

        // --- Constructors ---
        public RemoteInstanceManager(DekiWikiService dekiService, XUri directoryUri) : base(dekiService) {
            _directory = Plug.New(directoryUri);

            DreamMessage testMsg = _directory.GetAsync().Wait();
            if (!testMsg.IsSuccessful)
                throw new DreamInternalErrorException(string.Format("Error validating remote deki portal service at '{0}'", directoryUri.ToString()));
        }
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:8,代码来源:RemoteInstanceManager.cs


示例4: CallbackHandler

 //--- Methods ---
 private void CallbackHandler(Plug plug, string verb, XUri uri, DreamMessage request, Result<DreamMessage> response) {
     if(uri.Segments.Length == 0) {
         response.Return(DreamMessage.Ok());
         return;
     }
     var segments = uri.Segments;
     var wikiId = segments[0];
     if(wikiId.StartsWith("=")) {
         var id = (HostLookupOverride == null) ? DefaultWikiId : HostLookupOverride(wikiId.Substring(1));
         response.Return(DreamMessage.Ok(new XDoc("wiki").Attr("id", id)));
         return;
     }
     if(segments.Length == 2 && segments[1] == "license") {
         XDoc license;
         if(LicenseOverride == null) {
             _log.Debug("returning license from disk");
             license = XDocFactory.LoadFrom(Utils.Settings.LicensePath, MimeType.TEXT_XML);
         } else {
             _log.Debug("returning license from override callback");
             license = LicenseOverride(wikiId);
         }
         response.Return(DreamMessage.Ok(license));
         return;
     }
     var config = (ConfigOverride == null) ? DefaultConfig : ConfigOverride(wikiId);
     response.Return(DreamMessage.Ok(config));
 }
开发者ID:heran,项目名称:DekiWiki,代码行数:28,代码来源:RemoteInstanceService.cs


示例5: CreateRandomPage

        public static DreamMessage CreateRandomPage(Plug p, out string id)
        {
            string path = null;
            string title = GenerateUniquePageName();

            return PageUtils.SavePage(p, string.Empty, title, Utils.GetSmallRandomText(), out id, out path);
        }
开发者ID:heran,项目名称:DekiWiki,代码行数:7,代码来源:PageUtils.cs


示例6: LuceneResultFilter

 //--- Constructors ---
 public LuceneResultFilter(Plug authPlug, int maxAuthItems, int minAuthItems) {
     if(authPlug == null) {
         throw new ArgumentNullException("authPlug");
     }
     _authPlug = authPlug;
     _maxAuthItems = maxAuthItems;
     _minAuthItems = minAuthItems;
 }
开发者ID:heran,项目名称:DekiWiki,代码行数:9,代码来源:LuceneResultFilter.cs


示例7: DreamApplication

 //--- Constructors ---
 private DreamApplication(DreamApplicationConfiguration appConfig)
 {
     _appConfig = appConfig;
     _env = new DreamHostService();
     Initialize();
     RegisterDefaultRoute();
     _self = Plug.New(_env.Self.Uri.AtAbsolutePath("/"));
 }
开发者ID:nataren,项目名称:DReAM,代码行数:9,代码来源:DreamApplication.cs


示例8: CouchBase

        protected CouchBase(XUri baseUri, string username = null, 
      string password = null)
        {
            if (baseUri == null)
            throw new ArgumentNullException("baseUri");

              BasePlug = Plug.New(baseUri).WithCredentials(username, password);
        }
开发者ID:jvdgeest,项目名称:chesterfield,代码行数:8,代码来源:CouchBase.cs


示例9: GetServiceIDBySID

 private string GetServiceIDBySID(Plug p, string sid) {
     DreamMessage msg = p.At("site", "services").With("limit","all").Get();
     foreach(XDoc service in msg.ToDocument()["service"]) {
         if(service["sid"].AsText == sid)
             return service["@id"].AsText;
     }
     return null;
 }
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:8,代码来源:XmlAuthTests.cs


示例10: UploadRandomFile

        public static DreamMessage UploadRandomFile(Plug p, string pageid, byte[] content, string description, out string fileid, out string filename)
        {
            filename = FileUtils.CreateRamdomFile(content);
            DreamMessage msg = UploadFile(p, pageid, description, out fileid, filename);
            filename = msg.ToDocument()["filename"].AsText;
            Assert.IsFalse(string.IsNullOrEmpty(filename));

            return msg;
        }
开发者ID:heran,项目名称:DekiWiki,代码行数:9,代码来源:FileUtils.cs


示例11: DekiDispatcher

 //--- Constructors ---
 public DekiDispatcher(DispatcherConfig config, IPubSubDispatchQueueRepository repository)
     : base(config, repository) {
     _authtoken = config.ServiceConfig["authtoken"].AsText;
     var dekiUri = config.ServiceConfig["uri.deki"].AsUri;
     if(config.ServiceCookies != null) {
         _cookieJar.Update(config.ServiceCookies.Fetch(dekiUri), null);
     }
     _deki = Plug.New(dekiUri).WithCookieJar(_cookieJar);
 }
开发者ID:heran,项目名称:DekiWiki,代码行数:10,代码来源:DekiDispatcher.cs


示例12: Create_Helper

 private static Yield Create_Helper(Plug dekiApi, XDoc exports, int relto, string reltopath, IPackageWriter packager, Result<ExportManager> result) {
     Result<Exporter> exporterResult;
     if(string.IsNullOrEmpty(reltopath)) {
         yield return exporterResult = Exporter.CreateAsync(dekiApi, exports, relto, new Result<Exporter>());
     } else {
         yield return exporterResult = Exporter.CreateAsync(dekiApi, exports, reltopath, new Result<Exporter>());
     }
     result.Return(new ExportManager(exporterResult.Value, packager));
     yield break;
 }
开发者ID:heran,项目名称:DekiWiki,代码行数:10,代码来源:ExportManager.cs


示例13: PageChangeCache

 public PageChangeCache(Plug deki, Action<string, Action> cacheItemCallback) {
     if(deki == null) {
         throw new ArgumentNullException("deki");
     }
     if(cacheItemCallback == null) {
         throw new ArgumentNullException("cacheItemCallback");
     }
    _cacheItemCallback = cacheItemCallback;
     _deki = deki;
 }
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:10,代码来源:PageChangeCache.cs


示例14: Start

 protected override Yield Start(XDoc config, Result result) {
     Result res;
     yield return res = Coroutine.Invoke(base.Start, config, new Result());
     res.Confirm();
     var fs = new Result<Plug>();
     CreateService("mount", "http://services.mindtouch.com/dream/draft/2006/11/mount", 
         new XDoc("config").Start("mount").Attr("to", "files").Value("%DreamHost%").End(), fs);
     joinMeTL();
     _fs = fs.Value;
     result.Return();
 }
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:11,代码来源:ServiceRoot.cs


示例15: CouchBase

        protected CouchBase(string connectionStringName)
        {
            ConnectionStringSettings connectionString = ConfigurationManager.ConnectionStrings[connectionStringName];
            if(connectionString == null)
                throw new ArgumentException("Invalid connection string name");

            CouchDbConnectionStringBuilder cs = new CouchDbConnectionStringBuilder(connectionString.ConnectionString);

            BasePlug = Plug.New(String.Format("{0}://{1}:{2}",cs.SslEnabled ? "https" : "http", cs.Host, cs.Port))
                .WithCredentials(cs.UserName,cs.Password);
        }
开发者ID:jaimerosales,项目名称:DreamSeat,代码行数:11,代码来源:CouchBase.cs


示例16: Create_Helper

 private static Yield Create_Helper(Plug dekiApi, int relto, string reltopath, IPackageReader packager, Result<ImportManager> result) {
     Result<XDoc> manifestResult;
     yield return manifestResult = packager.ReadManifest(new Result<XDoc>());
     Result<Importer> importerResult;
     if(string.IsNullOrEmpty(reltopath)) {
         yield return importerResult = Importer.CreateAsync(dekiApi, manifestResult.Value, relto, new Result<Importer>());
     } else {
         yield return importerResult = Importer.CreateAsync(dekiApi, manifestResult.Value, reltopath, new Result<Importer>());
     }
     result.Return(new ImportManager(importerResult.Value, packager));
     yield break;
 }
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:12,代码来源:ImportManager.cs


示例17: ExecuteScript

        internal static XDoc ExecuteScript(Plug env, DreamHeaders headers, XDoc script) {

            // execute script commands
            XDoc reply = new XDoc("results");
            string ID = script["@ID"].Contents;
            if(!string.IsNullOrEmpty(ID)) {
                reply.Attr("ID", ID);
            }
            foreach(XDoc cmd in script.Elements) {
                reply.Add(ExecuteCommand(env, headers, cmd));
            }
            return reply;
        }
开发者ID:sdether,项目名称:DReAM,代码行数:13,代码来源:DreamCoreUtil.cs


示例18: GlobalInit

 public void GlobalInit() {
     _adminPlug = Utils.BuildPlugForAdmin();
     _log.DebugFormat("admin plug: {0}", _adminPlug.Uri.ToString());
     _userId = null;
     string subscriber = null;
     UserUtils.CreateRandomContributor(_adminPlug, out _userId, out subscriber);
     _log.DebugFormat("created contributor {0} ({1})", subscriber, _userId);
     _pageSubscriberPlug = Utils.BuildPlugForUser(subscriber);
     _log.DebugFormat("subscriber plug: {0}", _pageSubscriberPlug.Uri.ToString());
     _pageSub = _pageSubscriberPlug.At("pagesubservice");
     DreamMessage response = PageUtils.CreateRandomPage(_adminPlug);
     Assert.IsTrue(response.IsSuccessful);
 }
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:13,代码来源:DekiChangeSubscriptionExtTests.cs


示例19: UploadFile

        public static DreamMessage UploadFile(Plug p, string pageid, string description, out string fileid, string filename)
        {
            DreamMessage msg = DreamMessage.FromFile(filename);
            filename = XUri.DoubleEncode(System.IO.Path.GetFileName(filename));
            if (string.IsNullOrEmpty(description))
                msg = p.At("pages", pageid, "files", "=" + filename).Put(msg);
            else
                msg = p.At("pages", pageid, "files", "=" + filename).With("description", description).Put(msg);
            Assert.AreEqual(DreamStatus.Ok, msg.Status);
            fileid = msg.ToDocument()["@id"].AsText;
            Assert.IsFalse(string.IsNullOrEmpty(fileid));

            return msg;
        }
开发者ID:heran,项目名称:DekiWiki,代码行数:14,代码来源:FileUtils.cs


示例20: RemoteInstanceManager

        //--- Constructors ---
        public RemoteInstanceManager(DekiWikiService dekiService, TaskTimerFactory timerFactory, XUri directoryUri, string tempPath) : base(dekiService, timerFactory) {

            // validate temp folder
            _tempPath = tempPath;
            if(!Directory.Exists(_tempPath)) {
                throw new ArgumentException("temp folder does not exist", "tempPath");
            }

            // check remote directory
            _directory = Plug.New(directoryUri);
            var testMsg = _directory.GetAsync().Wait();
            if(!testMsg.IsSuccessful) {
                _log.WarnFormat("Error validating remote deki portal service at '{0}'", directoryUri);
            }
        }
开发者ID:heran,项目名称:DekiWiki,代码行数:16,代码来源:RemoteInstanceManager.cs



注:本文中的MindTouch.Dream.Plug类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Dream.XUri类代码示例发布时间:2022-05-26
下一篇:
C# Dream.MimeType类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap