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


C# XUri.GetParam方法代码示例

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


在下文中一共展示了XUri.GetParam方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Invoke

        public Yield Invoke(Plug plug, string verb, XUri uri, DreamMessage request, Result<DreamMessage> response)
        {
            // we only support GET as verb
            DreamMessage reply;
            if((verb != Verb.GET) && (verb != Verb.HEAD)) {
                reply = new DreamMessage(DreamStatus.MethodNotAllowed, null, null);
                reply.Headers.Allow = Verb.GET + "," + Verb.HEAD;
            } else {
                bool head = (verb == Verb.HEAD);

                // try to load the assembly
                System.Reflection.Assembly assembly = System.Reflection.Assembly.Load(uri.Host);
                Version version = assembly.GetName().Version;
                DateTime timestamp = new DateTime(2000, 1, 1).AddDays(version.Build).AddSeconds(version.Revision * 2);

                // check if request is just about re-validation
                if(!head && request.CheckCacheRevalidation(timestamp)) {
                    reply = DreamMessage.NotModified();
                } else {
                    try {
                        System.IO.Stream stream = assembly.GetManifestResourceStream(uri.Path.Substring(1));
                        if(stream != null) {
                            MimeType mime = MimeType.New(uri.GetParam(DreamOutParam.TYPE, null)) ?? MimeType.BINARY;
                            reply = new DreamMessage(DreamStatus.Ok, null, mime, stream.Length, head ? System.IO.Stream.Null : stream);
                            if(head) {
                                stream.Close();
                            } else {
                                reply.SetCacheMustRevalidate(timestamp);
                            }
                        } else {
                            reply = DreamMessage.NotFound("could not find resource");
                        }
                    } catch(System.IO.FileNotFoundException) {
                        reply = DreamMessage.NotFound("could not find resource");
                    } catch(Exception e) {
                        reply = DreamMessage.InternalError(e);
                    }
                }
            }
            response.Return(reply);
            yield break;
        }
开发者ID:nataren,项目名称:DReAM,代码行数:42,代码来源:ResourcePlugEndpoint.cs

示例2: lock

        //--- Interface Methods ---
        int IPlugEndpoint.GetScoreWithNormalizedUri(XUri uri, out XUri normalized)
        {
            int result;
            XUri prefix;
            lock(_aliases) {
                _aliases.TryGetValue(uri, out prefix, out result);
            }

            // check if we found a match
            if(prefix != null) {
                normalized = uri.ChangePrefix(prefix, _localMachineUri);

                // if 'dream.in.uri' is not set, set it
                if((normalized.GetParam(DreamInParam.URI, null) == null) && !prefix.Scheme.EqualsInvariant("local")) {
                    normalized = normalized.With(DreamInParam.URI, prefix.ToString());
                }
            } else {
                normalized = null;
            }
            return (result > 0) ? result + Plug.BASE_ENDPOINT_SCORE : 0;
        }
开发者ID:nataren,项目名称:DReAM,代码行数:22,代码来源:DreamHostService.cs

示例3: SubmitRequestAsync

        private Result<DreamMessage> SubmitRequestAsync(string verb, XUri uri, IPrincipal user, DreamMessage request, Result<DreamMessage> response, Action completion)
        {
            if(string.IsNullOrEmpty(verb)) {
                if(completion != null) {
                    completion();
                }
                throw new ArgumentNullException("verb");
            }
            if(uri == null) {
                if(completion != null) {
                    completion();
                }
                throw new ArgumentNullException("uri");
            }
            if(request == null) {
                if(completion != null) {
                    completion();
                }
                throw new ArgumentNullException("request");
            }
            if(response == null) {
                if(completion != null) {
                    completion();
                }
                throw new ArgumentNullException("response");
            }

            // ensure environment is still running
            if(!IsRunning) {
                response.Return(DreamMessage.InternalError("host not running"));
                if(completion != null) {
                    completion();
                }
                return response;
            }

            try {
                Interlocked.Increment(ref _requestCounter);

                // check if we were not able to begin processing the request
                DreamMessage failed = BeginRequest(completion, uri, request);
                if(failed != null) {
                    response.Return(failed);
                    EndRequest(completion, uri, request);
                    return response;
                }

                // check if 'verb' is overwritten by a processing parameter
                verb = verb.ToUpperInvariant();
                string requestedVerb = (uri.GetParam(DreamInParam.VERB, null) ?? request.Headers.MethodOverride ?? verb).ToUpperInvariant();
                if(
                    verb.EqualsInvariant(Verb.POST) || (
                        verb.EqualsInvariant(Verb.GET) && (
                            requestedVerb.EqualsInvariant(Verb.OPTIONS) ||
                            requestedVerb.EqualsInvariant(Verb.HEAD)
                        )
                    )
                ) {
                    verb = requestedVerb;
                }

                // check if an origin was specified
                request.Headers.DreamOrigin = uri.GetParam(DreamInParam.ORIGIN, request.Headers.DreamOrigin);

                // check if a public uri is supplied
                XUri publicUri = XUri.TryParse(uri.GetParam(DreamInParam.URI, null) ?? request.Headers.DreamPublicUri);
                XUri transport = XUri.TryParse(request.Headers.DreamTransport) ?? uri.WithoutCredentialsPathQueryFragment();
                if(publicUri == null) {

                    // check if request is local
                    if(transport.Scheme.EqualsInvariantIgnoreCase("local")) {

                        // local:// uris with no public-uri specifier default to the configured public-uri
                        publicUri = _publicUri;
                    } else {

                        // check if the request was forwarded through Apache mod_proxy
                        string proxyOverride = uri.GetParam(DreamInParam.HOST, null);
                        if(string.IsNullOrEmpty(proxyOverride)) {
                            proxyOverride = request.Headers.ForwardedHost;
                        }
                        string serverPath = string.Join("/", transport.Segments);
                        if(proxyOverride != null) {

                            // request used an override, append path of public-uri
                            serverPath = string.Join("/", _publicUri.Segments);
                        }

                        // set the uri scheme based-on the incoming scheme and the override header
                        string scheme = transport.Scheme;
                        if("On".EqualsInvariantIgnoreCase(request.Headers.FrontEndHttps ?? "")) {
                            scheme = Scheme.HTTPS;
                        }
                        scheme = uri.GetParam(DreamInParam.SCHEME, scheme);

                        // set the host port
                        string hostPort = proxyOverride ?? request.Headers.Host ?? uri.HostPort;
                        publicUri = new XUri(string.Format("{0}://{1}", scheme, hostPort)).AtPath(serverPath);
                    }
                    request.Headers.DreamPublicUri = publicUri.ToString();
//.........这里部分代码省略.........
开发者ID:nataren,项目名称:DReAM,代码行数:101,代码来源:DreamHostService.cs

示例4: CreateExportDocumentFromList

 private XDoc CreateExportDocumentFromList(string listPath) {
     if(!File.Exists(listPath)) {
         throw new ConfigurationException("No such export list: {0}", listPath);
     }
     XDoc exportDoc = new XDoc("export");
     foreach(string line in File.ReadAllLines(listPath)) {
         if(string.IsNullOrEmpty(line)) {
             continue;
         }
         if(line.StartsWith("#")) {
             exportDoc.Comment(line.Remove(0, 1));
             continue;
         }
         try {
             string path = line.Trim();
             if(!line.StartsWith("/")) {
                 XUri uri = new XUri(path);
                 path = uri.Path;
                 if(StringUtil.EqualsInvariantIgnoreCase("/index.php", path)) {
                     path = uri.GetParam("title");
                 }
             }
             exportDoc.Start("page")
                     .Attr("path", Title.FromUIUri(null, path).AsPrefixedDbPath())
                     .Attr("recursive", _exportRecursive)
                 .End();
         } catch(Exception) {
             throw new ConfigurationException("Unable to parse uri: {0}", line.Trim());
         }
     }
     return exportDoc;
 }
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:32,代码来源:Opts.cs

示例5: New

            //--- Class Methods ---
            internal static AMedia New(XUri uri, XDoc config) {

                // check if the uri is a viddler video
                if(uri.Scheme.EqualsInvariantIgnoreCase("kaltura")) {
                    if(uri.Segments.Length >= 1) {
                        string entryID = uri.Segments[0];
                        string partnerID = config["kaltura/partner-id"].AsText;

                        // check if extension is configured for kaltura integration
                        if(!string.IsNullOrEmpty(partnerID)) {
                            bool remix = !(uri.GetParam("edit", null) ?? uri.GetParam("remix", "no")).EqualsInvariantIgnoreCase("no");

                            // verify that user has permission to remix content on current page
                            if(remix) {
                                Plug dekiApi = GetDekiApi(config);
                                if(dekiApi != null) {
                                    try {
                                        DekiScriptMap env = DreamContext.Current.GetState<DekiScriptMap>();
                                        string pageid = env.GetAt("page.id").AsString();
                                        string userid = env.GetAt("user.id").AsString();
                                        XDoc users = dekiApi.At("pages", pageid, "allowed").With("permissions", "UPDATE").Post(new XDoc("users").Start("user").Attr("id", userid).End()).ToDocument();
                                        remix = !users[string.Format(".//user[@id='{0}']", userid)].IsEmpty;
                                    } catch(Exception e) {
                                        _log.Error("unable to verify user permission on page", e);
                                    }
                                }
                            }

                            // check if SEO links are explicitly disabled
                            bool seo = !(config["kaltura/seo-links"].AsText ?? "enabled").EqualsInvariantIgnoreCase("disabled");

                            // determin which UI configuration to use based on user's permissions and embed settings for video
                            string uiConfID = remix ? config["kaltura/uiconf/player-mix"].AsText : config["kaltura/uiconf/player-nomix"].AsText;
                            if(!string.IsNullOrEmpty(uiConfID)) {
                                uri = config["kaltura/server-uri"].AsUri ?? new XUri("http://www.kaltura.com");
                                uri = uri.At("index.php", "kwidget", "wid", "_" + partnerID, "uiconf_id", uiConfID, "entry_id", entryID);
                                return new KalturaVideo(uri, remix, seo);
                            }
                        }
                    }
                }
                return null;
            }
开发者ID:heran,项目名称:DekiWiki,代码行数:44,代码来源:MediaService.cs


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