Ejemplo n.º 1
0
        static VersionTracking2()
        {
            if (!Essentials.IsSupported)
            {
                IsFirstLaunchEver = !Preferences2.ContainsKey(versionsKey, sharedName);
                if (IsFirstLaunchEver)
                {
                    versionTrail = new();
                }
                else
                {
                    versionTrail = ReadHistory(versionsKey).ToList();
                }

                IsFirstLaunchForCurrentVersion = !versionTrail.Contains(CurrentVersion);
                if (IsFirstLaunchForCurrentVersion)
                {
                    versionTrail.Add(CurrentVersion);
                }

                if (IsFirstLaunchForCurrentVersion)
                {
                    WriteHistory(versionsKey, versionTrail);
                }
            }
        }
Ejemplo n.º 2
0
        static string Get(string key)
        {
            var value = Preferences2.Get(key, null);

            if (string.IsNullOrWhiteSpace(value))
            {
                value = Random2.GenerateRandomString(DeviceIdRLength, _Constants.DigitsLetters);
                Preferences2.Set(key, value);
            }
            return(value);
        }
Ejemplo n.º 3
0
        static Guid GetGuid(string key)
        {
            var value = Preferences2.Get(key, null);

            if (!(!string.IsNullOrWhiteSpace(value) && ShortGuid.TryParse(value, out Guid guid)))
            {
                guid = Guid.NewGuid();
                Preferences2.Set(key, guid.ToStringS());
            }
            return(guid);
        }
Ejemplo n.º 4
0
 static void WriteHistory(string key, IEnumerable <string> history)
 => Preferences2.Set(key, string.Join("|", history), sharedName);
Ejemplo n.º 5
0
 static string[] ReadHistory(string key)
 => Preferences2.Get(key, null, sharedName)?.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries) ?? new string[0];