Changeset 1893 for trunk/sources
- Timestamp:
- 05/25/09 18:04:44 (16 years ago)
- Location:
- trunk/sources/HeuristicLab.Persistence/3.3/Default
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/Storable/StorableAttribute.cs
r1852 r1893 20 20 BindingFlags.DeclaredOnly; 21 21 22 private static Dictionary<KeyValuePair<Type, bool>, IEnumerable<KeyValuePair<StorableAttribute, MemberInfo>>> memberCache = 23 new Dictionary<KeyValuePair<Type, bool>, IEnumerable<KeyValuePair<StorableAttribute, MemberInfo>>>(); 24 22 25 public static IEnumerable<KeyValuePair<StorableAttribute, MemberInfo>> GetStorableMembers(Type type) { 23 26 return GetStorableMembers(type, true); … … 26 29 public static IEnumerable<KeyValuePair<StorableAttribute, MemberInfo>> 27 30 GetStorableMembers(Type type, bool inherited) { 31 var query = new KeyValuePair<Type, bool>(type, inherited); 32 if (memberCache.ContainsKey(query)) 33 return memberCache[query]; 34 IEnumerable<KeyValuePair<StorableAttribute, MemberInfo>> storablesMembers = GenerateStorableMembers(type, inherited); 35 memberCache[query] = storablesMembers; 36 return storablesMembers; 37 } 38 39 public static IEnumerable<KeyValuePair<StorableAttribute, MemberInfo>> 40 GenerateStorableMembers(Type type, bool inherited) { 41 List<KeyValuePair<StorableAttribute, MemberInfo>> storableMembers = 42 new List<KeyValuePair<StorableAttribute, MemberInfo>>(); 28 43 if (inherited && type.BaseType != null) 29 foreach (var pair in GetStorableMembers(type.BaseType)) 30 yield return pair; 44 storableMembers.AddRange(GenerateStorableMembers(type.BaseType, true)); 31 45 foreach (MemberInfo memberInfo in type.GetMembers(instanceMembers)) { 32 46 foreach (object attribute in memberInfo.GetCustomAttributes(false)) { … … 34 48 attribute as StorableAttribute; 35 49 if (storableAttribute != null) { 36 yield return new KeyValuePair<StorableAttribute, MemberInfo>(storableAttribute, memberInfo);50 storableMembers.Add(new KeyValuePair<StorableAttribute, MemberInfo>(storableAttribute, memberInfo)); 37 51 } 38 52 } 39 53 } 54 return storableMembers; 40 55 } 41 56 -
trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Primitive/String2XmlSerializer.cs
r1853 r1893 19 19 } 20 20 21 private static Regex re = new Regex(@"<!\[CDATA\[((?:[^]]|\](?!\]>))*)\]\]>", RegexOptions.Singleline); 22 21 23 public override string Parse(XmlString x) { 22 24 StringBuilder sb = new StringBuilder(); 23 Regex re = new Regex(@"<!\[CDATA\[((?:[^]]|\](?!\]>))*)\]\]>", RegexOptions.Singleline);24 25 foreach (Match m in re.Matches(x.Data)) { 25 26 sb.Append(m.Groups[1]);
Note: See TracChangeset
for help on using the changeset viewer.