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


C# DreamContext.GetSuffixes方法代码示例

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


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

示例1: GetFileHandler

        public Yield GetFileHandler(DreamContext context, DreamMessage request, Result<DreamMessage> response)
        {
            string suffixPath = string.Join("" + Path.DirectorySeparatorChar, context.GetSuffixes(UriPathFormat.Decoded));
            string filename = Path.Combine(_path, suffixPath);
            if(Directory.Exists(filename)) {
                XDoc ret = new XDoc("files");
                string pattern = context.GetParam("pattern", "");
                AddDirectories(new DirectoryInfo(filename), pattern, ret);
                AddFiles(new DirectoryInfo(filename), pattern, ret);
                response.Return(DreamMessage.Ok(ret));
                yield break;
            }

            DreamMessage message;
            try {
                message = DreamMessage.FromFile(filename, StringUtil.EqualsInvariant(context.Verb, "HEAD"));
            } catch(FileNotFoundException) {
                message = DreamMessage.NotFound("file not found");
            } catch(Exception) {
                message = DreamMessage.BadRequest("invalid path");
            }

            // open file and stream it to the requester
            response.Return(message);
        }
开发者ID:maximmass,项目名称:DReAM,代码行数:25,代码来源:MountService.cs

示例2: GetHttp

 public Yield GetHttp(DreamContext context, DreamMessage request, Result<DreamMessage> response)
 {
     yield return context.Relay(_redirect.At(context.GetSuffixes(UriPathFormat.Original)), request, response);
 }
开发者ID:sdether,项目名称:DReAM,代码行数:4,代码来源:RedirectService.cs

示例3: ProxyToService

        public Yield ProxyToService(DreamContext context, DreamMessage request, Result<DreamMessage> response) {
            PermissionsBL.IsUserAllowed(DekiContext.Current.User, Permissions.ADMIN);

            //Private feature requires api-key
            var identifier = context.GetParam("id");
            ServiceRepository.IServiceInfo serviceInfo = null;
            if(identifier.StartsWith("=")) {
                serviceInfo = DekiContext.Current.Instance.RunningServices[XUri.Decode(identifier.Substring(1))];
            } else {
                uint serviceId;
                if(uint.TryParse(identifier, out serviceId)) {
                    serviceInfo = DekiContext.Current.Instance.RunningServices[serviceId];
                } else {
                    throw new DreamBadRequestException(string.Format("Invalid id '{0}'", identifier));
                }
            }
            if(serviceInfo == null) {
                response.Return(DreamMessage.NotFound(string.Format(DekiResources.SERVICE_NOT_FOUND, identifier)));
                yield break;
            }
            var proxyUri = serviceInfo.ServiceUri.At(context.GetSuffixes(UriPathFormat.Original).Skip(1).ToArray());

            yield return context.Relay(Plug.New(proxyUri), request, response);
        }
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:24,代码来源:DekiWiki-Services.cs

示例4: GetFile

 private DreamMessage GetFile(DreamContext context) {
     DreamMessage message;
     string[] parts = context.GetSuffixes(UriPathFormat.Decoded);
     string filename = _resourcesPath;
     foreach(string part in parts) {
         if(part.EqualsInvariant("..")) {
             _log.WarnFormat("attempted to access file outside of target folder: {0}", string.Join("/", parts));
             throw new DreamBadRequestException("paths cannot contain '..'");
         }
         filename = Path.Combine(filename, part);
     }
     try {
         message = DreamMessage.FromFile(filename, context.Verb == Verb.HEAD);
     } catch(FileNotFoundException e) {
         message = DreamMessage.NotFound("resource not found: " + String.Join("/", context.GetSuffixes(UriPathFormat.Decoded)));
     } catch(Exception e) {
         message = DreamMessage.BadRequest("invalid path");
     }
     return message;
 }
开发者ID:heran,项目名称:DekiWiki,代码行数:20,代码来源:DekiScriptHostService.cs

示例5: GetFiles

 public Yield GetFiles(DreamContext context, DreamMessage request, Result<DreamMessage> response) {
     if(_resourcesUri != null) {
         yield return context.Relay(Plug.New(_resourcesUri).AtPath(string.Join("/", context.GetSuffixes(UriPathFormat.Original))), request, response);
     } else {
         response.Return(GetFile(context));
     }
     yield break;
 }
开发者ID:heran,项目名称:DekiWiki,代码行数:8,代码来源:DekiScriptHostService.cs

示例6: PostPageMessage

 public Yield PostPageMessage(DreamContext context, DreamMessage request, Result<DreamMessage> response) {
     if(UserBL.IsAnonymous(DekiContext.Current.User)) {
         response.Return(DreamMessage.Forbidden("A logged-in user is required"));
         yield break;
     }
     if(request.ContentLength > 128 * 1024) {
         response.Return(DreamMessage.BadRequest("Content-length cannot exceed 128KB)"));
         yield break;
     }
     PageBE page = PageBL_AuthorizePage(context, null, Permissions.READ, false);
     XDoc body = new XDoc("body");
     switch(request.ContentType.FullType) {
     case "text/plain":
         body.Attr("content-type", request.ContentType.ToString())
             .Value(request.AsText());
         break;
     default:
         body.Attr("content-type", request.ContentType.ToString())
             .Add(request.ToDocument());
         break;
     }
     string[] path = context.GetSuffixes(UriPathFormat.Original);
     path = ArrayUtil.SubArray(path, 1);
     DekiContext.Current.Instance.EventSink.PageMessage(DekiContext.Current.Now, page, DekiContext.Current.User, body, path);
     response.Return(DreamMessage.Ok());
     yield break;
 }
开发者ID:heran,项目名称:DekiWiki,代码行数:27,代码来源:DekiWiki-Pages.cs

示例7: GetPath

 private string GetPath(DreamContext context)
 {
     string[] parts = context.GetSuffixes(UriPathFormat.Decoded);
     string path = _path;
     foreach(string part in parts) {
         if(part.EqualsInvariant("..")) {
             throw new DreamBadRequestException("paths cannot contain '..'");
         }
         path = Path.Combine(path, part);
     }
     if(_privateRoot && (parts.Length == 0 || (parts.Length == 1 && !Directory.Exists(path)))) {
         throw new DreamForbiddenException("Root level access is forbidden for this storage service");
     }
     return path;
 }
开发者ID:heran,项目名称:DReAM,代码行数:15,代码来源:StorageService.cs

示例8: GetPath

 private string GetPath(DreamContext context)
 {
     var parts = context.GetSuffixes(UriPathFormat.Decoded);
     if(parts.Where(p => p.EqualsInvariant("..")).Any()) {
         throw new DreamBadRequestException("paths cannot contain '..'");
     }
     if(_privateRoot && (parts.Length == 0 || (parts.Length == 1 && !context.Uri.TrailingSlash))) {
         throw new DreamForbiddenException("Root level access is forbidden for this storage service");
     }
     return context.Uri.GetRelativePathTo(context.Service.Self.Uri).IfNullOrEmpty("/");
 }
开发者ID:danice,项目名称:DReAM,代码行数:11,代码来源:S3StorageService.cs


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