コード例 #1
0
 /// <summary>
 /// Explicit command to load the alignment manager from store.
 /// </summary>
 /// <returns>True on successful load.</returns>
 public bool Load()
 {
     if (alignmentManager != null)
     {
         return(alignmentManager.Load());
     }
     return(false);
 }
コード例 #2
0
 /// <summary>
 /// Explicit command to load the alignment manager from store.
 /// </summary>
 /// <returns>True on successful load.</returns>
 public bool Load()
 {
     DebugLogSaveLoad($"Subtree {name} Load {(alignmentManager == null ? "a=null" : "a=good")}");
     if (alignmentManager != null)
     {
         return(alignmentManager.Load());
     }
     return(false);
 }
        /// <summary>
        /// Load the WorldLocking state in a background task
        /// </summary>
        private async Task loadAsync()
        {
            if (hasPendingLoadTask || hasPendingSaveTask)
            {
                return;
            }

            hasPendingLoadTask = true;

            try
            {
                // reset in any case to guarantee clean state even if no files have been read successfully
                Reset();

                string[] tryFileNames = { stateFileNameBase, stateFileNameBase + ".old" };

                foreach (var fileName in tryFileNames)
                {
                    if (File.Exists(fileName))
                    {
                        using (var file = File.OpenRead(fileName))
                        {
                            using (var pds = Plugin.CreateDeserializer())
                            {
                                pds.IncludePersistent = true;
                                pds.IncludeTransient  = false;
                                await pds.ReadRecordFromAsync(file);

                                pds.ApplyRecord();
                            }
                        }
                        await AnchorManager.LoadAnchors();

                        if (AnchorManager.SupportsPersistence)
                        {
                            AlignmentManager.Load();
                        }

                        // finish when reading was successful
                        return;
                    }
                }
            }
            finally
            {
                hasPendingLoadTask = false;
            }
        }