Xamarin.Essentials/VersionTracking/VersionTracking.shared.cs
/// <summary>
/// Initialize VersionTracking module, load data and track current version
/// </summary>
/// <remarks>
/// For internal use. Usually only called once in production code, but multiple times in unit tests
/// </remarks>
Initialize VersionTracking module, load data and track current version
Initialize VersionTracking module load data and track current version
internal static void InitVersionTracking()
        {
            IsFirstLaunchEver = !Preferences.ContainsKey(versionsKey, sharedName) || !Preferences.ContainsKey(buildsKey, sharedName);
            if (IsFirstLaunchEver)
            {
                versionTrail = new Dictionary<string, List<string>>
                {
                    { versionsKey, new List<string>() },
                    { buildsKey, new List<string>() }
                };
            }
            else
            {
                versionTrail = new Dictionary<string, List<string>>
                {
                    { versionsKey, ReadHistory(versionsKey).ToList() },
                    { buildsKey, ReadHistory(buildsKey).ToList() }
                };
            }
            IsFirstLaunchForCurrentVersion = !versionTrail[versionsKey].Contains(CurrentVersion) || CurrentVersion != LastInstalledVersion;
            if (IsFirstLaunchForCurrentVersion)
            {
                versionTrail[versionsKey].RemoveAll(v => v == CurrentVersion);
                versionTrail[versionsKey].Add(CurrentVersion);
            }
            IsFirstLaunchForCurrentBuild = !versionTrail[buildsKey].Contains(CurrentBuild) || CurrentBuild != LastInstalledBuild;
            if (IsFirstLaunchForCurrentBuild)
            {
                versionTrail[buildsKey].RemoveAll(b => b == CurrentBuild);
                versionTrail[buildsKey].Add(CurrentBuild);
            }
            if (IsFirstLaunchForCurrentVersion || IsFirstLaunchForCurrentBuild)
            {
                WriteHistory(versionsKey, versionTrail[versionsKey]);
                WriteHistory(buildsKey, versionTrail[buildsKey]);
            }
        }
internal static void InitVersionTracking ( ) { IsFirstLaunchEver = ! Preferences . ContainsKey ( versionsKey , sharedName ) || ! Preferences . ContainsKey ( buildsKey , sharedName ) ; if ( IsFirstLaunchEver ) { versionTrail = new Dictionary < string , List < string > > { { versionsKey , new List < string > ( ) } , { buildsKey , new List < string > ( ) } } ; } else { versionTrail = new Dictionary < string , List < string > > { { versionsKey , ReadHistory ( versionsKey ) . ToList ( ) } , { buildsKey , ReadHistory ( buildsKey ) . ToList ( ) } } ; } IsFirstLaunchForCurrentVersion = ! versionTrail [ versionsKey ] . Contains ( CurrentVersion ) || CurrentVersion != LastInstalledVersion ; if ( IsFirstLaunchForCurrentVersion ) { versionTrail [ versionsKey ] . RemoveAll ( v => v == CurrentVersion ) ; versionTrail [ versionsKey ] . Add ( CurrentVersion ) ; } IsFirstLaunchForCurrentBuild = ! versionTrail [ buildsKey ] . Contains ( CurrentBuild ) || CurrentBuild != LastInstalledBuild ; if ( IsFirstLaunchForCurrentBuild ) { versionTrail [ buildsKey ] . RemoveAll ( b => b == CurrentBuild ) ; versionTrail [ buildsKey ] . Add ( CurrentBuild ) ; } if ( IsFirstLaunchForCurrentVersion || IsFirstLaunchForCurrentBuild ) { WriteHistory ( versionsKey , versionTrail [ versionsKey ] ) ; WriteHistory ( buildsKey , versionTrail [ buildsKey ] ) ; } }
Initialize VersionTracking module, load data and track current version
Initialize VersionTracking module load data and track current version
// Avoid duplicates and move current version to end of list if already present // Avoid duplicates and move current build to end of list if already present
remarks
For internal use. Usually only called once in production code, but multiple times in unit tests
For internal use . Usually only called once in production code but multiple times in unit tests