Esempio n. 1
0
 /// <summary>
 /// Converts the specified values.
 /// </summary>
 /// <param name="values">The values.</param>
 /// <param name="targetType">Type of the target.</param>
 /// <param name="parameter">The parameter.</param>
 /// <param name="culture">The culture.</param>
 /// <returns>System.Object.</returns>
 public object Convert(IList <object> values, Type targetType, object parameter, CultureInfo culture)
 {
     if (values != null && values.Count == 2)
     {
         if (values[0] is IEnumerable <IDefinition> col && values[1] is IDefinition definition)
         {
             var service = DIResolver.Get <IModPatchCollectionService>();
             if (service.IsPatchMod(definition.ModName))
             {
                 return("PatchMod");
             }
             var clean = new List <IDefinition>();
             foreach (var item in col)
             {
                 if (!service.IsPatchMod(item.ModName))
                 {
                     clean.Add(item);
                 }
             }
             var priority = service.EvalDefinitionPriority(clean);
             if (priority?.Definition == definition)
             {
                 return("CopiedDefinition");
             }
         }
     }
     return(string.Empty);
 }
        static void Main(string[] args)
        {
            var diResolver = new DIResolver();

            var shortStayStrategy = diResolver.Get <IParkingChargeStrategy, ShortStayStrategy>();
            var longStayStrategy  = diResolver.Get <IParkingChargeStrategy, LongStayStrategy>();

            var calculator = diResolver.Get <IParkingCostCalculator>();

            calculator.SetStrategy(shortStayStrategy);

            Console.WriteLine(
                calculator.Calculate(DateTime.Parse("01/08/2020 00:00:00"), DateTime.Parse("02/08/2020 23:59:59"))
                );

            Console.WriteLine(
                calculator.Calculate(DateTime.Parse("07/09/2017 16:50:00"), DateTime.Parse("09/09/2017 19:15:00"))
                );

            calculator.SetStrategy(longStayStrategy); // swap strategy

            Console.WriteLine(
                calculator.Calculate(DateTime.Parse("07/09/2017 07:50:00"), DateTime.Parse("07/09/2017 08:20:00"))
                );

            Console.WriteLine(
                calculator.Calculate(DateTime.Parse("07/09/2017 07:50:00"), DateTime.Parse("09/09/2017 05:20:00"))
                );
        }
Esempio n. 3
0
        /// <summary>
        /// Resolves the user control.
        /// </summary>
        /// <param name="obj">The object.</param>
        /// <returns>UserControl.</returns>
        public virtual UserControl ResolveUserControl(object obj)
        {
            var name = FormatUserControlName(obj);
            var type = AssemblyManager.FindType(name);

            return((UserControl)DIResolver.Get(type));
        }
Esempio n. 4
0
        /// <summary>
        /// Resolves the view model.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns>ViewModelBase.</returns>
        public virtual IViewModel ResolveViewModel <T>() where T : Window
        {
            var name = FormatViewModelName <T>();
            var type = AssemblyManager.FindType(name);

            return((IViewModel)DIResolver.Get(type));
        }
Esempio n. 5
0
        /// <summary>
        /// Initializes the avalonia options.
        /// </summary>
        /// <param name="app">The application.</param>
        private static void InitAvaloniaOptions(AppBuilder app)
        {
            void configureLinux()
            {
                var configuration = DIResolver.Get <IPlatformConfiguration>().GetOptions().LinuxOptions;

                if (configuration.UseGPU.HasValue || configuration.UseEGL.HasValue || configuration.UseDBusMenu.HasValue || configuration.UseDeferredRendering.HasValue)
                {
                    var opts = new X11PlatformOptions();
                    if (configuration.UseGPU.HasValue)
                    {
                        opts.UseGpu = configuration.UseGPU.GetValueOrDefault();
                    }
                    if (configuration.UseEGL.HasValue)
                    {
                        opts.UseEGL = configuration.UseEGL.GetValueOrDefault();
                    }
                    if (configuration.UseDBusMenu.HasValue)
                    {
                        opts.UseDBusMenu = configuration.UseDBusMenu.GetValueOrDefault();
                    }
                    if (configuration.UseDeferredRendering.HasValue)
                    {
                        opts.UseDeferredRendering = configuration.UseDeferredRendering.GetValueOrDefault();
                    }
                    app.With(opts);
                }
            }

            configureLinux();
        }
Esempio n. 6
0
        /// <summary>
        /// Initializes the themes.
        /// </summary>
        private void InitThemes()
        {
            var currentTheme = DIResolver.Get <IThemeService>().GetSelected();
            var themeManager = DIResolver.Get <IThemeManager>();

            themeManager.ApplyTheme(currentTheme.Type);

            var themeListener = MessageBus.Current.Listen <ThemeChangedEventArgs>();

            themeListener.SubscribeObservable(x =>
            {
                OnThemeChanged().ConfigureAwait(true);
            });
            var idGenerator      = DIResolver.Get <IIDGenerator>();
            var languageListener = MessageBus.Current.Listen <LocaleChangedEventArgs>();

            languageListener.SubscribeObservable(x =>
            {
                var window = (MainWindow)Helpers.GetMainWindow();
                var id     = idGenerator.GetNextId();
                window.ViewModel.TriggerManualOverlay(id, true, string.Empty);
                SetFontFamily(window, x.Locale);
                window.ViewModel.TriggerManualOverlay(id, false, string.Empty);
            });
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="MergeViewerControlView" /> class.
 /// </summary>
 public MergeViewerControlView()
 {
     logger = DIResolver.Get <ILogger>();
     hotkeyPressedHandler = DIResolver.Get <ConflictSolverViewHotkeyPressedHandler>();
     resourceLoader       = DIResolver.Get <IResourceLoader>();
     InitializeComponent();
 }
 /// <summary>
 /// Initializes the localization manager.
 /// </summary>
 private static void InitLocalizationManager()
 {
     if (localizationManager == null)
     {
         localizationManager = DIResolver.Get <ILocalizationManager>();
     }
 }
Esempio n. 9
0
        public UniTask Initialize()
        {
            _playerDataGetter  = DIResolver.GetObject <PlayerDataGetter>();
            _playerDataMutator = DIResolver.GetObject <PlayerDataMutator>();

            return(UniTask.CompletedTask);
        }
Esempio n. 10
0
        public ViewResult Index(Customer customer)
        {
            if (ModelState.IsValid)
            {
                //DEPENDENCY INJECTION!!
                //ICustomerRepository customerrepo = new XMLCustomerRepository();
                //IOrderRepository orderrepo = new XMLOrderRepository();
                ICustomerRepository customerrepo = (ICustomerRepository)DIResolver.GetClass <ICustomerRepository>();
                IOrderRepository    orderrepo    = (IOrderRepository)DIResolver.GetClass <IOrderRepository>();


                //Save Client
                int customerid = customerrepo.SaveClient(customer);

                //Save Order
                ShoppingCart sscart  = new ShoppingCart(Session["cart"]);
                int          orderid = orderrepo.SaveOrder(customerid, sscart);


                ViewBag.OrderNo = orderid;
                ViewBag.Name    = customer.Title + " " + customer.FirstName + " " + customer.LastName;

                return(View("ThankYou"));
            }
            else
            {
                return(View());
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Runs the generic double property test.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="prop">The property.</param>
        /// <param name="value">The value.</param>
        /// <param name="prop2">The prop2.</param>
        /// <param name="value2">The value2.</param>
        /// <param name="checkChanged">The check changed.</param>
        private void RunGenericDoublePropTest <T>(string prop, object value, string prop2, object value2, bool checkChanged) where T : class, IModel
        {
            DISetup.SetupContainer();
            var events = new List <string>();
            var model  = DIResolver.Get <T>();

            if (checkChanged)
            {
                model.PropertyChanged += (s, e) =>
                {
                    events.Add(e.PropertyName);
                };
            }
            else
            {
                model.PropertyChanging += (s, e) =>
                {
                    events.Add(e.PropertyName);
                };
            }
            model.GetType().GetProperty(prop).SetValue(model, value);
            model.GetType().GetProperty(prop2).SetValue(model, value2);
            events.Count.Should().Be(2);
            events.First().Should().Be(prop);
            events.Last().Should().Be(prop2);
        }
Esempio n. 12
0
        public ShoppingCart Add(int prodid)
        {
            int      qty          = 1;
            ItemCart existingItem = Cart.Find(p => p.ProductId == prodid);

            if (existingItem != null)
            {
                qty = existingItem.Quantity + 1;
                Cart.Remove(existingItem);
            }

            //DEPENDENCY INJECTION!!

            //IProductRepository prodrepo = new XMLProductRepository();
            IProductRepository prodrepo = (IProductRepository)DIResolver.GetClass <IProductRepository>();


            Product selectedprod = prodrepo.GetProduct(prodid);
            string  prodname     = selectedprod.Name;
            decimal prodprice    = selectedprod.Price;

            Cart.Add(new ItemCart()
            {
                ProductId = prodid,
                Product   = prodname,
                Quantity  = qty,
                UnitPrice = prodprice,
                Price     = decimal.Round(qty * prodprice, 2)
            });

            return(this);
        }
Esempio n. 13
0
        /// <summary>
        /// Logs the error.
        /// </summary>
        /// <param name="e">The e.</param>
        private static void LogError(Exception e)
        {
            if (e != null)
            {
                var logger = DIResolver.Get <ILogger>();
                logger.Error(e);

                var title   = Constants.UnhandledErrorTitle;
                var message = Constants.UnhandledErrorMessage;
                var header  = Constants.UnhandledErrorHeader;
                try
                {
                    var locManager = DIResolver.Get <ILocalizationManager>();
                    title   = locManager.GetResource(LocalizationResources.FatalError.Title);
                    message = locManager.GetResource(LocalizationResources.FatalError.Message);
                    header  = locManager.GetResource(LocalizationResources.FatalError.Header);
                }
                catch
                {
                }
                var messageBox = MessageBoxes.GetFatalErrorWindow(title, header, message);
                // We're deadlocking the thread, so kill the task after x amount of seconds.
                messageBox.ShowAsync().Wait(TimeSpan.FromSeconds(10));
                Dispatcher.UIThread.InvokeAsync(() => Environment.Exit(0));
            }
        }
Esempio n. 14
0
        private async Task <Dictionary <string, string> > GetAllAsync()
        {
            var result     = new Dictionary <string, string>();
            var assemblies = DIResolver.GetAssemblies();

            foreach (var assembly in assemblies)
            {
                var resourceNames = assembly.GetManifestResourceNames();
                foreach (var resourceName in resourceNames)
                {
                    var resourceStream = assembly.GetManifestResourceStream(resourceName);
                    if (resourceStream == null)
                    {
                        continue;
                    }

                    using (var reader = new System.IO.StreamReader(resourceStream, Encoding.UTF8))
                    {
                        var sql = await reader.ReadToEndAsync();

                        result.Add(resourceName, sql);
                    }
                }
            }
            return(result);
        }
Esempio n. 15
0
        /// <summary>
        /// Gets the file information.
        /// </summary>
        /// <param name="rootPath">The root path.</param>
        /// <param name="file">The file.</param>
        /// <returns>IFileInfo.</returns>
        public virtual IFileInfo GetFileInfo(string rootPath, string file)
        {
            var fileInfo = GetStreamInternal(rootPath, file);

            using var stream = fileInfo.Item1;
            if (stream != null)
            {
                var info = DIResolver.Get <IFileInfo>();
                info.FileName   = file;
                info.IsReadOnly = fileInfo.Item2;
                info.Size       = stream.Length;
                if (Constants.TextExtensions.Any(s => file.EndsWith(s, StringComparison.OrdinalIgnoreCase)))
                {
                    using var streamReader = new StreamReader(stream, true);
                    var text = streamReader.ReadToEnd();
                    streamReader.Close();
                    info.IsBinary   = false;
                    info.Content    = text.SplitOnNewLine(false);
                    info.ContentSHA = text.CalculateSHA();
                }
                else
                {
                    info.IsBinary   = true;
                    info.ContentSHA = stream.CalculateSHA();
                }
                return(info);
            }
            return(null);
        }
        /// <summary>
        /// cleanup updater as an asynchronous operation.
        /// </summary>
        private async Task CleanupUpdaterAsync()
        {
            foreach (var path in StaticResources.GetUpdaterPath())
            {
                if (Directory.Exists(path))
                {
                    bool cleanup          = true;
                    var  settingsFileName = Path.Combine(path, Constants.UpdateSettings);
                    if (File.Exists(settingsFileName))
                    {
                        var fileInfo = new FileInfo(settingsFileName);
                        var text     = await File.ReadAllTextAsync(settingsFileName);

                        var settings = JsonConvert.DeserializeObject <UpdateSettings>(text);
                        // At least 72 since last update to cleanup
                        cleanup = (settings.Updated || settings.IsInstaller) && fileInfo.LastWriteTime <= DateTime.Now.AddHours(-72);
                    }
                    if (cleanup)
                    {
                        await Task.Delay(5000);

                        try
                        {
                            Directory.Delete(path, true);
                        }
                        catch (Exception ex)
                        {
                            var logger = DIResolver.Get <ILogger>();
                            logger.Error(ex);
                        }
                    }
                }
            }
        }
Esempio n. 17
0
        /// <summary>
        /// Initializes the fatal error message.
        /// </summary>
        /// <param name="desktop">The desktop.</param>
        private void InitFatalErrorMessage(IClassicDesktopStyleApplicationLifetime desktop)
        {
            async Task close()
            {
                await Task.Delay(10000);

                var appAction = DIResolver.Get <IAppAction>();
                await Dispatcher.UIThread.SafeInvokeAsync(async() =>
                {
                    await appAction.ExitAppAsync();
                });
            }

            var locManager = DIResolver.Get <ILocalizationManager>();
            var title      = locManager.GetResource(LocalizationResources.FatalError.Title);
            var message    = locManager.GetResource(LocalizationResources.FatalError.Message);
            var header     = locManager.GetResource(LocalizationResources.FatalError.Header);
            var messageBox = MessageBoxes.GetFatalErrorWindow(title, header, message);

            SetFontFamily(messageBox);
            desktop.MainWindow = messageBox;

            var stateService = DIResolver.Get <IWindowStateService>();

            if (!stateService.IsDefined() || stateService.IsMaximized())
            {
                desktop.MainWindow.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            }
            close().ConfigureAwait(false);
        }
Esempio n. 18
0
        /// <summary>
        /// Reads the JSON representation of the object.
        /// </summary>
        /// <param name="reader">The <see cref="T:Newtonsoft.Json.JsonReader" /> to read from.</param>
        /// <param name="objectType">Type of the object.</param>
        /// <param name="existingValue">The existing value of object being read.</param>
        /// <param name="serializer">The calling serializer.</param>
        /// <returns>The object value.</returns>
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            reader.Read();
            var    typeName = reader.ReadAsString();
            object instance;

            if (typeName.StartsWith(nameof(IEnumerable)))
            {
                var splitType    = typeName.Split(Constants.EnumerableOpenTag, StringSplitOptions.RemoveEmptyEntries)[1].Replace(Constants.EnumerableCloseTag, string.Empty).Trim();
                var type         = AssemblyManager.FindType(splitType);
                var resolvedType = DIResolver.GetImplementationType(type);
                instance = Activator.CreateInstance(typeof(List <>).MakeGenericType(resolvedType));
            }
            else
            {
                var type = AssemblyManager.FindType(typeName);
                instance = DIResolver.Get(type);
            }

            reader.Read();
            var propName = reader.ReadAsString();

            reader.Read();
            reader.Read();
            serializer.Populate(reader, instance);

            reader.Read();

            return(new StoreItem()
            {
                Name = propName, Value = instance, Type = typeName
            });
        }
Esempio n. 19
0
        /// <summary>
        /// Generates the patch mod descriptor.
        /// </summary>
        /// <param name="allMods">All mods.</param>
        /// <param name="game">The game.</param>
        /// <param name="patchName">Name of the patch.</param>
        /// <returns>IMod.</returns>
        protected virtual IMod GeneratePatchModDescriptor(IEnumerable <IMod> allMods, IGame game, string patchName)
        {
            var mod = DIResolver.Get <IMod>();

            mod.DescriptorFile = $"{Shared.Constants.ModDirectory}/{patchName}{Shared.Constants.ModExtension}";
            mod.FileName       = GetPatchModDirectory(game, patchName).Replace("\\", "/");
            mod.Name           = patchName;
            mod.Source         = ModSource.Local;
            var version = GameService.GetVersion(game);

            if (!string.IsNullOrWhiteSpace(version))
            {
                mod.Version = version;
            }
            else
            {
                mod.Version = allMods.OrderByDescending(p => p.VersionData).FirstOrDefault() != null?allMods.OrderByDescending(p => p.VersionData).FirstOrDefault().Version : string.Empty;
            }
            mod.Tags = new List <string>()
            {
                "Fixes"
            };
            mod.IsValid  = true;
            mod.FullPath = mod.FileName.StandardizeDirectorySeparator();
            return(mod);
        }
        /// <summary>
        /// import as an asynchronous operation.
        /// </summary>
        /// <param name="parameters">The parameters.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
        public async Task <ICollectionImportResult> ImportAsync(ModCollectionExporterParams parameters)
        {
            var path = Path.Combine(Path.GetDirectoryName(parameters.ModDirectory), Constants.DLC_load_path);

            if (File.Exists(path))
            {
                var result  = DIResolver.Get <ICollectionImportResult>();
                var content = await File.ReadAllTextAsync(path);

                if (!string.IsNullOrWhiteSpace(content))
                {
                    try
                    {
                        var model = JsonConvert.DeserializeObject <DLCLoad>(content);
                        if (model.EnabledMods?.Count > 0)
                        {
                            result.Name        = CollectionName;
                            result.Descriptors = model.EnabledMods;
                            return(result);
                        }
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex);
                    }
                }
            }
            return(null);
        }
        /// <summary>
        /// Reads the specified path.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <param name="allowedPaths">The allowed paths.</param>
        /// <returns>IReadOnlyCollection&lt;IFileInfo&gt;.</returns>
        public virtual IReadOnlyCollection <IFileInfo> Read(string path, IEnumerable <string> allowedPaths = null)
        {
            var files = Directory.GetFiles(path, SearchPattern, SearchOption);

            if (files?.Length > 0)
            {
                var result = new List <IFileInfo>();
                foreach (var file in files)
                {
                    var relativePath = file.Replace(path, string.Empty).Trim(Path.DirectorySeparatorChar);
                    var info         = DIResolver.Get <IFileInfo>();
                    var fileInfo     = new System.IO.FileInfo(file);
                    info.IsReadOnly = fileInfo.IsReadOnly;
                    info.Size       = fileInfo.Length;
                    var content = File.ReadAllText(file);
                    info.FileName   = relativePath;
                    info.IsBinary   = false;
                    info.Content    = content.SplitOnNewLine(false);
                    info.ContentSHA = content.CalculateSHA();
                    result.Add(info);
                }
                return(result);
            }
            return(null);
        }
Esempio n. 22
0
        /// <summary>
        /// Reads the JSON representation of the object.
        /// </summary>
        /// <param name="reader">The <see cref="T:Newtonsoft.Json.JsonReader" /> to read from.</param>
        /// <param name="objectType">Type of the object.</param>
        /// <param name="existingValue">The existing value of object being read.</param>
        /// <param name="serializer">The calling serializer.</param>
        /// <returns>The object value.</returns>
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            var instance = DIResolver.Get(objectType);

            serializer.Populate(reader, instance);
            return(instance);
        }
Esempio n. 23
0
 /// <summary>
 /// Registers the game.
 /// </summary>
 /// <param name="gameType">Type of the game.</param>
 /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
 /// <exception cref="InvalidOperationException"></exception>
 public virtual bool RegisterGame(IGameType gameType)
 {
     lock (dbLock)
     {
         if (gameType == null || Database.Games.Any(s => s.Name.Equals(gameType.Name, StringComparison.OrdinalIgnoreCase)))
         {
             throw new InvalidOperationException($"{gameType?.Name} game is already registered or invalid registration.");
         }
         var game = DIResolver.Get <IGameType>();
         game.Name                      = gameType.Name;
         game.UserDirectory             = gameType.UserDirectory ?? string.Empty;
         game.SteamAppId                = gameType.SteamAppId;
         game.WorkshopDirectory         = gameType.WorkshopDirectory ?? new List <string>();
         game.LogLocation               = gameType.LogLocation;
         game.ChecksumFolders           = gameType.ChecksumFolders ?? new List <string>();
         game.GameFolders               = gameType.GameFolders ?? new List <string>();
         game.BaseSteamGameDirectory    = gameType.BaseSteamGameDirectory ?? string.Empty;
         game.ExecutablePath            = gameType.ExecutablePath ?? string.Empty;
         game.ExecutableArgs            = gameType.ExecutableArgs ?? string.Empty;
         game.LauncherSettingsFileName  = gameType.LauncherSettingsFileName ?? string.Empty;
         game.LauncherSettingsPrefix    = gameType.LauncherSettingsPrefix ?? string.Empty;
         game.AdvancedFeaturesSupported = gameType.AdvancedFeaturesSupported;
         game.RemoteSteamUserDirectory  = gameType.RemoteSteamUserDirectory ?? new List <string>();
         game.Abrv                      = gameType.Abrv ?? string.Empty;
         Database.Games.Add(game);
         return(true);
     }
 }
Esempio n. 24
0
        /// <summary>
        /// Handles the closing.
        /// </summary>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
        protected override bool HandleClosing()
        {
            var service = DIResolver.Get <IWindowStateService>();
            var state   = service.Get();

            if (WindowState == WindowState.Maximized)
            {
                state.IsMaximized = true;
            }
            else
            {
                var totalScreenX = Screens.All.Sum(p => p.WorkingArea.Width);
                var totalScreenY = Screens.All.Max(p => p.WorkingArea.Height);
                var locX         = Position.X + ClientSize.Width > totalScreenX ? totalScreenX - ClientSize.Width : Position.X;
                var locY         = Position.Y + ClientSize.Height > totalScreenY ? totalScreenY - ClientSize.Height : Position.Y;
                if (locX < 0.0)
                {
                    locX = 0;
                }
                if (locY < 0.0)
                {
                    locY = 0;
                }
                state.Height      = Convert.ToInt32(ClientSize.Height);
                state.Width       = Convert.ToInt32(ClientSize.Width);
                state.IsMaximized = false;
                state.LocationX   = Convert.ToInt32(locX);
                state.LocationY   = Convert.ToInt32(locY);
            }
            service.Save(state);
            return(base.HandleClosing());
        }
Esempio n. 25
0
        /// <summary>
        /// Database importv3 as an asynchronous operation.
        /// </summary>
        /// <param name="parameters">The parameters.</param>
        /// <returns>A Task&lt;ICollectionImportResult&gt; representing the asynchronous operation.</returns>
        protected virtual async Task <ICollectionImportResult> DatabaseImportv3Async(ModCollectionExporterParams parameters)
        {
            try
            {
                using var con = GetConnection(parameters);
                var activeCollection = (await con.QueryAsync <Models.Paradox.v4.Playsets>(p => p.IsActive == true, trace: trace)).FirstOrDefault();
                if (activeCollection != null)
                {
                    var collectionMods = await con.QueryAsync <Models.Paradox.v4.PlaysetsMods>(p => p.PlaysetId == activeCollection.Id.ToString(), trace : trace);

                    if (collectionMods?.Count() > 0)
                    {
                        var mods = await con.QueryAllAsync <Models.Paradox.v4.Mods>(trace : trace);

                        var ordered   = collectionMods.Where(p => p.Enabled).OrderBy(p => p.Position).ToList();
                        var validMods = mods.Where(p => ordered.Any(m => m.ModId.Equals(p.Id))).OrderBy(p => ordered.FindIndex(o => o.ModId == p.Id));
                        if (validMods.Any())
                        {
                            var result = DIResolver.Get <ICollectionImportResult>();
                            result.Name        = activeCollection.Name;
                            result.Descriptors = validMods.Select(p => p.GameRegistryId).ToList();
                            result.ModNames    = validMods.Select(p => p.DisplayName).ToList();
                            return(result);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex);
            }
            return(null);
        }
Esempio n. 26
0
        /// <summary>
        /// Copies the definition.
        /// </summary>
        /// <param name="definition">The definition.</param>
        /// <returns>IDefinition.</returns>
        protected virtual IDefinition CopyDefinition(IDefinition definition)
        {
            var newDefinition = DIResolver.Get <IDefinition>();

            newDefinition.Code                 = definition.Code;
            newDefinition.ContentSHA           = definition.ContentSHA;
            newDefinition.DefinitionSHA        = definition.DefinitionSHA;
            newDefinition.Dependencies         = definition.Dependencies;
            newDefinition.ErrorColumn          = definition.ErrorColumn;
            newDefinition.ErrorLine            = definition.ErrorLine;
            newDefinition.ErrorMessage         = definition.ErrorMessage;
            newDefinition.File                 = definition.File;
            newDefinition.GeneratedFileNames   = definition.GeneratedFileNames;
            newDefinition.OverwrittenFileNames = definition.OverwrittenFileNames;
            newDefinition.AdditionalFileNames  = definition.AdditionalFileNames;
            newDefinition.Id            = definition.Id;
            newDefinition.ModName       = definition.ModName;
            newDefinition.Type          = definition.Type;
            newDefinition.UsedParser    = definition.UsedParser;
            newDefinition.ValueType     = definition.ValueType;
            newDefinition.Tags          = definition.Tags;
            newDefinition.OriginalCode  = definition.OriginalCode;
            newDefinition.CodeSeparator = definition.CodeSeparator;
            newDefinition.CodeTag       = definition.CodeTag;
            newDefinition.Order         = definition.Order;
            return(newDefinition);
        }
Esempio n. 27
0
 public UniTask Initialize()
 {
     _playerDataGetter = DIResolver.GetObject <PlayerDataGetter>();
     InitMaps();
     InitCustomMaps();
     return(UniTask.CompletedTask);
 }
Esempio n. 28
0
        /// <summary>
        /// add virtual definition as an asynchronous operation.
        /// </summary>
        /// <param name="definitions">The definitions.</param>
        protected async Task AddVirtualDefinitionAsync(IEnumerable <IDefinition> definitions)
        {
            if (previousDefinitions != definitions)
            {
                if (!IsBinaryConflict)
                {
                    var col = definitions.OrderBy(p => SelectedModsOrder.IndexOf(p.ModName)).ToHashSet();
                    var priorityDefinition = modPatchCollectionService.EvalDefinitionPriority(col);
                    if (priorityDefinition == null || priorityDefinition.Definition == null)
                    {
                        if (priorityDefinition == null)
                        {
                            priorityDefinition = DIResolver.Get <IPriorityDefinitionResult>();
                            priorityDefinition.PriorityType = DefinitionPriorityType.None;
                        }
                        if (priorityDefinition.Definition == null)
                        {
                            priorityDefinition.Definition = col.First();
                        }
                    }
                    var newDefinition = await modPatchCollectionService.CreatePatchDefinitionAsync(priorityDefinition.Definition, CollectionName);

                    if (newDefinition != null)
                    {
                        col.Add(newDefinition);
                    }
                    VirtualDefinitions = col.ToObservableCollection();
                    if (VirtualDefinitions.Count() > 0)
                    {
                        // No reason to anymore not select a default definition on either side, wait a bit first to allow the UI to settle down
                        await Task.Delay(100);

                        LeftSelectedDefinition  = null;
                        RightSelectedDefinition = null;
                        await Task.Delay(50);

                        LeftSelectedDefinition  = VirtualDefinitions.FirstOrDefault(p => p != newDefinition && p != priorityDefinition.Definition);
                        RightSelectedDefinition = newDefinition;
                    }
                }
                else
                {
                    VirtualDefinitions = definitions.OrderBy(p => SelectedModsOrder.IndexOf(p.ModName)).ToHashSet();
                    if (VirtualDefinitions.Count() > 0)
                    {
                        // No reason to anymore not select a default definition on either side, wait a bit first to allow the UI to settle down
                        await Task.Delay(100);

                        LeftSelectedDefinition  = null;
                        RightSelectedDefinition = null;
                        await Task.Delay(50);

                        LeftSelectedDefinition  = definitions.ElementAt(0);
                        RightSelectedDefinition = definitions.ElementAt(1);
                    }
                }
            }
            previousDefinitions = definitions;
        }
Esempio n. 29
0
        public UniTask Initialize()
        {
            _gameSignals = DIResolver.GetObject <GameSignals>();

            _gameSignals.GameEntityCollisionTriggeredSignal.Listen(HandleGameEntityCollisionTriggered).AddTo(disposables);

            return(UniTask.CompletedTask);
        }
Esempio n. 30
0
        public UniTask Initialize()
        {
            _asteroidGameSettings  = DIResolver.GetObject <AsteroidGameSettings>();
            _gameSignal            = DIResolver.GetObject <GameSignals>();
            _bookKeepingInGameData = DIResolver.GetObject <BookKeepingInGameData>();

            return(UniTask.CompletedTask);
        }