本文整理汇总了C#中Result.Return方法的典型用法代码示例。如果您正苦于以下问题:C# Result.Return方法的具体用法?C# Result.Return怎么用?C# Result.Return使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Result
的用法示例。
在下文中一共展示了Result.Return方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetGroup
public Yield GetGroup(DreamContext context, DreamMessage request, Result<DreamMessage> response) {
PermissionsBL.CheckUserAllowed(DekiContext.Current.User, Permissions.READ);
GroupBE group = GetGroupFromUrl();
DreamMessage responseMsg = DreamMessage.Ok(GroupBL.GetGroupXmlVerbose(group, null));
response.Return(responseMsg);
yield break;
}
示例2: PostBans
public Yield PostBans(DreamContext context, DreamMessage request, Result<DreamMessage> response) {
PermissionsBL.CheckUserAllowed(DekiContext.Current.User, Permissions.ADMIN);
BanBE ban = BanningBL.SaveBan(request.ToDocument());
DekiContext.Current.Instance.EventSink.BanCreated(context.StartTime, ban);
response.Return(DreamMessage.Ok(BanningBL.GetBanXml(ban)));
yield break;
}
示例3: GetCommentContent
public Yield GetCommentContent(DreamContext context, DreamMessage request, Result<DreamMessage> response) {
PageBE page = null;
CommentBE comment = null;
GetCommentFromRequest(context, Permissions.READ, out page, out comment);
response.Return(DreamMessage.Ok(new MimeType(comment.ContentMimeType), comment.Content));
yield break;
}
示例4: WriteData_Helper
protected override Yield WriteData_Helper(ExportItem item, Result result) {
string file = GetFilePath(item);
string filepath = Path.Combine(_packageDirectory, file);
string path = Path.GetDirectoryName(filepath);
if(!Directory.Exists(path)) {
_log.DebugFormat("creating directory: {0}", path);
Directory.CreateDirectory(path);
}
FileStream fileStream = File.Create(filepath);
Result<long> copyResult;
yield return copyResult = item.Data.CopyTo(fileStream, item.DataLength, new Result<long>()).Catch();
item.Data.Close();
fileStream.Close();
if(copyResult.HasException) {
result.Throw(copyResult.Exception);
yield break;
}
if(item.DataLength != copyResult.Value) {
throw new IOException(string.Format("tried to write {0} bytes, but wrote {1} instead for {2}", item.DataLength, copyResult.Value, filepath));
}
_log.DebugFormat("saved: {0}", filepath);
AddFileMap(item.DataId, file);
item.Data.Close();
result.Return();
yield break;
}
示例5: ReadManifest_Helper
private Yield ReadManifest_Helper(Result<XDoc> result) {
if(_package == null) {
yield return Coroutine.Invoke(ReadPackage_Helper, new Result());
}
result.Return(_package["manifest"]);
yield break;
}
示例6: DeleteBan
public Yield DeleteBan(DreamContext context, DreamMessage request, Result<DreamMessage> response) {
PermissionsBL.CheckUserAllowed(DekiContext.Current.User, Permissions.ADMIN);
BanBE ban = GetBanFromRequest(context, context.GetParam<uint>("banid"));
BanningBL.DeleteBan(ban);
DekiContext.Current.Instance.EventSink.BanRemoved(context.StartTime, ban);
response.Return(DreamMessage.Ok());
yield break;
}
示例7: CreatePlay
public Yield CreatePlay(DreamContext context, DreamMessage request, Result<DreamMessage> response)
{
IPlay play = Context.Current.Instance.PlayController.FromJson(request.ToText());
Result<IPlay> result = new Result<IPlay>();
yield return Context.Current.Instance.PlayController.Insert(play, result);
response.Return(DreamMessage.Ok(MimeType.JSON, Context.Current.Instance.PlayController.ToJson(result.Value)));
}
示例8: PutSiteRole
public Yield PutSiteRole(DreamContext context, DreamMessage request, Result<DreamMessage> response) {
PermissionsBL.CheckUserAllowed(DekiContext.Current.User, Permissions.ADMIN);
RoleBE role = GetRoleFromUrl(false);
role = PermissionsBL.PutRole(role, request, context);
response.Return(DreamMessage.Ok(PermissionsBL.GetRoleXml(role, null)));
yield break;
}
示例9: WildCardMessage
public IEnumerator<IYield> WildCardMessage(DreamContext context, DreamMessage request, Result<DreamMessage> response)
{
// convert dream message into an XML document
XDoc xmessage = new XMessage(request);
// respond by sending the message back
response.Return(DreamMessage.Ok(xmessage));
yield break;
}
示例10: ReadPackage_Helper
private Yield ReadPackage_Helper(Result result) {
ZipEntry manifestEntry = _zipFile.GetEntry("package.xml");
Result<MemoryStream> readResult;
yield return readResult = ReadZipStream(manifestEntry, new Result<MemoryStream>());
using(TextReader reader = new StreamReader(readResult.Value)) {
_package = XDocFactory.From(reader, MimeType.TEXT_XML);
}
result.Return();
}
示例11: GetPlays
public Yield GetPlays(DreamContext context, DreamMessage request, Result<DreamMessage> response)
{
Result<SearchResult<IPlay>> result = new Result<SearchResult<IPlay>>();
int limit = context.GetParam("max", 20);
int offset = context.GetParam("offset", 0);
yield return Context.Current.Instance.PlayController.GetAll(offset, limit, result);
response.Return(DreamMessage.Ok(MimeType.JSON, Context.Current.Instance.PlayController.ToJson(result.Value)));
}
示例12: ReadData
public Result<ImportItem> ReadData(ImportItem item, Result<ImportItem> result) {
string file = _package[string.Format("map/item[@dataid='{0}']/@path", item.DataId)].AsText;
string path = Path.Combine(_packageDirectory, file);
if(!File.Exists(path)) {
throw new FileNotFoundException(string.Format("Unable to locate file for dataid '{0}'", item.DataId), path);
}
FileStream fileStream = File.OpenRead(path);
result.Return(item.WithData(fileStream, fileStream.Length));
return result;
}
示例13: GetScores
public Yield GetScores(DreamContext aContext, DreamMessage aRequest, Result<DreamMessage> aResponse)
{
theLogger.Info("GetScores");
Result<SearchResult<IScoreSearchResult>> result = new Result<SearchResult<IScoreSearchResult>>();
int limit = aContext.GetParam("max", 20);
int offset = aContext.GetParam("offset", 0);
yield return Context.Current.Instance.IndexController.GetAllScores(limit, offset, result);
aResponse.Return(DreamMessage.Ok(MimeType.JSON, Context.Current.Instance.IndexController.ToJson(result.Value)));
}
示例14: GetPlay
public Yield GetPlay(DreamContext context, DreamMessage request, Result<DreamMessage> response)
{
Result<IPlay> result = new Result<IPlay>();
string id = context.GetParam<string>("id");
yield return Context.Current.Instance.PlayController.Retrieve(id, result);
response.Return(result.Value == null
? DreamMessage.NotFound("No Score found for id " + id)
: DreamMessage.Ok(MimeType.JSON, Context.Current.Instance.PlayController.ToJson(result.Value)));
}
示例15: WildCardHeaders
public IEnumerator<IYield> WildCardHeaders(DreamContext context, DreamMessage request, Result<DreamMessage> response)
{
// convert dream message into an XML document
XDoc xmessage = new XMessage(request);
// select <headers> element
XDoc headers = xmessage["headers"];
// send it back
response.Return(DreamMessage.Ok(headers));
yield break;
}