Example #1
0
        public void UpdatePasswordsByNewMasterPassword(string newMasterKey)
        {
            // nothing to do in database, the application master password doesn't affect the database
            // but, the file persisted passwords may be lost, so we have to update them.
            var newSecurity     = new PersistenceSecurity(this.security);
            var filePersistence = new FilePersistence(newSecurity, this.favoriteIcons, this.connectionManager);

            filePersistence.Initialize();
            filePersistence.UpdatePasswordsByNewMasterPassword(newMasterKey);
        }
Example #2
0
        private Autoya(string basePath = "")
        {
            // Debug.LogWarning("autoya initialize start. basePath:" + basePath);

            var isPlayer = false;

            if (Application.isPlaying)
            {
                isPlayer = true;

                // create game object for Autoya.
                var go = GameObject.Find("AutoyaMainthreadDispatcher");
                if (go == null)
                {
                    go = new GameObject("AutoyaMainthreadDispatcher");
                    this.mainthreadDispatcher = go.AddComponent <AutoyaMainThreadDispatcher>();
                    GameObject.DontDestroyOnLoad(go);
                }
                else
                {
                    this.mainthreadDispatcher = go.GetComponent <AutoyaMainThreadDispatcher>();
                }
            }
            else
            {
                // create editor runnner for Autoya.
                this.mainthreadDispatcher = new EditorUpdator();
            }

            _autoyaFilePersistence = new FilePersistence(basePath);

            _autoyaHttp = new HTTPConnection();

            InitializeAssetBundleFeature();

            InitializeAppManifest();

            var isFirstBoot = IsFirstBoot();

            /*
             *  start authentication.
             */
            Authenticate(
                isFirstBoot,
                () => {
                /*
                 *  initialize purchase feature.
                 */
                if (isPlayer)
                {
                    ReloadPurchasability();
                }
            }
                );
        }
Example #3
0
    public static void LatestConnectionRecord(ref string record)
    {
        var fp = new FilePersistence(Application.persistentDataPath);

        if (fp.IsExist("connectionRecord", "latestIp"))
        {
            record = fp.Load("connectionRecord", "latestIp");
            return;
        }
        record = "";
    }
Example #4
0
 protected override OptionResult Run(GameHitParameters <GameObject> parameters)
 {
     if (FilePersistence.ExportToFile())
     {
         return(OptionResult.SuccessClose);
     }
     else
     {
         return(OptionResult.Failure);
     }
 }
Example #5
0
        public static BasicNetwork loadNetwork(byte[] networkBytes)
        {
            FilePersistence location = new FilePersistence();

            location.AddStreamData(networkBytes);
            EncogPersistedCollection collection    = new EncogPersistedCollection(location, FileMode.Open);
            BasicNetwork             returnNetwork = (BasicNetwork)collection.Find("neuralNet");

            //Make sure we have the flattended network cached.
            returnNetwork.Structure.FinalizeStructure();

            return(returnNetwork);
        }
Example #6
0
        public void CustomIcon_UpdateFavoriteIcon_DoesntSaveFavorite()
        {
            var favorite = this.AddFavorite();

            this.Favorites.UpdateFavoriteIcon(favorite, ImageAssert.IMAGE_FILE);
            FilePersistence secondaryPersistence = CreateFilePersistence();
            IFavorite       checkfavorite        = secondaryPersistence.Favorites.FirstOrDefault();
            Image           favoriteIcon         = secondaryPersistence.Favorites.LoadFavoriteIcon(checkfavorite);

            string testDeploymentDir = this.TestContext.TestDeploymentDir;

            ImageAssert.DoesntEqualsExpectedIcon(testDeploymentDir, favoriteIcon);
        }
Example #7
0
        public void DisabledPlugins_SaveFavorites_UnknownProtocolsArePreserved()
        {
            this.AddVncRdpFavorites();
            FilePersistence limitedPersistence = CreateLimitedPersistence();
            var             favorite           = limitedPersistence.Favorites.First();

            favorite.Notes = "irrelevant change";
            limitedPersistence.Favorites.Update(favorite);
            var  secondary    = CreateFilePersistence();
            bool keepsUnknown = secondary.Favorites.Any(f => f.Protocol == "VNC");

            Assert.IsTrue(keepsUnknown, "Persistence is not able to serialize unknown protocols.");
        }
Example #8
0
        void App_Startup(object sender, StartupEventArgs eventArgs)
        {
            _viewModel = new EditorViewModel();
            _window    = new MainWindow();
            FilePersistence dataAccess = new FilePersistence();

            _model = new EditorModel(dataAccess);

            _model.FileOpened   += new EventHandler <FileOperationEventArgs>(_viewModel.Model_FileOpened);
            _model.FileSaved    += new EventHandler <FileOperationEventArgs>(_viewModel.Model_FileSaved);
            _viewModel.SaveFile += new EventHandler <FileOperationEventArgs>(ViewModel_FileSaved);
            _viewModel.OpenFile += new EventHandler <FileOperationEventArgs>(ViewModel_FileOpened);

            _window.DataContext = _viewModel;
            _window.Show();
        }
        /// <summary>
        /// Create an object based on the specified location.
        /// </summary>
        /// <param name="location">The location to load/save from.</param>
        /// <param name="mode">The file mode.</param>
        public EncogPersistedCollection(IPersistenceLocation location, FileMode mode)
        {
            this.filePrimary = location;

            if (this.filePrimary is FilePersistence)
            {
                FilePersistence locationObj = (FilePersistence)this.filePrimary;

                if (locationObj.containsByteData)
                {
                    this.fileTemp = new FilePersistence();
                    ((FilePersistence)this.fileTemp).AddStreamData(locationObj.byteData);

                    if (this.filePrimary.Exists())
                    {
                        BuildDirectory();
                    }
                }
                else
                {
                    String file = locationObj.FileName;

                    int index = file.LastIndexOf('.');
                    if (index != -1)
                    {
                        file = file.Substring(0, index);
                    }
                    file         += ".tmp";
                    this.fileTemp = new FilePersistence(file);

                    if (this.filePrimary.Exists())
                    {
                        BuildDirectory();
                    }
                    else
                    {
                        Create();
                    }
                }
            }
            else
            {
                this.fileTemp = null;
            }
        }
Example #10
0
 protected override bool PrivatePerform()
 {
     return(FilePersistence.ExportToFile());
 }
Example #11
0
 public HashHit(FilePersistence fp)
 {
     this.filePersist = fp;
 }
Example #12
0
 protected override bool PrivatePerform()
 {
     return(FilePersistence.ImportFromFile());
 }
Example #13
0
    private void StartReceiving(Action <string> onReceived)
    {
        Debug.Log("start receiveing data.");
        ShowEditorLocalIP();

        // WS -> updateへのデータの転送を行うチャンネル。
        var chan = Chan <OnUpdatePayload> .Make();

        // updateでデータを受け取るブロック。
        chan.Receive(
            (data, ok) =>
        {
            if (!ok)
            {
                return;
            }

            onReceived(data.payload);
        }
            );

        var fp = new FilePersistence(Application.persistentDataPath);

        ws = new WebuSocket(
            "ws://" + "127.0.0.1" + ":1129",
            10240,
            () =>
        {
            // 接続できたipを保存
            fp.Update("connectionRecord", "latestIp", "127.0.0.1");

            // var data = new byte[1300];
            // // for (var i = 0; i < data.Length; i++)
            // // {
            // //     data[i] = (byte)UnityEngine.Random.Range(0, 100);
            // // }

            // try
            // {
            //     ws.Send(data);
            // }
            // catch (Exception e)
            // {
            //     Debug.Log("ここだ" + e);
            // }

            // do nothng.
        },
            segments =>
        {
            // データを受け取った。受け取りは非メインスレッドなので、メインスレッドに転送する必要がある。
            while (0 < segments.Count)
            {
                var data  = segments.Dequeue();
                var bytes = new byte[data.Count];
                Buffer.BlockCopy(data.Array, data.Offset, bytes, 0, data.Count);

                // updateブロックへと転送する
                var jsonPayload     = new OnUpdatePayload();
                jsonPayload.payload = Encoding.UTF8.GetString(bytes);
                chan.Send(jsonPayload);
            }
        },
            () => { },
            closedEnum =>
        {
            Debug.Log("closedEnum:" + closedEnum);
        },
            (error, reason) =>
        {
            Debug.Log("error:" + error + " reason:" + reason);
        },
            new Dictionary <string, string> {
            { "local", "" }
        }
            );
    }
Example #14
0
 public EditorModel(FilePersistence persistence)
 {
     filePersistence = persistence;
 }
Example #15
0
        public void OnTimer()
        {
            try
            {
                if (StoryProgression.Main == null)
                {
                    return;
                }

                Scenarios.IncStat("OnTimer Try");

                if (mInTimer)
                {
                    return;
                }

                mWatch.Restart();

                try
                {
                    mInTimer = true;

                    mRunning = true;

                    if (GetValue <ShowStartScreenOption, bool>())
                    {
                        FilePersistence.ImportFromTuning("NRaas.StoryProgression.Tuning");

                        if (!GetValue <ProgressionOption, bool>())
                        {
                            if (AcceptCancelDialog.Show(Localize("Welcome")))
                            {
                                GetOption <ProgressionOption>().SetValue(true);

                                new InitialHomelessScenario().Post(Households, true, false);
                            }
                        }
                    }

                    GetOption <ShowStartScreenOption>().SetValue(false);

                    if (GetValue <ProgressionOption, bool>())
                    {
                        int currentInterval = LifeSpan.GetHumanAgeSpanLength();

                        if (GetValue <LastAskedIntervalOption, int>() != currentInterval)
                        {
                            if (AcceptCancelDialog.Show(Localize("AgeSpan")))
                            {
                                AdjustSpeedForAgeSpan((float)currentInterval / GetValue <SavedIntervalOption, int>());

                                GetOption <SavedIntervalOption>().SetValue(currentInterval);
                            }

                            GetOption <LastAskedIntervalOption>().SetValue(currentInterval);
                        }
                    }

                    Update(false, false);
                }
                finally
                {
                    mInTimer = false;
                }

                Scenarios.IncStat("OnTimer Complete");
            }
            catch (Exception exception)
            {
                Common.Exception(UnlocalizedName, exception);
            }
        }
Example #16
0
        private static IFavorite LoadFavoriteFromSecondaryPersistence()
        {
            FilePersistence secondaryPersistence = CreateFilePersistence();

            return(secondaryPersistence.Favorites.FirstOrDefault());
        }
Example #17
0
 public URLCache(FilePersistence fp)
 {
     this.filePersist = fp;
 }
Example #18
0
        private Autoya(string basePath = "")
        {
            // Debug.LogWarning("autoya initialize start. basePath:" + basePath);

            var isPlayer = false;

            if (Application.isPlaying)
            {
                isPlayer = true;

                // create game object for Autoya.
                var go = GameObject.Find("AutoyaMainthreadDispatcher");
                if (go == null)
                {
                    go = new GameObject("AutoyaMainthreadDispatcher");
                    this.mainthreadDispatcher = go.AddComponent <AutoyaMainthreadDispatcher>();
                    GameObject.DontDestroyOnLoad(go);
                }
                else
                {
                    this.mainthreadDispatcher = go.GetComponent <AutoyaMainthreadDispatcher>();
                }
            }
            else
            {
                // create editor runnner for Autoya.
                this.mainthreadDispatcher = new EditorUpdator();
            }

            _autoyaFilePersistence = new FilePersistence(basePath);
            _notification          = new Notifications(AutoyaMainthreadDispatcher.AddNativeObserver);
            _autoyaHttp            = new HTTPConnection();

            InitializeAppManifest();

            // setup response handling.
            this.httpResponseHandlingDelegate = HttpResponseHandling;

            /*
             *  endPoint -> AB -> OnBootLoop -> authentication.
             */
            IEnumerator bootSequence()
            {
                // EndPointSelector initialize and update.
                {
                    InitializeEndPointImplementation();

retryEndPointRequest:
                    var failed = false;
                    var cor  = UpdateEndPoints(() => failed = true);
                    var cont = cor.MoveNext();
                    if (cont)
                    {
                        yield return(null);

                        while (cor.MoveNext())
                        {
                            yield return(null);
                        }
                    }

                    if (failed)
                    {
                        if (ShouldRetryEndPointGetRequestOrNot())
                        {
                            goto retryEndPointRequest;
                        }
                    }
                }

                // initialize AB feature.
                {
                    var cor  = InitializeAssetBundleFeature();
                    var cont = cor.MoveNext();
                    if (cont)
                    {
                        yield return(null);

                        while (cor.MoveNext())
                        {
                            yield return(null);
                        }
                    }
                }

                // boot app loop.
                {
                    var cor  = OnBootApplication();
                    var cont = cor.MoveNext();
                    if (cont)
                    {
                        yield return(null);

                        while (cor.MoveNext())
                        {
                            yield return(null);
                        }
                    }
                }

                // check if first boot or not.
                {
                    var cor = IsFirstBoot(
                        isFirstBoot =>
                    {
                        /*
                         *  start authentication.
                         */
                        Authenticate(
                            isFirstBoot,
                            () =>
                        {
                            /*
                             *  initialize purchase feature.
                             */
                            if (isPlayer)
                            {
                                ReloadPurchasability();
                            }
                        }
                            );
                    }
                        );

                    // run 1st loop for getting autoya instance.
                    var cont = cor.MoveNext();
                    if (cont)
                    {
                        yield return(null);

                        while (cor.MoveNext())
                        {
                            yield return(null);
                        }
                    }
                }
            }

            mainthreadDispatcher.Commit(bootSequence());
        }
 public void UpdatePasswordsByNewMasterPassword(string newMasterKey)
 {
     // nothing to do in database, the application master password doesn't affect the database
     // but, the file persisted passwords may be lost, so we have to update them
     var newSecurity = new PersistenceSecurity(this.security);
     var filePersistence = new FilePersistence(newSecurity);
     filePersistence.Initialize();
     filePersistence.UpdatePasswordsByNewMasterPassword(newMasterKey);
 }