Esempio n. 1
0
 public static DateTime?GetLastUpdateDate(this EnvironmentV2.ISystemInfo self)
 {
     if (self.lastUpdateDate == null)
     {
         return(null);
     }
     return(DateTimeV2.NewDateTimeFromUnixTimestamp(self.lastUpdateDate.Value));
 }
Esempio n. 2
0
        public async Task ExampleUsage2()
        {
            var store = new InMemoryKeyValueStore();
            var prefs = new Preferences(store);

            IoC.inject.SetSingleton <IPreferences>(prefs);

            var firstStart = prefs.GetFirstStartDate();
            var lastUpdate = prefs.GetLastUpdateDate();

            Assert.True(firstStart > 0, "firstStart=" + firstStart);
            Assert.True(lastUpdate > 0, "lastUpdate=" + lastUpdate);
            var diffInMs = Math.Abs(firstStart - lastUpdate);

            Assert.True(diffInMs < 1000, "diffInMs=" + diffInMs);

            prefs = new Preferences(store);
            Assert.Equal(firstStart, prefs.GetFirstStartDate());
            Assert.Equal(lastUpdate, prefs.GetLastUpdateDate());

            EnvironmentV2.ISystemInfo sysInfo = EnvironmentV2.instance.systemInfo;
            Assert.NotNull(sysInfo);

            Assert.True(DateTime.UtcNow.ToUnixTimestampUtc() > 0, "DateTime.UtcNow=" + DateTime.UtcNow.ToUnixTimestampUtc());
            Assert.True(DateTimeV2.UtcNow.ToUnixTimestampUtc() > 0, "DateTimeV2.UtcNow=" + DateTimeV2.UtcNow.ToUnixTimestampUtc());
            Assert.True(sysInfo.latestLaunchDate > 0, "sysInfo.latestLaunchDate=" + sysInfo.latestLaunchDate);
            Assert.NotEqual(0, sysInfo.latestLaunchDate);
            Assert.NotNull(sysInfo.lastUpdateDate);
            Assert.NotNull(sysInfo.firstLaunchDate);

            if (sysInfo is EnvironmentV2.SystemInfo si)
            {
                si.appVersion += "_v2"; // Simulate that the app was updated
                prefs          = new Preferences(store);
                Assert.NotEqual(lastUpdate, prefs.GetLastUpdateDate());
                Assert.Equal(firstStart, prefs.GetFirstStartDate());
            }

            // PlayerPrefsV2.SetStringEncrypted and PlayerPrefsV2.GetStringDecrypted example:
            await prefs.SetStringEncrypted("mySecureString", "some text to encrypt", password : "******");

            var decryptedAgain = await prefs.GetStringDecrypted("mySecureString", null, password : "******");

            Assert.Equal("some text to encrypt", decryptedAgain);
        }
Esempio n. 3
0
 public static DateTime GetLatestLaunchDate(this EnvironmentV2.ISystemInfo self)
 {
     return(DateTimeV2.NewDateTimeFromUnixTimestamp(self.latestLaunchDate));
 }