-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(项目首次提交)
- Loading branch information
unknown
committed
Oct 7, 2016
0 parents
commit f085155
Showing
221 changed files
with
48,162 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace Moon.Mvc | ||
{ | ||
/// <summary> | ||
/// 用于修饰控制器域名 | ||
/// </summary> | ||
public class AreaAttribute : Attribute | ||
{ | ||
public string AreaName | ||
{ | ||
get; set; | ||
} | ||
public AreaAttribute(string areaName) | ||
{ | ||
this.AreaName = areaName; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using System; | ||
using System.Reflection; | ||
|
||
namespace Moon.Mvc | ||
{ | ||
/// <summary> | ||
/// 告诉action不要验证请求是否安全(往往包括html标签) | ||
/// </summary> | ||
public class DontValidateRequestAttribute : Attribute | ||
{ | ||
|
||
} | ||
/// <summary> | ||
/// Post请求 | ||
/// </summary> | ||
public class PostAttribute : Attribute | ||
{ | ||
|
||
} | ||
/// <summary> | ||
/// Get 请求 | ||
/// </summary> | ||
public class GetAttribute : Attribute | ||
{ | ||
|
||
} | ||
/// <summary> | ||
/// 方面注入的基类 | ||
/// </summary> | ||
public abstract class AspectAttribute : Attribute | ||
{ | ||
/// <summary> | ||
/// 优先级,数值越大优先级越大,AspectAttributePriority枚举 | ||
/// </summary> | ||
public int Priority{ | ||
get; | ||
set; | ||
} | ||
public AspectAttribute(){ | ||
Priority=AspectAttributePriority.Common; | ||
} | ||
public virtual AspectResultType BeforeInvoke(MethodInfo methodInfo,System.Web.HttpContext context ) | ||
{ | ||
return AspectResultType.Continue; | ||
} | ||
public virtual AspectResultType AfterInvoke(MethodInfo methodInfo,System.Web.HttpContext context ) | ||
{ | ||
return AspectResultType.Continue; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* 由SharpDevelop创建。 | ||
* 用户: qscq | ||
* 日期: 2014/8/27 | ||
* 时间: 16:59 | ||
* | ||
* 要改变这种模板请点击 工具|选项|代码编写|编辑标准头文件 | ||
*/ | ||
using System; | ||
using Moon.Orm.Util; | ||
namespace Moon.Mvc | ||
{ | ||
/// <summary> | ||
/// 通过告诉客户端304状态进行缓存 | ||
/// </summary> | ||
public class Client304Expires:AspectAttribute | ||
{ | ||
/// <summary> | ||
/// 缓存有效期 | ||
/// </summary> | ||
protected int TimeOut{ | ||
get; | ||
set; | ||
} | ||
/// <summary> | ||
/// 构造 | ||
/// </summary> | ||
/// <param name="howlong">客户端缓存有效期</param> | ||
public Client304Expires(int howlong){ | ||
this.TimeOut=howlong; | ||
this.Priority=AspectAttributePriority.High; | ||
} | ||
/// <summary> | ||
/// action执行之前 | ||
/// </summary> | ||
/// <param name="methodInfo"></param> | ||
/// <param name="context"></param> | ||
/// <returns></returns> | ||
public override AspectResultType AfterInvoke(System.Reflection.MethodInfo methodInfo, System.Web.HttpContext context) | ||
{ | ||
return AspectResultType.Continue; | ||
} | ||
/// <summary> | ||
/// action执行之后 | ||
/// </summary> | ||
/// <param name="methodInfo"></param> | ||
/// <param name="context"></param> | ||
/// <returns></returns> | ||
public override AspectResultType BeforeInvoke(System.Reflection.MethodInfo methodInfo, System.Web.HttpContext context) | ||
{ | ||
|
||
DateTime dt; | ||
if (DateTime.TryParse(context.Request.Headers["If-Modified-Since"], out dt)) | ||
{ | ||
// 注意:如果是20秒内,我就以304的方式响应。 | ||
if ((DateTime.Now - dt).TotalSeconds < TimeOut) | ||
{ | ||
context.Response.StatusCode = 304; | ||
context.Response.End(); | ||
return AspectResultType.Stop; | ||
} | ||
} | ||
|
||
string time = DateTime.Now.AddSeconds(TimeOut).ToUniversalTime().ToString("r"); | ||
context.Response.AddHeader("Last-Modified", time); | ||
return AspectResultType.Continue; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* 由SharpDevelop创建。 | ||
* 用户: qscq | ||
* 日期: 2014/8/27 | ||
* 时间: 16:59 | ||
* | ||
* 要改变这种模板请点击 工具|选项|代码编写|编辑标准头文件 | ||
*/ | ||
using System; | ||
using Moon.Orm.Util; | ||
namespace Moon.Mvc | ||
{ | ||
/// <summary> | ||
/// 通过给客户端设置Expires头来决定过期时间. | ||
/// </summary> | ||
public class ClientExpires:AspectAttribute | ||
{ | ||
/// <summary> | ||
/// 客户端缓存时间 | ||
/// </summary> | ||
protected int TimeOut{ | ||
get; | ||
set; | ||
} | ||
/// <summary> | ||
/// 构造 | ||
/// </summary> | ||
/// <param name="howlong">过期时间(秒)</param> | ||
public ClientExpires(int howlong){ | ||
this.TimeOut=howlong; | ||
this.Priority=AspectAttributePriority.High; | ||
} | ||
/// <summary> | ||
/// action执行前 | ||
/// </summary> | ||
/// <param name="methodInfo">方法信息</param> | ||
/// <param name="context">httpcontext</param> | ||
/// <returns>该方法的反馈信息</returns> | ||
public override AspectResultType AfterInvoke(System.Reflection.MethodInfo methodInfo, System.Web.HttpContext context) | ||
{ | ||
return AspectResultType.Continue; | ||
} | ||
public override AspectResultType BeforeInvoke(System.Reflection.MethodInfo methodInfo, System.Web.HttpContext context) | ||
{ | ||
string time=DateTime.Now.AddSeconds(TimeOut).ToUniversalTime().ToString("r"); | ||
context.Response.AddHeader("Expires",time); | ||
return AspectResultType.Continue; | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* 由SharpDevelop创建。 | ||
* 用户: qscq | ||
* 日期: 2014/8/28 | ||
* 时间: 21:20 | ||
* | ||
* 要改变这种模板请点击 工具|选项|代码编写|编辑标准头文件 | ||
*/ | ||
using System; | ||
using Moon.Orm; | ||
|
||
namespace Moon.Mvc | ||
{ | ||
/// <summary> | ||
/// Description of TimeLogAttribute. | ||
/// </summary> | ||
public class TimeLogAttribute:AspectAttribute | ||
{ | ||
public TimeLogAttribute(){ | ||
this.Priority=AspectAttributePriority.High; | ||
} | ||
protected long _start; | ||
public override AspectResultType BeforeInvoke(System.Reflection.MethodInfo methodInfo, System.Web.HttpContext context) | ||
{ | ||
_start=DateTime.Now.Ticks; | ||
return AspectResultType.Continue; | ||
} | ||
public override AspectResultType AfterInvoke (System.Reflection.MethodInfo methodInfo, System.Web.HttpContext context) | ||
{ | ||
var classFullName=methodInfo.DeclaringType.FullName; | ||
var methodName=methodInfo.Name; | ||
var result=DateTime.Now.Ticks-_start; | ||
TimeSpan ts = new TimeSpan(result); | ||
//var time=result/10000000; | ||
string msg = classFullName + "." + methodName+" spent time(s):"+ts.TotalSeconds; | ||
Moon.Orm.Util.LogUtil.Write("执行时间", msg); | ||
return AspectResultType.Continue; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System; | ||
using System.Reflection; | ||
|
||
namespace Moon.Mvc | ||
{ | ||
/// <summary> | ||
/// 注入特性类优先级(如果默认则使用Common) | ||
/// </summary> | ||
public static class AspectAttributePriority | ||
{ | ||
/// <summary> | ||
/// 最高级别,10000 | ||
/// </summary> | ||
public const int Highest = 10000; | ||
/// <summary> | ||
/// 高级,1000 | ||
/// </summary> | ||
public const int High = 1000; | ||
/// <summary> | ||
/// 通常所用的级别,100 | ||
/// </summary> | ||
public const int Common = 100; | ||
/// <summary> | ||
/// 低级,10 | ||
/// </summary> | ||
public const int Low = 10; | ||
/// <summary> | ||
/// 最低级,0 | ||
/// </summary> | ||
public const int Lowest = 0; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System; | ||
using System.Reflection; | ||
|
||
namespace Moon.Mvc | ||
{ | ||
public enum AspectResultType | ||
{ | ||
/// <summary> | ||
/// 继续后续操作 | ||
/// </summary> | ||
Continue, | ||
/// <summary> | ||
/// 终止后续操作 | ||
/// </summary> | ||
Stop, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace Moon.Mvc | ||
{ | ||
public interface ICaptcha | ||
{ | ||
string Value | ||
{ | ||
get; | ||
set; | ||
} | ||
byte[] GetImageByte(); | ||
} | ||
} |
Oops, something went wrong.