-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImpConfiguration.cs
More file actions
94 lines (79 loc) · 2.48 KB
/
Copy pathImpConfiguration.cs
File metadata and controls
94 lines (79 loc) · 2.48 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/**************
.UseImp<MyPages>()
or
.UseImp<MyPages>(ImpConfiguration
.NotFoundType<NotFoundPage>()
.RootPageNamespace("ConsoleTest.Pages")
.RootTemplateNamespace("ConsoleTest.Templates")
.CDNPrefix("cnd.domain.com")
);
Overloads to get strings with a delegate instead
Or a .FromConfiguration which takes an IImpConfiguration instance
NotFoundType could potentially be found by looking for attributes in assembly
- error out if more than one is found, or just use first one
Any way to avoid using a string for namespaces?
**************/
using System;
using System.Reflection;
using static Imp.ImpMiddleware;
namespace Imp
{
public class ImpConfiguration
{
internal Assembly pageAssembly { get; private set; }
internal Type notFoundPageType { get; private set; }
internal string rootPageNamespace { get; private set; }
internal string rootTemplateNamespace { get; private set; }
internal string cdnPrefix { get; private set; }
internal NotFoundCallback onNotFound { get; private set; }
internal CdnResolutionEvent onBuildCdnPath { get; private set; }
internal PageCycleEvent onPreRender { get; private set; }
internal AuthenticateLogonCallback authenticate { get; private set; }
internal ImpConfiguration() { }
public ImpConfiguration PageAssembly(Assembly assembly)
{
pageAssembly = assembly;
return this;
}
public ImpConfiguration NotFoundPageType<T>()
{
notFoundPageType = typeof(T);
return this;
}
public ImpConfiguration OnNotFound(NotFoundCallback callback)
{
onNotFound = callback;
return this;
}
public ImpConfiguration OnBuildCdnPath(CdnResolutionEvent callback)
{
onBuildCdnPath = callback;
return this;
}
public ImpConfiguration OnPreRender(PageCycleEvent callback)
{
onPreRender = callback;
return this;
}
public ImpConfiguration Authenticate(AuthenticateLogonCallback callback)
{
authenticate = callback;
return this;
}
public ImpConfiguration RootPageNamespace(string value)
{
rootPageNamespace = value;
return this;
}
public ImpConfiguration RootTemplateNamespace(string value)
{
rootTemplateNamespace = value;
return this;
}
public ImpConfiguration CdnPrefix(string value)
{
cdnPrefix = value;
return this;
}
}
}