-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWebServiceHost.cs
79 lines (69 loc) · 2.26 KB
/
WebServiceHost.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
Copyright (c) 2011, thinktecture (http://www.thinktecture.com).
All rights reserved, comes as-is and without any warranty. Use of this
source file is governed by the license which is contained in LICENSE.TXT
in the distribution.
*/
using System;
using System.Collections.Generic;
namespace Thinktecture.ServiceModel
{
/// <summary>
/// Custom WebServiceHost with bootstrap task support.
/// </summary>
public class WebServiceHost : System.ServiceModel.Web.WebServiceHost
{
private IList<IBootstrapTask> bootstrapTasks;
public IList<IBootstrapTask> BootstrapTasks
{
get
{
if (bootstrapTasks == null)
{
bootstrapTasks = new List<IBootstrapTask>();
}
return bootstrapTasks;
}
}
/// <summary>
/// Initializes a new instance of the <see cref="WebServiceHost"/> class.
/// </summary>
protected WebServiceHost()
: base()
{
}
/// <summary>
/// Initializes a new instance of the <see cref="WebServiceHost"/> class.
/// </summary>
public WebServiceHost(Type serviceType, params Uri[] baseAddresses)
: base(serviceType, baseAddresses)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="WebServiceHost"/> class.
/// </summary>
public WebServiceHost(object singeltonInstance, params Uri[] baseAddresses)
: base(singeltonInstance, baseAddresses)
{
}
/// <summary>
/// Initializes the runtime for the service host.
/// </summary>
/// <exception cref="T:System.InvalidOperationException">The description of the service hosted is null.</exception>
protected override void InitializeRuntime()
{
base.InitializeRuntime();
ExecuteBootstrapTasks();
}
private void ExecuteBootstrapTasks()
{
foreach (var task in BootstrapTasks)
{
if (task != null)
{
task.Execute();
}
}
}
}
}