Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/07/11 12:49:03 (13 years ago)
Author:
mkommend
Message:

#1479: Merged trunk changes into branch.

Location:
branches/GP.Grammar.Editor/HeuristicLab.Persistence/3.3
Files:
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/GP.Grammar.Editor/HeuristicLab.Persistence/3.3/Core/ConfigurationService.cs

    r5445 r6377  
    4242
    4343    private static ConfigurationService instance;
     44    private static object locker = new object();
    4445    private readonly Dictionary<IFormat, Configuration> customConfigurations;
    4546
     
    6566    public static ConfigurationService Instance {
    6667      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        }
    7073      }
    7174    }
  • branches/GP.Grammar.Editor/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/NumberEnumerable2StringSerializer.cs

    r5445 r6377  
    4646
    4747    private static readonly Dictionary<Type, Type> interfaceCache = new Dictionary<Type, Type>();
     48    private static readonly object locker = new object();
    4849
    4950    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          }
    5861        }
     62        interfaceCache.Add(type, null);
    5963      }
    60       interfaceCache.Add(type, null);
    6164      return null;
    6265    }
  • branches/GP.Grammar.Editor/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/Storable/StorableReflection.cs

    r5445 r6377  
    124124    /// <param name="storableMemberInfos"></param>
    125125    /// <returns></returns>
    126     private static IEnumerable<StorableMemberInfo> DisentangleNameMapping(
    127         IEnumerable<StorableMemberInfo> storableMemberInfos) {
     126    private static IEnumerable<StorableMemberInfo> DisentangleNameMapping(IEnumerable<StorableMemberInfo> storableMemberInfos) {
    128127      var nameGrouping = new Dictionary<string, List<StorableMemberInfo>>();
    129128      foreach (StorableMemberInfo storable in storableMemberInfos) {
  • branches/GP.Grammar.Editor/HeuristicLab.Persistence/3.3/HeuristicLab.Persistence-3.3.csproj

    r6173 r6377  
    204204    <Compile Include="Default\Xml\Primitive\SimpleNumber2XmlSerializerBase.cs" />
    205205    <Compile Include="Default\Xml\Primitive\String2XmlSerializer.cs" />
     206    <Compile Include="Default\Xml\Primitive\System.Drawing\Font2XmlSerializer.cs" />
    206207    <Compile Include="Default\Xml\Primitive\TimeSpan2XmlSerializer.cs" />
    207208    <Compile Include="Default\Xml\Primitive\UInt2XmlSerializer.cs" />
  • branches/GP.Grammar.Editor/HeuristicLab.Persistence/3.3/Tests/HeuristicLab.Persistence-3.3.Tests.csproj

    r4065 r6377  
    107107  </ItemGroup>
    108108  <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>
    109113    <ProjectReference Include="..\HeuristicLab.Persistence-3.3.csproj">
    110114      <Project>{102BC7D3-0EF9-439C-8F6D-96FF0FDB8E1B}</Project>
  • branches/GP.Grammar.Editor/HeuristicLab.Persistence/3.3/Tests/UseCases.cs

    r5698 r6377  
    3939using HeuristicLab.Persistence.Interfaces;
    4040using Microsoft.VisualStudio.TestTools.UnitTesting;
     41using System.Threading.Tasks;
     42using HeuristicLab.Algorithms.GeneticAlgorithm;
    4143
    4244namespace HeuristicLab.Persistence_33.Tests {
     
    11981200      public OneWayTest() { this.value = "default"; }
    11991201      public string value;
    1200       [Storable(AllowOneWay=true)]
     1202      [Storable(AllowOneWay = true)]
    12011203      public string ReadOnly {
    12021204        get { return "ReadOnly"; }
    12031205      }
    1204       [Storable(AllowOneWay=true)]
     1206      [Storable(AllowOneWay = true)]
    12051207      public string WriteOnly {
    12061208        set { this.value = value; }
     
    12551257    }
    12561258
    1257 
     1259    [TestMethod]
     1260    public void FontTest() {
     1261      List<Font> fonts = new List<Font>() {
     1262        new Font(FontFamily.GenericSansSerif, 12),
     1263        new Font("Times New Roman", 21, FontStyle.Bold, GraphicsUnit.Pixel),
     1264        new Font("Courier New", 10, FontStyle.Underline, GraphicsUnit.Document),
     1265        new Font("Helvetica", 21, FontStyle.Strikeout, GraphicsUnit.Inch, 0, true),
     1266      };
     1267      XmlGenerator.Serialize(fonts, tempFile);
     1268      var newFonts = XmlParser.Deserialize<List<Font>>(tempFile);
     1269      Assert.AreEqual(fonts[0], newFonts[0]);
     1270      Assert.AreEqual(fonts[1], newFonts[1]);
     1271      Assert.AreEqual(fonts[2], newFonts[2]);
     1272      Assert.AreEqual(fonts[3], newFonts[3]);
     1273    }
     1274
     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    }
    12581290
    12591291    [ClassInitialize]
Note: See TracChangeset for help on using the changeset viewer.