Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/08/19 00:23:12 (5 years ago)
Author:
mkommend
Message:

#2520: Merged 16584, 16585,16594,16595, 16625, 16658, 16659, 16672, 16707, 16729, 16792, 16796, 16797, 16799, 16819, 16906, 16907, 16908, 16933, 16945, 16992, 16994, 16995, 16996, 16997, 17014, 17015, 17017, 17020, 17021, 17022, 17023, 17024, 17029, 17086, 17087, 17088, 17089 into stable.

Location:
stable
Files:
1 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Common/3.3/Content/ContentManager.cs

    r17097 r17105  
    2121
    2222using System;
     23using System.Collections.Generic;
     24using System.Linq;
    2325using System.Threading;
     26using System.Threading.Tasks;
     27using HEAL.Attic;
    2428
    2529namespace HeuristicLab.Common {
    2630  public abstract class ContentManager {
     31    public class Info {
     32      public Info() { }
     33
     34      public Info(string filename, TimeSpan duration) {
     35        Filename = filename;
     36        Duration = duration;
     37      }
     38
     39      public Info(string filename, SerializationInfo serInfo) {
     40        Filename = filename;
     41        Duration = serInfo.Duration;
     42        UnknownTypeGuids = serInfo.UnknownTypeGuids;
     43        NumberOfSerializedObjects = serInfo.NumberOfSerializedObjects;
     44        SerializedTypes = serInfo.SerializedTypes;       
     45      }
     46
     47      public TimeSpan Duration { get; internal set; }
     48      public IEnumerable<Guid> UnknownTypeGuids { get; internal set; } = Enumerable.Empty<Guid>();
     49      public int NumberOfSerializedObjects { get; internal set; }
     50      public IEnumerable<Type> SerializedTypes { get; internal set; } = Enumerable.Empty<Type>();
     51      public string Filename { get; internal set; } = string.Empty;
     52    }
     53
    2754    private static ContentManager instance;
    2855
     
    3663
    3764    public static IStorableContent Load(string filename) {
     65      return Load(filename, out var _);
     66    }
     67
     68    public static IStorableContent Load(string filename, out Info serializationInfo) {
    3869      if (instance == null) throw new InvalidOperationException("ContentManager is not initialized.");
    39       IStorableContent content = instance.LoadContent(filename);
    40       content.Filename = filename;
     70      IStorableContent content = instance.LoadContent(filename, out serializationInfo);
     71     
     72      if (content != null) content.Filename = filename;
    4173      return content;
    4274    }
    43     public static void LoadAsync(string filename, Action<IStorableContent, Exception> loadingCompletedCallback) {
     75
     76
     77    public static Task LoadAsync(string filename, Action<IStorableContent, Exception> loadingCompletedCallback) {
     78      return LoadAsync(filename, (content, error, info) => loadingCompletedCallback(content, error)); // drop info
     79    }
     80
     81    public static async Task LoadAsync(string filename, Action<IStorableContent, Exception, Info> loadingCompletedCallback) {
    4482      if (instance == null) throw new InvalidOperationException("ContentManager is not initialized.");
    45       var func = new Func<string, IStorableContent>(instance.LoadContent);
    46       func.BeginInvoke(filename, delegate (IAsyncResult result) {
    47         Exception error = null;
    48         IStorableContent content = null;
    49         try {
    50           content = func.EndInvoke(result);
    51           content.Filename = filename;
    52         } catch (Exception ex) {
    53           error = ex;
    54         }
    55         loadingCompletedCallback(content, error);
    56       }, null);
     83
     84      Exception error = null;
     85      IStorableContent result = null;
     86      Info serializationInfo = null;
     87      try {
     88        result = await Task.Run(() => {
     89          var content = instance.LoadContent(filename, out serializationInfo);
     90          if(content!=null) content.Filename = filename;
     91          return content;
     92        });
     93      } catch(Exception ex) {
     94        error = ex;
     95      }
     96      loadingCompletedCallback(result, error, serializationInfo);
    5797    }
    58     protected abstract IStorableContent LoadContent(string filename);
     98
     99    protected abstract IStorableContent LoadContent(string filename, out Info serializationInfo);
    59100
    60101    public static void Save(IStorableContent content, string filename, bool compressed, CancellationToken cancellationToken = default(CancellationToken)) {
  • stable/HeuristicLab.Common/3.3/HeuristicLab.Common-3.3.csproj

    r17097 r17105  
    105105  </PropertyGroup>
    106106  <ItemGroup>
    107     <Reference Include="Google.Protobuf, Version=3.6.1.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
    108       <HintPath>..\..\packages\Google.Protobuf.3.6.1\lib\net45\Google.Protobuf.dll</HintPath>
    109     </Reference>
    110     <Reference Include="HEAL.Attic, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    111       <HintPath>..\..\packages\HEAL.Attic.1.0.0-pre02\lib\net461\HEAL.Attic.dll</HintPath>
    112     </Reference>
    113107    <Reference Include="System" />
    114108    <Reference Include="System.Core">
     
    116110    </Reference>
    117111    <Reference Include="System.Drawing" />
    118     <Reference Include="System.Drawing.Common, Version=4.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
    119       <HintPath>..\..\packages\System.Drawing.Common.4.5.1\lib\net461\System.Drawing.Common.dll</HintPath>
    120     </Reference>
    121112    <Reference Include="System.Xml.Linq">
    122113      <RequiredTargetFramework>3.5</RequiredTargetFramework>
     
    134125    <Compile Include="AsyncHelper.cs" />
    135126    <Compile Include="CancelEventArgs.cs" />
    136     <None Include="packages.config" />
    137127    <None Include="Plugin.cs.frame" />
    138128    <Compile Include="ColorGradient.cs" />
     
    194184    </BootstrapperPackage>
    195185  </ItemGroup>
     186  <ItemGroup>
     187    <Reference Include="HEAL.Attic, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     188      <SpecificVersion>False</SpecificVersion>
     189      <HintPath>..\..\bin\HEAL.Attic.dll</HintPath>
     190      <Private>False</Private>
     191    </Reference>
     192  </ItemGroup>
    196193  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
    197194  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
  • stable/HeuristicLab.Common/3.3/Plugin.cs.frame

    r17097 r17105  
    3131  [Plugin("HeuristicLab.Common", "3.3.15.$WCREV$")]
    3232  [PluginFile("HeuristicLab.Common-3.3.dll", PluginFileType.Assembly)]
    33   [PluginDependency("HeuristicLab.Persistence", "3.3")]
     33  [PluginDependency("HeuristicLab.Attic", "1.0")]
    3434  public class HeuristicLabCommonPlugin : PluginBase {
    3535  }
Note: See TracChangeset for help on using the changeset viewer.