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


C# Result.Return方法代码示例

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


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

示例3: GetPageTags

 public Yield GetPageTags(DreamContext context, DreamMessage request, Result<DreamMessage> response) {
     PageBE page = PageBL.AuthorizePage(DekiContext.Current.User, Permissions.READ, false);
     XUri href = DekiContext.Current.ApiUri.At("pages", page.ID.ToString(), "tags");
     XDoc doc = TagBL.GetTagListXml(TagBL.GetTagsForPage(page), "tags", href, false);
     response.Return(DreamMessage.Ok(doc));
     yield break;
 } 
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:7,代码来源:DekiWiki-Tags.cs

示例4: GetPageRating

 public Yield GetPageRating(DreamContext context, DreamMessage request, Result<DreamMessage> response) {
     UserBE user = DekiContext.Current.User;
     PageBE page = PageBL.AuthorizePage(user, Permissions.READ, false);
     XDoc ret = RatingBL.GetRatingXml(page, user);
     response.Return(DreamMessage.Ok(ret));
     yield break;
 }
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:7,代码来源:DekiWiki-Ratings.cs

示例5: DeleteRecord

 public Yield DeleteRecord(DreamContext context, DreamMessage request, Result<DreamMessage> response)
 {
     string name = context.GetSuffix(0, UriPathFormat.Normalized);
     DeleteRecord(name);
     response.Return(DreamMessage.Ok());
     yield break;
 }
开发者ID:sdether,项目名称:DReAM,代码行数:7,代码来源:directoryservice.cs

示例6: GetArchiveFiles

 public Yield GetArchiveFiles(DreamContext context, DreamMessage request, Result<DreamMessage> response) {
     PermissionsBL.CheckUserAllowed(DekiContext.Current.User, Permissions.ADMIN);
     IList<AttachmentBE> removedFiles = AttachmentBL.Instance.GetResources(DeletionFilter.DELETEDONLY, null, null);
     XDoc responseXml = AttachmentBL.Instance.GetFileXml(removedFiles, true, "archive", null, null);            
     response.Return(DreamMessage.Ok(responseXml));
     yield break;
 }
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:7,代码来源:DekiWiki-RecycleBin.cs

示例7: GetPage

 public Yield GetPage(DreamContext context, DreamMessage request, Result<DreamMessage> response) {
     CheckResponseCache(context, false);
     PageBE page = PageBL.GetPageFromUrl(true);
     page = PageBL.AuthorizePage(DekiContext.Current.User, Permissions.READ, page, false);
     response.Return(DreamMessage.Ok(PageBL.GetPageXmlVerbose(page, null)));
     yield break;
 }
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:7,代码来源:DekiWiki-Pages.cs

示例8: Dispatch

 public Result Dispatch(UpdateRecord updateRecord, Result result) {
     _log.DebugFormat("got dispatch");
     Dispatches.Add(new Tuplet<DateTime, UpdateRecord>(DateTime.Now, updateRecord));
     result.Return();
     ResetEvent.Set();
     return result;
 }
开发者ID:heran,项目名称:DekiWiki,代码行数:7,代码来源:UpdateDelayQueueTests.cs

示例9: Register

        public Yield Register(DreamContext context, DreamMessage request, Result<DreamMessage> response) {
            string servicePath = context.GetParam("service-path");
            string location = StringUtil.CreateAlphaNumericKey(8);

            // register the script
            XDoc config = new XDoc("config")
                .Elem("manifest", servicePath)
                .Elem("debug", true);

            //create the script service
            Result<Plug> res;
            yield return res = CreateService(location, "sid://mindtouch.com/2007/12/dekiscript", config, new Result<Plug>());
            Plug service = res.Value;

            // register script functions in environment
            XDoc manifest = service.Get().ToDocument();
            string ns = manifest["namespace"].AsText;
            foreach(XDoc function in manifest["function"]) {
                string name = function["name"].AsText;
                if(string.IsNullOrEmpty(ns)) {
                    _env.Vars.AddNativeValueAt(name, function["uri"].AsUri);
                } else {
                    _env.Vars.AddNativeValueAt(ns + "." + name, function["uri"].AsUri);
                }
            }
            response.Return(DreamMessage.Ok(MimeType.XML, manifest));
        }
开发者ID:heran,项目名称:DekiWiki,代码行数:27,代码来源:ScriptTestService.cs

示例10: GetSiteStatus

 public Yield GetSiteStatus(DreamContext context, DreamMessage request, Result<DreamMessage> response) {
     PermissionsBL.CheckUserAllowed(DekiContext.Current.User, Permissions.UPDATE);
     var status = new XDoc("status")
         .Elem("state", DekiContext.Current.Instance.Status);
     response.Return(DreamMessage.Ok(status));
     yield break;
 }
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:7,代码来源:DekiWiki-Site.cs

示例11: DeleteConfigValue

        /// <summary>
        /// <para>Deletes a single configuration value from a given section in the
        /// CouchDB server configuration.</para>
        /// <para>(This method is asynchronous.)</para>
        /// </summary>
        /// <param name="section">The configuration section.</param>
        /// <param name="keyName">The name of the configuration key.</param>
        /// <param name="result"></param>
        /// <returns></returns>
        public Result DeleteConfigValue(
      string section, 
      string keyName, 
      Result result)
        {
            if (String.IsNullOrEmpty(section))
            throw new ArgumentException("section cannot be null nor empty");
              if (String.IsNullOrEmpty(keyName))
            throw new ArgumentException("keyName cannot be null nor empty");
              if (result == null)
            throw new ArgumentNullException("result");

              BasePlug
            .At(Constants._CONFIG, XUri.EncodeFragment(section),
            XUri.EncodeFragment(keyName))
            .Delete(DreamMessage.Ok(), new Result<DreamMessage>())
            .WhenDone(
              a =>
              {
            if (a.Status == DreamStatus.Ok)
              result.Return(); // remove " and "\n
            else
              result.Throw(new CouchException(a));
              },
              result.Throw
            );
              return result;
        }
开发者ID:jvdgeest,项目名称:chesterfield,代码行数:37,代码来源:CouchClient.Config.cs

示例12: GetSearchDescription

        public Yield GetSearchDescription(DreamContext context, DreamMessage request, Result<DreamMessage> response) {
            XDoc description = new XDoc("OpenSearchDescription", "http://a9.com/-/spec/opensearch/1.1/");
            description.Elem("ShortName", string.Format(DekiResources.OPENSEARCH_SHORTNAME, DekiContext.Current.Instance.SiteName))
                       .Elem("Description", DekiResources.OPENSEARCH_DESCRIPTION)
                       .Start("Query")
                            .Attr("role", "example")
                            .Attr("searchTerms", "Wiki")
                       .End();

            // HACK HACK HACK: we can't use XUri because it encodes the "{}" characters
            string uri = DekiContext.Current.ApiUri.At("site", "opensearch").ToString();
            uri += "?q={searchTerms}&offset={startIndex}&limit={count?}&";

            description.Start("Url")
                 .Attr("type", "text/html")
                 .Attr("indexOffset", 0)
                 .Attr("template", DekiContext.Current.UiUri.At("Special:Search").ToString() + "?search={searchTerms}&offset=0&limit={count?}&format=html")
            .End()
            .Start("Url")
                 .Attr("type", "application/atom+xml")
                 .Attr("indexOffset", 0)
                 .Attr("template", uri + "format=atom")
            .End()
            .Start("Url")
                 .Attr("type", "application/rss+xml")
                 .Attr("indexOffset", 0)
                 .Attr("template", uri + "format=rss")
            .End()
            .Start("Url")
                 .Attr("type", "application/x-suggestions+json")
                 .Attr("template", DekiContext.Current.ApiUri.At("site", "opensearch", "suggestions").ToString() + "?q={searchTerms}")
             .End();
            response.Return(DreamMessage.Ok(description));
            yield break;
        }
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:35,代码来源:DekiWiki-Search.cs

示例13: DeleteSource

		public Yield DeleteSource(DreamContext context, DreamMessage request, Result<DreamMessage> response)
		{
			Result<bool> result = new Result<bool>();
			yield return Context.Current.Instance.SourceController.Delete(context.GetParam("id"), context.GetParam("rev",null), result);

			response.Return(DreamMessage.Ok(MimeType.JSON, result.Value.ToString()));
		} 
开发者ID:willemda,项目名称:FoireMuses,代码行数:7,代码来源:SourceService.cs

示例14: GetInfo

		public Yield GetInfo(DreamContext aContext, DreamMessage aRequest, Result<DreamMessage> aResponse)
		{
			XDoc xmlInfo = new XDoc("info");
			xmlInfo.Elem("User", Context.Current.User);
			xmlInfo.Elem("About", "Foiremuses web service (c) 2011 Vincent DARON / Danny WILLEM");
			aResponse.Return(DreamMessage.Ok(MimeType.XML, xmlInfo));
			yield break;
		}
开发者ID:willemda,项目名称:FoireMuses,代码行数:8,代码来源:Services.cs

示例15: UpdateSource

		public Yield UpdateSource(DreamContext context, DreamMessage request, Result<DreamMessage> response)
		{
			ISource source = Context.Current.Instance.SourceController.FromJson(request.ToText());
			Result<ISource> result = new Result<ISource>();
			yield return Context.Current.Instance.SourceController.Update(context.GetParam("id"), context.GetParam("rev", null), source, result);

			response.Return(DreamMessage.Ok(MimeType.JSON, Context.Current.Instance.SourceController.ToJson(result.Value)));
		}
开发者ID:willemda,项目名称:FoireMuses,代码行数:8,代码来源:SourceService.cs


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