Was.OrcSearch – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | using Was.OrcSearch.Models.Interfaces; |
2 | |||
3 | namespace Was.OrcSearch.Models |
||
4 | { |
||
5 | public class ObjectWithMetadata : IObjectWithMetadata |
||
6 | { |
||
7 | public ObjectWithMetadata(object instance, IMetadataCollection metadataCollection) |
||
8 | { |
||
9 | Instance = instance; |
||
10 | MetadataCollection = metadataCollection; |
||
11 | } |
||
12 | |||
13 | public object Instance { get; } |
||
14 | |||
15 | public IMetadataCollection MetadataCollection { get; } |
||
16 | |||
17 | public virtual object GetMetadataValue(string key) |
||
18 | { |
||
19 | return GetMetadataValueWithInstance(Instance, key); |
||
20 | } |
||
21 | |||
22 | public virtual bool SetMetadataValue(string key, object value) |
||
23 | { |
||
24 | return SetMetadataValueWithInstance(Instance, key, value); |
||
25 | } |
||
26 | |||
27 | protected object GetMetadataValueWithInstance(object instance, string key) |
||
28 | { |
||
29 | var metadata = MetadataCollection.GetMetadata(key); |
||
30 | if (metadata == null) return null; |
||
31 | |||
32 | return metadata.GetValue(instance); |
||
33 | } |
||
34 | |||
35 | protected bool SetMetadataValueWithInstance(object instance, string key, object value) |
||
36 | { |
||
37 | var metadata = MetadataCollection.GetMetadata(key); |
||
38 | if (metadata == null) return false; |
||
39 | |||
40 | metadata.SetValue(instance, value); |
||
41 | return true; |
||
42 | } |
||
43 | } |
||
44 | } |