Was.OrcSearch – Diff between revs 1 and 4

Subversion Repositories:
Rev:
Only display areas with differencesIgnore whitespace
Rev 1 Rev 4
1 using System; 1 using System;
-   2 using System.Collections;
2 using System.Collections.Generic; 3 using System.Collections.Generic;
-   4 using System.ComponentModel;
-   5 using System.Linq;
3 using System.Reflection; 6 using System.Reflection;
-   7 using System.Threading;
4 using Was.OrcSearch.Attributes; 8 using Was.OrcSearch.Attributes;
5 using Was.OrcSearch.Models; 9 using Was.OrcSearch.Models;
6 using Was.OrcSearch.Models.Interfaces; 10 using Was.OrcSearch.Models.Interfaces;
7   11  
8 namespace Was.OrcSearch.Metadata 12 namespace Was.OrcSearch.Metadata
9 { 13 {
10 public class AttributeMetadataCollection : ReflectionMetadataCollection 14 public class AttributeMetadataCollection : ReflectionMetadataCollection
11 { 15 {
12 private static readonly Dictionary<Type, List<SearchableMetadata>> _propertiesCache = 16 private static readonly Dictionary<Type, List<SearchableMetadata>> PropertiesCache =
13 new Dictionary<Type, List<SearchableMetadata>>(); 17 new Dictionary<Type, List<SearchableMetadata>>();
14   18  
15 private readonly Type _targetType; 19 private readonly Type _targetType;
16   20  
17 public AttributeMetadataCollection(Type targetType) 21 public AttributeMetadataCollection(Type targetType)
18 : base(targetType) 22 : base(targetType)
19 { 23 {
20 _targetType = targetType; 24 _targetType = targetType;
21 } 25 }
22   26  
23 public override IEnumerable<IMetadata> All 27 public override IEnumerable<IMetadata> All
24 { 28 {
25 get 29 get
26 { 30 {
27 if (_propertiesCache.TryGetValue(_targetType, out var storedProperty)) 31 if (PropertiesCache.TryGetValue(_targetType, out var storedProperty))
28 return storedProperty; 32 return storedProperty;
29   33  
30 var searchableProperties = new List<SearchableMetadata>(); 34 var searchableProperties = new List<SearchableMetadata>();
31   -  
32 var properties = _targetType.GetProperties(); 35 var properties = _targetType.GetProperties();
33 foreach (var property in properties) 36 foreach (var property in properties)
34 { 37 {
35 var searchablePropertyAttribute = -  
36 property.GetCustomAttribute(typeof(SearchablePropertyAttribute), false) as 38 if (!(property.GetCustomAttribute(typeof(SearchablePropertyAttribute), false) is
37 SearchablePropertyAttribute; 39 SearchablePropertyAttribute searchablePropertyAttribute)) continue;
38 if (searchablePropertyAttribute != null) -  
39 { -  
-   40
40 var searchableProperty = new SearchableMetadata(property); 41 var searchableProperty = new SearchableMetadata(property);
41 if (!string.IsNullOrWhiteSpace(searchablePropertyAttribute.SearchName)) 42 if (!string.IsNullOrWhiteSpace(searchablePropertyAttribute.SearchName))
42 searchableProperty.SearchName = searchablePropertyAttribute.SearchName; 43 searchableProperty.SearchName = searchablePropertyAttribute.SearchName;
43   44  
44 searchableProperty.Analyze = searchablePropertyAttribute.Analyze; 45 searchableProperty.Analyze = searchablePropertyAttribute.Analyze;
45   -  
46 searchableProperties.Add(searchableProperty); 46  
47 } 47 searchableProperties.Add(searchableProperty);
48 } 48 }
49   49  
50 _propertiesCache.Add(_targetType, searchableProperties); 50 PropertiesCache.Add(_targetType, searchableProperties);
51 return searchableProperties; 51 return searchableProperties;
52 } 52 }
53 } 53 }
54 } 54 }
55 } 55 }
56   56  
57
Generated by GNU Enscript 1.6.5.90.
57
Generated by GNU Enscript 1.6.5.90.
58   58  
59   59  
60   60