Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/17/10 16:42:58 (14 years ago)
Author:
mkommend
Message:

Removed cloning of saved contents and refactored FileManager (ticket #1143).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Common/3.3/Content/ContentManager.cs

    r3500 r4245  
    6060    public static void Save(IStorableContent content, string filename, bool compressed) {
    6161      if (instance == null) throw new InvalidOperationException("ContentManager is not initialized.");
    62       instance.SaveContent((IStorableContent)content.Clone(), filename, compressed);
     62      instance.SaveContent(content, filename, compressed);
    6363      content.Filename = filename;
    6464    }
    6565    public static void SaveAsync(IStorableContent content, string filename, bool compressed, Action<IStorableContent, Exception> savingCompletedCallback) {
    6666      if (instance == null) throw new InvalidOperationException("ContentManager is not initialized.");
     67      var action = new Action<IStorableContent, string, bool>(instance.SaveContent);
     68      action.BeginInvoke(content, filename, compressed, delegate(IAsyncResult result) {
     69        Exception error = null;
     70        try {
     71          action.EndInvoke(result);
     72          content.Filename = filename;
     73        }
     74        catch (Exception ex) {
     75          error = ex;
     76        }
     77        savingCompletedCallback(content, error);
     78      }, null);
    6779
    68       IStorableContent clone = null;
    69       try {
    70         clone = (IStorableContent)content.Clone();
    71       }
    72       catch (Exception ex) {
    73         savingCompletedCallback(content, ex);
    74       }
    75 
    76       if (clone != null) {
    77         var action = new Action<IStorableContent, string, bool>(instance.SaveContent);
    78         action.BeginInvoke(clone, filename, compressed, delegate(IAsyncResult result) {
    79           Exception error = null;
    80           try {
    81             action.EndInvoke(result);
    82             content.Filename = filename;
    83           }
    84           catch (Exception ex) {
    85             error = ex;
    86           }
    87           savingCompletedCallback(content, error);
    88         }, null);
    89       }
    9080    }
    9181    protected abstract void SaveContent(IStorableContent content, string filename, bool compressed);
Note: See TracChangeset for help on using the changeset viewer.