-
Notifications
You must be signed in to change notification settings - Fork 476
Expand file tree
/
Copy pathWhiteExecution.cs
More file actions
53 lines (45 loc) · 1.88 KB
/
WhiteExecution.cs
File metadata and controls
53 lines (45 loc) · 1.88 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
using System;
using System.Collections.Generic;
using TestStack.White.Bricks;
using TestStack.White.Reporting.Configuration;
using TestStack.White.Reporting.Domain;
using TestStack.White.ScreenObjects.Configuration;
namespace TestStack.White.ScreenObjects.Services
{
public class WhiteExecution : IDisposable
{
private readonly ServiceExecution serviceExecution = new NullServiceExecution();
private readonly IReport sessionReport = new NullSessionReport();
private readonly Dictionary<Type, Service> services = new Dictionary<Type, Service>();
protected WhiteExecution() {}
public WhiteExecution(ServiceExecution serviceExecution, IReport sessionReport)
{
this.serviceExecution = serviceExecution;
this.sessionReport = sessionReport;
}
public static WhiteExecution Create(ServiceExecution serviceExecution, IReport sessionReport)
{
return new WhiteExecution(serviceExecution, sessionReport);
}
public virtual void Dispose()
{
serviceExecution.Dispose();
}
public virtual T GetService<T>(params object[] objs) where T : Service
{
Service service;
if (services.TryGetValue(typeof (T), out service)) return (T) service;
service = (T) Activator.CreateInstance(typeof(T), objs);
if (RepositoryConfigurationLocator.Get().UseHistory || ReportingConfigurationLocator.Get().PublishTestReports)
{
service = (Service) DynamicProxyGenerator.Instance.CreateProxy(typeof (T), new ServiceInterceptor(service, serviceExecution, sessionReport));
services.Add(typeof (T), service);
}
return (T) service;
}
public virtual ServiceExecution ServiceExecution
{
get { return serviceExecution; }
}
}
}