-
Notifications
You must be signed in to change notification settings - Fork 0
/
Resource.cs
55 lines (46 loc) · 921 Bytes
/
Resource.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;
using System.Text;
using System.Threading;
using System.IO;
namespace netzlib
{
internal class Resource
{
public virtual string Content { get; set; }
}
internal class ExternalResource : Resource
{
public readonly ManualResetEvent Loaded = new ManualResetEvent(false);
public Uri Uri { get; set; }
}
internal class CompositeResource : Resource
{
public Resource[] Resources { get; set; }
public ContentFilter Filter { get; set; }
public override string Content
{
get
{
var sb = new StringBuilder();
foreach (var r in Resources)
{
if (r is ExternalResource)
{
(r as ExternalResource).Loaded.WaitOne();
}
sb.AppendLine(r.Content);
}
var content = sb.ToString();
if (Filter != null)
{
content = Filter(content);
}
return content;
}
set
{
throw new InvalidOperationException();
}
}
}
}