Was.OrcSearch – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | using System; |
2 | using System.Collections.Generic; |
||
3 | using System.Linq; |
||
4 | using Was.OrcSearch.Models.Interfaces; |
||
5 | |||
6 | namespace Was.OrcSearch.Models |
||
7 | { |
||
8 | public class ReflectionMetadataCollection : MetadataCollectionBase |
||
9 | { |
||
10 | #region Fields |
||
11 | |||
12 | private static readonly Dictionary<Type, IEnumerable<IMetadata>> MetadataCache = |
||
13 | new Dictionary<Type, IEnumerable<IMetadata>>(); |
||
14 | |||
15 | #endregion |
||
16 | |||
17 | #region Constructors |
||
18 | |||
19 | public ReflectionMetadataCollection(Type type) |
||
20 | { |
||
21 | if (MetadataCache.TryGetValue(type, out var storedMetadata)) |
||
22 | { |
||
23 | All = storedMetadata; |
||
24 | return; |
||
25 | } |
||
26 | |||
27 | var metadata = type.GetProperties().Select(x => new ReflectionMetadata(x)).ToArray(); |
||
28 | MetadataCache.Add(type, metadata); |
||
29 | All = metadata; |
||
30 | } |
||
31 | |||
32 | #endregion |
||
33 | |||
34 | #region Properties |
||
35 | |||
36 | public override IEnumerable<IMetadata> All { get; } |
||
37 | |||
38 | #endregion |
||
39 | } |
||
40 | } |