コード例 #1
0
ファイル: Fallen8.cs プロジェクト: ruo2012/fallen-8
        public void Load(String path, Boolean startServices = false)
        {
            if (String.IsNullOrWhiteSpace(path))
            {
                Logger.LogInfo(String.Format("There is no path given, so nothing will be loaded."));
                return;
            }

            Logger.LogInfo(String.Format("Fallen-8 now loads a savegame from path \"{0}\"", path));

            if (ReadResource())
            {
                try
                {
                    var oldIndexFactory   = IndexFactory;
                    var oldServiceFactory = ServiceFactory;
                    oldServiceFactory.ShutdownAllServices();
                    var oldGraphElements = _graphElements;
#if __MonoCS__
                    //mono specific code
#else
                    GC.Collect();
                    GC.Collect();
                    GC.WaitForFullGCComplete(-1);
                    GC.WaitForPendingFinalizers();
#endif
                    _graphElements = new List <AGraphElement>();

                    var success = PersistencyFactory.Load(this, ref _graphElements, path, ref _currentId, startServices);

                    if (success)
                    {
                        oldIndexFactory.DeleteAllIndices();
                    }
                    else
                    {
                        _graphElements = oldGraphElements;
                        IndexFactory   = oldIndexFactory;
                        ServiceFactory = oldServiceFactory;
                        ServiceFactory.StartAllServices();
                    }

                    TrimPrivate();
                }
                finally
                {
                    FinishReadResource();
                }

                return;
            }

            throw new CollisionException(this);
        }
コード例 #2
0
        public void Save(String path, UInt32 savePartitions = 5)
        {
            if (ReadResource())
            {
                PersistencyFactory.Save(this, _graphElements, path, savePartitions, _currentId);

                FinishReadResource();

                return;
            }

            throw new CollisionException(this);
        }