Ejemplo n.º 1
0
        private void TryImportBlockData()
        {
            LocalFileIO blockIO = new LocalFileIO($"{QuickActionHudSpace.Target?.TypeID}.bin");

            byte[] byteData;

            if (blockIO.FileExists && blockIO.TryRead(out byteData) == null)
            {
                BlockData data;

                if (Utils.ProtoBuf.TryDeserialize(byteData, out data) == null)
                {
                    QuickActionHudSpace.Target.ImportSettings(data);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Attempts to load config file and creates a new one if it can't.
        /// </summary>
        private BvException TryLoad(out ConfigData cfg)
        {
            string      data;
            BvException exception = cfgFile.TryRead(out data);

            cfg = null;

            if (exception != null || data == null)
            {
                return(exception);
            }
            else
            {
                exception = TryDeserializeXml(data, out cfg);
            }

            if (exception != null)
            {
                Backup();
                TrySave(ConfigData.Defaults);
            }

            return(exception);
        }