本文整理汇总了C#中IManosContext类的典型用法代码示例。如果您正苦于以下问题:C# IManosContext类的具体用法?C# IManosContext怎么用?C# IManosContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IManosContext类属于命名空间,在下文中一共展示了IManosContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestSubmitLink
public void TestSubmitLink(IManosContext ctx, string link)
{
var template = new RazorTemplate {
Model = link
};
ctx.Response.End(template.TransformText());
}
示例2: SubmitLink
public void SubmitLink(IManosContext ctx, Shorty app, string link)
{
string id = GenerateHash (link, 5);
Cache [id] = new LinkData (link);
ctx.Response.Redirect ("/r/" + id + "~");
}
示例3: Images
public void Images(IManosContext ctx, int index)
{
var images = new ImageList();
var image = images[index];
ctx.Response.End("Image: {0}, size {1} x {2}", image.Name, image.Width,
image.Height);
}
示例4: Content
public void Content(IManosContext ctx)
{
string path = ctx.Request.Path;
// Double check path start with route-prefix
if (path.StartsWith(route_prefix, StringComparison.InvariantCultureIgnoreCase) && path.IndexOf("..") < 0)
{
// Strip off the route prefix and leading slash
path = path.Substring(route_prefix.Length);
if (path.StartsWith("/"))
path = path.Substring(1);
// Locate the file
path = Path.Combine(content_folder, path);
// Check it exists
if (File.Exists(path))
{
// Send it
ctx.Response.Headers.SetNormalizedHeader("Content-Type", ManosMimeTypes.GetMimeType(path));
ctx.Response.SendFile(path);
ctx.Response.End();
return;
}
}
ctx.Response.StatusCode = 404;
ctx.Response.End();
}
示例5: HandShake
public void HandShake(IManosContext ctx)
{
var id = GenerateId();
int heartbeat_timeout = 15;
int close_timeout = 25;
string[] supported_transports = new string[] { "websocket" }; //websocket
ctx.Response.End(id + ":" + heartbeat_timeout.ToString() + ":" + close_timeout.ToString() + ":" + string.Join(",", supported_transports));
}
示例6: SaveSessionState
public void SaveSessionState(IManosContext ctx, SessionState state)
{
if (!state.Modified)
return;
// Just store it
m_ActiveSessions[state.SessionID] = state;
}
示例7: Echo
public void Echo(IManosContext ctx, String value, int id)
{
ctx.Response.SetHeader("Content-Type","text/html");
for(; id > 0; id--)
{
ctx.Response.Write(value + "<br/>");
}
ctx.Response.End();
}
示例8: SubmitLink
public void SubmitLink(IManosContext ctx, Shorty app, string link, bool show_info)
{
string id = GenerateHash (link, 5);
if (show_info)
ctx.Response.SetCookie ("show_info", "true");
Cache [id] = new LinkData (link);
ctx.Response.Redirect ("/r/" + id + "~");
}
示例9: RenderStache
public static void RenderStache(this ManosModule mod, IManosContext ctx, string template, object obj)
{
var t = new Template ();
var path = Path.Combine (TEMPLATE_DIR, template);
using (var r = new StreamReader (path)) {
t.Load (r);
}
t.Render (obj, new StreamWriter (ctx.Response.Stream), locator.GetTemplate);
ctx.Response.End ();
}
示例10: OnError
public void OnError(IManosContext ctx)
{
foreach (IManosPipe pipe in AppHost.Pipes) {
try {
pipe.OnError (ctx);
} catch (Exception e) {
Console.Error.WriteLine ("Exception in {0}::OnError", pipe);
Console.Error.WriteLine (e);
}
}
}
示例11: Manual
public void Manual(IManosContext ctx, string manual)
{
string md_page;
if (!manuals.TryGetValue (manual, out md_page)) {
ctx.Response.StatusCode = 404;
return;
}
WriteMarkdownDocsPage (ctx.Response, md_page);
}
示例12: Index
public void Index(IManosContext ctx)
{
ctx.Response.WriteLine (@"<html>
<head><title>Welcome to Shorty</title></head>
<body>
<form method='POST' action='submit-link'>
<input type='text' name='link' />
<input type='submit' />
</form>
</body>");
}
示例13: Index
public void Index(IManosContext ctx)
{
ctx.Response.End(@"<html>
<head><title>Welcome to Aqrubik</title></head>
<body>
<form method='POST' action='TestSubmit'>
<input type='text' name='link'>
<input type='submit'>
</form>
</body>
</html>");
}
示例14: Content
public void Content(IManosContext ctx)
{
var recommender = MyRecommender.Instance.Predictor;
var ratings = MyRecommender.Instance.Data;
Log.Info("stats");
ctx.Response.WriteLine("MyMediaLite recommender: {0}", recommender);
ctx.Response.WriteLine("Rating statistics: " + ratings.Statistics());
ctx.Response.End();
}
示例15: Content
public static void Content(IManosContext ctx)
{
string path = ctx.Request.LocalPath;
if (path.StartsWith ("/"))
path = path.Substring (1);
if (File.Exists (path)) {
ctx.Response.SendFile (path);
} else
ctx.Response.StatusCode = 404;
}