public CurrentCoreVersionService(IEnumerable <ICoreVersion> coreVersions,
                                         ICurrentCoreSettings settings,
                                         IMessageBoxService messageBoxService)
        {
            this.settings = settings;
            AllVersions   = coreVersions.ToList();
            Current       = AllVersions.First();

            var savedVersion = settings.CurrentCore;

            if (savedVersion != null)
            {
                var found = AllVersions.FirstOrDefault(v => v.Tag == savedVersion);
                if (found != null)
                {
                    Current = found;
                }
                else
                {
                    messageBoxService.ShowDialog(new MessageBoxFactory <bool>().SetIcon(MessageBoxIcon.Error)
                                                 .SetTitle("Error while loading core version")
                                                 .SetMainInstruction("Unknown core version")
                                                 .SetContent($"You have set core version to {savedVersion} in settings, however such core is not found in modules. Switching back to default: {Current.FriendlyName}")
                                                 .WithOkButton(true)
                                                 .Build());
                    UpdateCurrentVersion(Current);
                }
            }
            else
            {
                UpdateCurrentVersion(Current);
            }
        }
Exemplo n.º 2
0
 /// <summary> Helper compilable version enumeration list. Can be used to populate various controls, like listbox. </summary>
 public static List <Game> CompilableVersions(bool experimental)
 {
     if (experimental)
     {
         return(AllVersions.Where(item => item >= Game.TR2).ToList());
     }
     else
     {
         return(AllVersions.Where(item => item >= Game.TR2 && item.Native() <= Game.TR4).ToList());
     }
 }
Exemplo n.º 3
0
        public AllVersions DownloadAllVersions()
        {
            var versions = new AllVersions();

            var json      = _jsonManager.DownloadJson(ModelResource.VersionsUrl);
            var jVersions = json["versions"].ToObject <Version[]>();

            versions.Release.AddRange(jVersions.Where(_ => _.Type == ModelResource.release).Select(_ => _.Id));
            versions.Snapshot.AddRange(jVersions.Where(_ => _.Type == ModelResource.snapshot).Select(_ => _.Id));
            versions.Beta.AddRange(jVersions.Where(_ => _.Type == ModelResource.beta).Select(_ => _.Id));
            versions.Alpha.AddRange(jVersions.Where(_ => _.Type == ModelResource.alpha).Select(_ => _.Id));

            return(versions);
        }
Exemplo n.º 4
0
        static SqlEngineVersions()
        {
            var versionClassTypes = typeof(SqlEngineVersions).Assembly.GetTypes().Where(x => !x.IsAbstract && x.IsClass && typeof(SqlEngineVersion).IsAssignableFrom(x));

            foreach (var cls in versionClassTypes)
            {
                var staticInstanceProperties = cls.GetProperties(BindingFlags.Static | BindingFlags.Public).Where(x => x.PropertyType == cls);
                foreach (var prop in staticInstanceProperties)
                {
                    var version = prop.GetValue(null) as SqlEngineVersion;
                    AllVersions.Add(version);
                }
            }
        }
Exemplo n.º 5
0
        public static SqlEngineVersion GetSqlEngineVersion(this LightWeight.AdoNet.NamedConnectionString connectionString)
        {
            var versionsByType = AllVersions.GroupBy(x => x.GetType());

            foreach (var group in versionsByType)
            {
                var matches = group
                              .Where(version => string.Equals(connectionString.ProviderName, version.ProviderName, StringComparison.InvariantCultureIgnoreCase))
                              .ToList();

                if (matches.Count > 0)
                {
                    return(matches.Find(x => string.Equals(x.VersionString, connectionString.Version, StringComparison.InvariantCultureIgnoreCase)));
                }
            }

            return(null);
        }
        //nastavi vyhledavaci masku
        public void GetSelectionMask()
        {
            List <VersionEntityDB> allVersionsFromDB = versionsRepository.GetAllVersions();

            if (AllVersions == null)
            {
                AllVersions = new List <SelectListItem>();
            }

            if (AllVersions.Count == 0)
            {
                foreach (VersionEntityDB version in allVersionsFromDB)
                {
                    AllVersions.Add(new SelectListItem {
                        Text = version.Name, Value = version.Name
                    });
                }
            }
        }
Exemplo n.º 7
0
        public void Update()
        {
            // This brings the current database up to date. Use with care! It should probably not be accessible to end users, but only from Admin tools.
            bool appliedUpdate = true;

            // first apply all updates that are missing from this database's list of versions
            List <ITransition> missingUpdates = new List <ITransition>();

            foreach (ITransition v in Versions)
            {
                if (!AllVersions.Contains(v.VersionNumber) && v.VersionNumber < DatabaseVersion)
                {
                    missingUpdates.Add(v);
                }
            }
            missingUpdates.Sort((x, y) => x.VersionNumber.CompareTo(y.VersionNumber));
            foreach (ITransition v in missingUpdates)
            {
                if (!RunUpdate(v))
                {
                    throw new Exception(string.Format("Version number {0} reported an error applying the update.", v.VersionNumber));
                }
            }

            // now update the remaining
            while (!IsCurrent() && appliedUpdate)
            {
                // With the below orderby, there's now no point in doing these in two separate passes - but I want some more tests before I make that change
                foreach (ITransition v in Versions.OrderBy(v => v.VersionNumber))
                {
                    if (v.VersionNumber > DatabaseVersion)
                    {
                        appliedUpdate = RunUpdate(v);
                        if (!appliedUpdate)
                        {
                            throw new Exception(string.Format("Version number {0} reported an error applying the update.", v.VersionNumber));
                        }
                    }
                }
            }
        }