当前位置: 首页>>代码示例>>C#>>正文


C# Dream.Plug类代码示例

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


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


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