-
Notifications
You must be signed in to change notification settings - Fork 20
/
BeforeUploadAttribute.cs
55 lines (48 loc) · 1.47 KB
/
BeforeUploadAttribute.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using System;
namespace RemoteFileExplorer.Editor
{
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
public class BeforeUploadAttribute : System.Attribute
{
public string description;
public int priority;
public string IncludeSrc = null;
public string IncludeDest = null;
public BeforeUploadAttribute(string description) : this(description, 0) { }
public BeforeUploadAttribute(string description, int priority)
{
this.description = description;
this.priority = priority;
}
public bool Validate(string src, string dest)
{
if (!string.IsNullOrEmpty(this.IncludeSrc))
{
src = FileUtil.FixedPath(src);
if (!src.Contains(FileUtil.FixedPath(this.IncludeSrc)))
{
return false;
}
}
if (!string.IsNullOrEmpty(this.IncludeDest))
{
dest = FileUtil.FixedPath(dest);
if (!dest.Contains(FileUtil.FixedPath(this.IncludeDest)))
{
return false;
}
}
return true;
}
}
}
/* BeforeUploadAttribute使用样例
using RemoteFileExplorer.Editor;
public class TestBeforeUpload
{
[BeforeUpload("before upload luascripts", IncludeSrc = "luascripts")]
public static void Test(string src, string dest)
{
}
}
*/