本文整理汇总了C#中DreamContext.GetSuffix方法的典型用法代码示例。如果您正苦于以下问题:C# DreamContext.GetSuffix方法的具体用法?C# DreamContext.GetSuffix怎么用?C# DreamContext.GetSuffix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DreamContext
的用法示例。
在下文中一共展示了DreamContext.GetSuffix方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: GetBlueprints
public Yield GetBlueprints(DreamContext context, DreamMessage request, Result<DreamMessage> response)
{
string sid = context.GetSuffix(0, UriPathFormat.Original);
XDoc result = null;
Dictionary<string, XDoc> blueprints = _blueprints;
if(blueprints != null) {
lock(blueprints) {
blueprints.TryGetValue(sid, out result);
}
}
if(result != null) {
response.Return(DreamMessage.Ok(result));
} else {
response.Return(DreamMessage.NotFound(string.Format("could not find blueprint for {0}", sid)));
}
yield break;
}
示例3: GetRecord
public Yield GetRecord(DreamContext context, DreamMessage request, Result<DreamMessage> response)
{
XDoc doc = null;
string name = context.GetSuffix(0, UriPathFormat.Normalized);
lock(_directory) {
DirectoryRecord record;
if(_directory.TryGetValue(name, out record)) {
doc = record.Value;
}
}
// check if we should look into a parent directory
if(doc == null) {
if(_parent != null) {
Result<DreamMessage> result;
yield return result = _parent.At("records", context.GetSuffix(0, UriPathFormat.Normalized)).Get(new Result<DreamMessage>(TimeSpan.MaxValue));
if(!result.Value.IsSuccessful) {
// respond with the error code we received
response.Return(result.Value);
yield break;
}
doc = result.Value.ToDocument();
} else {
response.Return(DreamMessage.NotFound("record not found"));
yield break;
}
}
response.Return(DreamMessage.Ok(doc));
yield break;
}
示例4: PutRecord
public Yield PutRecord(DreamContext context, DreamMessage request, Result<DreamMessage> response)
{
DirectoryRecord record = new DirectoryRecord();
record.Name = context.GetSuffix(0, UriPathFormat.Normalized);
record.Value = request.ToDocument();
int ttl = context.GetParam<int>(TIME_TO_LIVE, -1);
if(ttl >= 0) {
record.Expiration = DateTime.UtcNow.AddSeconds(ttl);
}
// add value to directory
InsertRecord(record);
response.Return(DreamMessage.Ok());
yield break;
}