Changeset 6569 for branches/QAPAlgorithms/HeuristicLab.Persistence
- Timestamp:
- 07/17/11 22:51:11 (13 years ago)
- Location:
- branches/QAPAlgorithms
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/QAPAlgorithms
- Property svn:ignore
-
old new 12 12 *.psess 13 13 *.vsp 14 *.docstates
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/QAPAlgorithms/HeuristicLab.Persistence
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Persistence merged: 6356,6446,6548
- Property svn:mergeinfo changed
-
branches/QAPAlgorithms/HeuristicLab.Persistence/3.3/Core/ConfigurationService.cs
r5445 r6569 42 42 43 43 private static ConfigurationService instance; 44 private static object locker = new object(); 44 45 private readonly Dictionary<IFormat, Configuration> customConfigurations; 45 46 … … 65 66 public static ConfigurationService Instance { 66 67 get { 67 if (instance == null) 68 instance = new ConfigurationService(); 69 return instance; 68 lock (locker) { 69 if (instance == null) 70 instance = new ConfigurationService(); 71 return instance; 72 } 70 73 } 71 74 } -
branches/QAPAlgorithms/HeuristicLab.Persistence/3.3/Core/Serializer.cs
r5445 r6569 246 246 compositeSerializer.CreateMetaInfo(value), 247 247 emitTypeInfo); 248 throw CreatePersistenceException(type, "Could not determine how to serialize a value." );248 throw CreatePersistenceException(type, "Could not determine how to serialize a value.", true); 249 249 } 250 250 catch (Exception x) { … … 255 255 throw; 256 256 } else { 257 throw CreatePersistenceException(type, "Uncaught exception during serialization: " + x.Message); 257 throw CreatePersistenceException( 258 type, 259 string.Format("Uncaught exception during serialization:{0}{1}", Environment.NewLine, x), 260 false); 258 261 } 259 262 } … … 261 264 objectGraphTrace.Pop(); 262 265 } 263 } 264 265 private PersistenceException CreatePersistenceException(Type type, string message ) {266 } 267 268 private PersistenceException CreatePersistenceException(Type type, string message, bool appendConfig) { 266 269 StringBuilder sb = new StringBuilder(); 267 270 sb.Append(message) … … 270 273 .AppendLine("\"") 271 274 .Append("object graph location: ") 272 .AppendLine(string.Join(".", objectGraphTrace.ToArray())) 273 .AppendLine("No registered primitive serializer for this type:"); 274 foreach (var ps in configuration.PrimitiveSerializers) 275 sb.Append(ps.SourceType.VersionInvariantName()) 276 .Append(" ---- (") 277 .Append(ps.GetType().VersionInvariantName()) 278 .AppendLine(")"); 279 sb.AppendLine("Rejected by all composite serializers:"); 280 foreach (var cs in configuration.CompositeSerializers) 281 sb.Append("\"") 282 .Append(cs.JustifyRejection(type)) 283 .Append("\" ---- (") 284 .Append(cs.GetType().VersionInvariantName()) 285 .AppendLine(")"); 275 .AppendLine(string.Join(".", objectGraphTrace.ToArray())); 276 if (appendConfig) { 277 sb.AppendLine("No registered primitive serializer for this type:"); 278 foreach (var ps in configuration.PrimitiveSerializers) 279 sb.Append(ps.SourceType.VersionInvariantName()) 280 .Append(" ---- (") 281 .Append(ps.GetType().VersionInvariantName()) 282 .AppendLine(")"); 283 sb.AppendLine("Rejected by all composite serializers:"); 284 foreach (var cs in configuration.CompositeSerializers) 285 sb.Append("\"") 286 .Append(cs.JustifyRejection(type)) 287 .Append("\" ---- (") 288 .Append(cs.GetType().VersionInvariantName()) 289 .AppendLine(")"); 290 } 286 291 return new PersistenceException(sb.ToString()); 287 292 } -
branches/QAPAlgorithms/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/NumberEnumerable2StringSerializer.cs
r5445 r6569 46 46 47 47 private static readonly Dictionary<Type, Type> interfaceCache = new Dictionary<Type, Type>(); 48 private static readonly object locker = new object(); 48 49 49 50 public Type GetGenericEnumerableInterface(Type type) { 50 if (interfaceCache.ContainsKey(type)) 51 return interfaceCache[type]; 52 foreach (Type iface in type.GetInterfaces()) { 53 if (iface.IsGenericType && 54 iface.GetGenericTypeDefinition() == typeof(IEnumerable<>) && 55 numberConverter.CanSerialize(iface.GetGenericArguments()[0])) { 56 interfaceCache.Add(type, iface); 57 return iface; 51 lock (locker) { 52 if (interfaceCache.ContainsKey(type)) 53 return interfaceCache[type]; 54 foreach (Type iface in type.GetInterfaces()) { 55 if (iface.IsGenericType && 56 iface.GetGenericTypeDefinition() == typeof(IEnumerable<>) && 57 numberConverter.CanSerialize(iface.GetGenericArguments()[0])) { 58 interfaceCache.Add(type, iface); 59 return iface; 60 } 58 61 } 62 interfaceCache.Add(type, null); 59 63 } 60 interfaceCache.Add(type, null);61 64 return null; 62 65 } -
branches/QAPAlgorithms/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/Storable/StorableReflection.cs
r5445 r6569 124 124 /// <param name="storableMemberInfos"></param> 125 125 /// <returns></returns> 126 private static IEnumerable<StorableMemberInfo> DisentangleNameMapping( 127 IEnumerable<StorableMemberInfo> storableMemberInfos) { 126 private static IEnumerable<StorableMemberInfo> DisentangleNameMapping(IEnumerable<StorableMemberInfo> storableMemberInfos) { 128 127 var nameGrouping = new Dictionary<string, List<StorableMemberInfo>>(); 129 128 foreach (StorableMemberInfo storable in storableMemberInfos) { -
branches/QAPAlgorithms/HeuristicLab.Persistence/3.3/Default/Xml/Primitive/System.Drawing/Bitmap2XmlSerializer.cs
r5445 r6569 28 28 internal sealed class Bitmap2XmlSerializer : PrimitiveXmlSerializerBase<Bitmap> { 29 29 30 public override XmlString Format(Bitmap o) { 30 public override XmlString Format(Bitmap o) { 31 31 MemoryStream stream = new MemoryStream(); 32 o.Save(stream, ImageFormat.Png); 32 lock (o) 33 o.Save(stream, ImageFormat.Png); 33 34 byte[] array = stream.ToArray(); 34 35 Byte1DArray2XmlSerializer serializer = new Byte1DArray2XmlSerializer(); -
branches/QAPAlgorithms/HeuristicLab.Persistence/3.3/HeuristicLabPersistencePlugin.cs.frame
r6099 r6569 27 27 /// The plugin for HeuriticLab.Persistence 28 28 /// </summary> 29 [Plugin("HeuristicLab.Persistence", "3.3. 4.$WCREV$")]29 [Plugin("HeuristicLab.Persistence", "3.3.5.$WCREV$")] 30 30 [PluginFile("HeuristicLab.Persistence-3.3.dll", PluginFileType.Assembly)] 31 31 [PluginDependency("HeuristicLab.Tracing", "3.3")] -
branches/QAPAlgorithms/HeuristicLab.Persistence/3.3/Properties/AssemblyInfo.frame
r6099 r6569 52 52 // 53 53 [assembly: AssemblyVersion("3.3.0.0")] 54 [assembly: AssemblyFileVersion("3.3. 4.$WCREV$")]54 [assembly: AssemblyFileVersion("3.3.5.$WCREV$")] -
branches/QAPAlgorithms/HeuristicLab.Persistence/3.3/Tests/HeuristicLab.Persistence-3.3.Tests.csproj
r4065 r6569 107 107 </ItemGroup> 108 108 <ItemGroup> 109 <ProjectReference Include="..\..\..\HeuristicLab.Algorithms.GeneticAlgorithm\3.3\HeuristicLab.Algorithms.GeneticAlgorithm-3.3.csproj"> 110 <Project>{A51DA44F-CB35-4F6F-99F5-2A2E904AB93B}</Project> 111 <Name>HeuristicLab.Algorithms.GeneticAlgorithm-3.3</Name> 112 </ProjectReference> 109 113 <ProjectReference Include="..\HeuristicLab.Persistence-3.3.csproj"> 110 114 <Project>{102BC7D3-0EF9-439C-8F6D-96FF0FDB8E1B}</Project> -
branches/QAPAlgorithms/HeuristicLab.Persistence/3.3/Tests/Properties/AssemblyInfo.cs
r5446 r6569 53 53 // by using the '*' as shown below: 54 54 [assembly: AssemblyVersion("3.3.0.0")] 55 [assembly: AssemblyFileVersion("3.3. 3.0")]55 [assembly: AssemblyFileVersion("3.3.5.0")] -
branches/QAPAlgorithms/HeuristicLab.Persistence/3.3/Tests/UseCases.cs
r6342 r6569 39 39 using HeuristicLab.Persistence.Interfaces; 40 40 using Microsoft.VisualStudio.TestTools.UnitTesting; 41 using System.Threading.Tasks; 42 using HeuristicLab.Algorithms.GeneticAlgorithm; 41 43 42 44 namespace HeuristicLab.Persistence_33.Tests { … … 1271 1273 } 1272 1274 1273 1275 [TestMethod] 1276 public void ConcurrencyTest() { 1277 int n = 20; 1278 Task[] tasks = new Task[n]; 1279 for (int i = 0; i < n; i++) { 1280 tasks[i] = Task.Factory.StartNew((idx) => { 1281 byte[] data; 1282 using(var stream = new MemoryStream()) { 1283 XmlGenerator.Serialize(new GeneticAlgorithm(), stream); 1284 data = stream.ToArray(); 1285 } 1286 }, i); 1287 } 1288 Task.WaitAll(tasks); 1289 } 1290 1291 [TestMethod] 1292 public void ConcurrentBitmapTest() { 1293 Bitmap b = new Bitmap(300, 300); 1294 Random r = new Random(); 1295 for (int x = 0; x<b.Height; x++) { 1296 for (int y = 0; y<b.Width; y++) { 1297 b.SetPixel(x, y, Color.FromArgb(r.Next())); 1298 } 1299 } 1300 Task[] tasks = new Task[20]; 1301 byte[][] datas = new byte[tasks.Length][]; 1302 for (int i = 0; i<tasks.Length; i++) { 1303 tasks[i] = Task.Factory.StartNew((idx) => { 1304 using (var stream = new MemoryStream()) { 1305 XmlGenerator.Serialize(b, stream); 1306 datas[(int)idx] = stream.ToArray(); 1307 } 1308 }, i); 1309 } 1310 Task.WaitAll(tasks); 1311 } 1274 1312 1275 1313 [ClassInitialize]
Note: See TracChangeset
for help on using the changeset viewer.