public override void Execute(XElement element, Context context,
                              Configuration.IConfiguration configuration, ISite site = null, ISiteOwner siteOwner = null)
 {
     foreach (var input in element.Elements("input"))
     {
         IWebElement webElement = context.Driver.FindElement(By.Id(input.Attribute("id").Value));
         webElement.SendKeys(input.Attribute("content").Value);
     }
 }
예제 #2
0
        public AssertItem(XElement item, XElement page, ISiteOwner siteOwner, Configuration.IConfiguration defaultConfiguration)
        {
            this._element              = item;
            this._page                 = page;
            this._siteOwner            = siteOwner;
            this._defaultConfiguration = defaultConfiguration;

            this.CurrentSite = siteOwner.DefineSite(this._page, defaultConfiguration);
        }
        public override void Execute(XElement element, Context context,
                                     Configuration.IConfiguration configuration, ISite site = null, ISiteOwner siteOwner = null)
        {
            base.Execute(element, context, configuration, site, siteOwner);

            string url = this.CurrentSite != null ? this.CurrentSite.DefaultUrl : string.Empty;

            context.Driver.Navigate().GoToUrl(url + element.Attribute("url").Value);
        }
        public virtual void Execute(XElement element, Context context,
                                    Configuration.IConfiguration configuration, ISite site = null, ISiteOwner siteOwner = null)
        {
            this.CurrentSite = siteOwner.DefineSite(element, configuration);

            if (this.CurrentSite == null)
            {
                this.CurrentSite = site;
            }
        }
예제 #5
0
        public void Setup()
        {
            _config = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json").Build();

            _nemoConfig = (ConfigurationFactory.Configure() ?? ConfigurationFactory.DefaultConfiguration)
                          .SetDefaultChangeTrackingMode(ChangeTrackingMode.Debug)
                          .SetDefaultMaterializationMode(MaterializationMode.Exact)
                          .SetDefaultCacheRepresentation(CacheRepresentation.None)
                          .SetDefaultSerializationMode(SerializationMode.Compact)
                          .SetOperationNamingConvention(OperationNamingConvention.Default)
                          .SetOperationPrefix("spDTO_")
                          .SetAutoTypeCoercion(true)
                          .SetLogging(false)
                          .SetSystemConfiguration(_config);
        }
예제 #6
0
        public static async Task Main(string[] args)
        {
            var builder = WebAssemblyHostBuilder.CreateDefault(args);

            builder.RootComponents.Add <App>("#app");

            builder.Services.AddScoped(sp => new HttpClient {
                BaseAddress = new Uri(builder.HostEnvironment.BaseAddress)
            });
            Configuration.IConfiguration settings = builder.Configuration.Get <Rootobject>().Configuration;
            builder.Services.AddSingleton(settings);
            builder.Services.AddSingleton <IMarsRoverApi, MarsRoverApi>();
            builder.Services.AddSingleton <IRoverEventService, RoverEventService>();
            await builder.Build().RunAsync();
        }
예제 #7
0
        /// <summary>
        /// Crée la bonne assertion
        /// </summary>
        public static IAssert Create(XElement page, XElement item, Configuration.IConfiguration configuration, ISiteOwner siteOwner)
        {
            IAssert assert = null;

            if (item.Element("title") != null)
            {
                assert = new TitleAssertItem(item, page, siteOwner, configuration);
            }
            else if (item.Element("content") != null)
            {
                assert = new ContentAssertItem(item, page, siteOwner, configuration);
            }
            else if (item.Element("count") != null)
            {
                assert = new CountAssertItem(item, page, siteOwner, configuration);
            }

            return(assert);
        }
        public override void Execute(XElement element, Context context,
                                     Configuration.IConfiguration configuration, ISite site = null, ISiteOwner siteOwner = null)
        {
            const string FINDBY     = "findby-";
            XAttribute   attribute  = element.Element("input").Attribute(FINDBY + "xpath");
            IWebElement  webElement = null;

            if (attribute != null)
            {
                webElement = context.Driver.FindElement(By.XPath(attribute.Value));
            }

            System.Threading.Thread.Sleep(100);

            if (webElement != null)
            {
                webElement.Click();
            }
        }
예제 #9
0
파일: Main.cs 프로젝트: mioackerman/CKAN
        public Main(string[] cmdlineArgs, GameInstanceManager mgr, bool showConsole)
        {
            log.Info("Starting the GUI");
            commandLineArgs = cmdlineArgs;

            Configuration.IConfiguration mainConfig = ServiceLocator.Container.Resolve <Configuration.IConfiguration>();

            // If the language is not set yet in the config, try to save the current language.
            // If it isn't supported, it'll still be null afterwards. Doesn't matter, .NET handles the resource selection.
            // Once the user chooses a language in the settings, the string will be no longer null, and we can change
            // CKAN's language here before any GUI components are initialized.
            if (string.IsNullOrEmpty(mainConfig.Language))
            {
                string runtimeLanguage = Thread.CurrentThread.CurrentUICulture.IetfLanguageTag;
                mainConfig.Language = runtimeLanguage;
            }
            else
            {
                Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(mainConfig.Language);
            }

            InitializeComponent();

            Instance = this;

            currentUser = new GUIUser(this, this.Wait);
            manager     = mgr ?? new GameInstanceManager(currentUser);

            controlFactory = new ControlFactory();

            // React when the user clicks a tag or filter link in mod info
            ModInfo.OnChangeFilter += ManageMods.Filter;

            // Replace mono's broken, ugly toolstrip renderer
            if (Platform.IsMono)
            {
                menuStrip1.Renderer = new FlatToolStripRenderer();
                fileToolStripMenuItem.DropDown.Renderer     = new FlatToolStripRenderer();
                settingsToolStripMenuItem.DropDown.Renderer = new FlatToolStripRenderer();
                helpToolStripMenuItem.DropDown.Renderer     = new FlatToolStripRenderer();
                minimizedContextMenuStrip.Renderer          = new FlatToolStripRenderer();
            }

            // Initialize all user interaction dialogs.
            RecreateDialogs();

            // We want to check if our current instance is null first,
            // as it may have already been set by a command-line option.
            if (CurrentInstance == null && manager.GetPreferredInstance() == null)
            {
                Hide();

                var result = new ManageGameInstancesDialog(!actuallyVisible, currentUser).ShowDialog();
                if (result == DialogResult.Cancel || result == DialogResult.Abort)
                {
                    Application.Exit();
                    return;
                }
            }

            configuration = GUIConfiguration.LoadOrCreateConfiguration
                            (
                Path.Combine(CurrentInstance.CkanDir(), "GUIConfig.xml")
                            );

            // Check if there is any other instances already running.
            // This is not entirely necessary, but we can show a nicer error message this way.
            try
            {
#pragma warning disable 219
                var lockedReg = RegistryManager.Instance(CurrentInstance).registry;
#pragma warning restore 219
            }
            catch (RegistryInUseKraken kraken)
            {
                errorDialog.ShowErrorDialog(kraken.ToString());
                return;
            }

            tabController = new TabController(MainTabControl);
            tabController.ShowTab("ManageModsTabPage");

            if (!showConsole)
            {
                Util.HideConsoleWindow();
            }

            // Disable the modinfo controls until a mod has been choosen. This has an effect if the modlist is empty.
            ActiveModInfo = null;

            // WinForms on Mac OS X has a nasty bug where the UI thread hogs the CPU,
            // making our download speeds really slow unless you move the mouse while
            // downloading. Yielding periodically addresses that.
            // https://bugzilla.novell.com/show_bug.cgi?id=663433
            if (Platform.IsMac)
            {
                var timer = new Timer {
                    Interval = 2
                };
                timer.Tick += (sender, e) => { Thread.Yield(); };
                timer.Start();
            }

            // Set the window name and class for X11
            if (Platform.IsX11)
            {
                HandleCreated += (sender, e) => X11.SetWMClass("CKAN", "CKAN", Handle);
            }

            Application.Run(this);

            var registry = RegistryManager.Instance(Manager.CurrentInstance);
            registry?.Dispose();
        }
예제 #10
0
        public Main(string[] cmdlineArgs, GameInstanceManager mgr, bool showConsole)
        {
            log.Info("Starting the GUI");
            commandLineArgs = cmdlineArgs;

            Configuration.IConfiguration mainConfig = ServiceLocator.Container.Resolve <Configuration.IConfiguration>();

            // If the language is not set yet in the config, try to save the current language.
            // If it isn't supported, it'll still be null afterwards. Doesn't matter, .NET handles the resource selection.
            // Once the user chooses a language in the settings, the string will be no longer null, and we can change
            // CKAN's language here before any GUI components are initialized.
            if (string.IsNullOrEmpty(mainConfig.Language))
            {
                string runtimeLanguage = Thread.CurrentThread.CurrentUICulture.IetfLanguageTag;
                mainConfig.Language = runtimeLanguage;
            }
            else
            {
                CultureInfo.DefaultThreadCurrentUICulture = Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(mainConfig.Language);
            }

            InitializeComponent();

            Instance = this;

            currentUser = new GUIUser(this, this.Wait);
            if (mgr != null)
            {
                // With a working GUI, assign a GUIUser to the GameInstanceManager to replace the ConsoleUser
                mgr.User = currentUser;
                manager  = mgr;
            }
            else
            {
                manager = new GameInstanceManager(currentUser);
            }

            controlFactory = new ControlFactory();

            // React when the user clicks a tag or filter link in mod info
            ModInfo.OnChangeFilter += ManageMods.Filter;

            // Replace mono's broken, ugly toolstrip renderer
            if (Platform.IsMono)
            {
                menuStrip1.Renderer = new FlatToolStripRenderer();
                fileToolStripMenuItem.DropDown.Renderer     = new FlatToolStripRenderer();
                settingsToolStripMenuItem.DropDown.Renderer = new FlatToolStripRenderer();
                helpToolStripMenuItem.DropDown.Renderer     = new FlatToolStripRenderer();
                minimizedContextMenuStrip.Renderer          = new FlatToolStripRenderer();
            }

            // Initialize all user interaction dialogs.
            RecreateDialogs();

            // Make sure we have an instance
            if (CurrentInstance == null)
            {
                // Maybe we can find an instance automatically (e.g., portable, only, default)
                manager.GetPreferredInstance();
            }
            // A loop that ends when we have a valid instance or the user gives up
            do
            {
                if (CurrentInstance == null && !InstancePromptAtStart())
                {
                    // User cancelled, give up
                    return;
                }
                // We now have a tentative instance. Check if it's locked.
                try
                {
                    // This will throw RegistryInUseKraken if locked by another process
                    var regMgr = RegistryManager.Instance(CurrentInstance);
                    // Tell the user their registry was reset if it was corrupted
                    if (!string.IsNullOrEmpty(regMgr.previousCorruptedMessage) &&
                        !string.IsNullOrEmpty(regMgr.previousCorruptedPath))
                    {
                        errorDialog.ShowErrorDialog(Properties.Resources.MainCorruptedRegistry,
                                                    regMgr.previousCorruptedPath, regMgr.previousCorruptedMessage,
                                                    Path.Combine(Path.GetDirectoryName(regMgr.previousCorruptedPath) ?? "", regMgr.LatestInstalledExportFilename()));
                        regMgr.previousCorruptedMessage = null;
                        regMgr.previousCorruptedPath    = null;
                        // But the instance is actually fine because a new registry was just created
                    }
                }
                catch (RegistryInUseKraken kraken)
                {
                    errorDialog.ShowErrorDialog(kraken.ToString());
                    // Couldn't get the lock, there is no current instance
                    manager.CurrentInstance = null;
                    if (manager.Instances.All(inst => !inst.Value.Valid || inst.Value.IsMaybeLocked))
                    {
                        // Everything's invalid or locked, give up
                        Application.Exit();
                        return;
                    }
                }
            } while (CurrentInstance == null);
            // We can only reach this point if CurrentInstance is not null
            // AND we acquired the lock for it successfully

            // Get the instance's GUI onfig
            configuration = GUIConfiguration.LoadOrCreateConfiguration(
                Path.Combine(CurrentInstance.CkanDir(), "GUIConfig.xml"));

            tabController = new TabController(MainTabControl);
            tabController.ShowTab("ManageModsTabPage");

            if (!showConsole)
            {
                Util.HideConsoleWindow();
            }

            // Disable the modinfo controls until a mod has been choosen. This has an effect if the modlist is empty.
            ActiveModInfo = null;

            // WinForms on Mac OS X has a nasty bug where the UI thread hogs the CPU,
            // making our download speeds really slow unless you move the mouse while
            // downloading. Yielding periodically addresses that.
            // https://bugzilla.novell.com/show_bug.cgi?id=663433
            if (Platform.IsMac)
            {
                var timer = new Timer {
                    Interval = 2
                };
                timer.Tick += (sender, e) => { Thread.Yield(); };
                timer.Start();
            }

            // Set the window name and class for X11
            if (Platform.IsX11)
            {
                HandleCreated += (sender, e) => X11.SetWMClass("CKAN", "CKAN", Handle);
            }

            Application.Run(this);

            if (CurrentInstance != null)
            {
                var registry = RegistryManager.Instance(Manager.CurrentInstance);
                registry?.Dispose();
            }
        }
예제 #11
0
        /// <summary>
        /// 不可配置扩展方法
        /// </summary>
        /// <param name="services"></param>
        /// <param name="configuration"></param>
        /// <returns></returns>
        public static ResillienceBuilder AddResillience(this IServiceCollection services, Configuration.IConfiguration configuration = null)
        {
            configuration = (configuration ?? services.BuildServiceProvider().GetService <Configuration.IConfiguration>());
            IConfigurationSection section = configuration.GetSection("Resillience");

            return(services.Configure <ResillienceOption>(section).AddResillienceCode());
        }
 public TitleAssertItem(XElement item, XElement page, ISiteOwner siteOwner,
                        Configuration.IConfiguration defaultConfiguration) : base(item, page, siteOwner, defaultConfiguration)
 {
 }
예제 #13
0
        public SearchFileManager(Configuration.IConfiguration configuration)
        {
            this.Configuration = configuration;

            this.Configuration.Initialize();
        }
예제 #14
0
 public static IServiceCollection AddMongoDb(this IServiceCollection services, Configuration.IConfiguration configuration)
 {
     ConfigureDatabase(services, configuration);
     services.AddSingleton <IFleetStore, FleetStore>();
     services.AddSingleton <ICarsStore, FleetStore>();
     services.AddSingleton <IRegistrationsStore, RegistrationsStore>();
     services.AddSingleton <IMonthlyAggregatesStore, MonthlyAggregatesStore>();
     services.AddSingleton <IMonthlyAggregateLimitsStore, MonthlyAggregateLimitsStore>();
     services.AddSingleton <IPaymentsStore, PaymentsStore>();
     services.AddSingleton <IServiceRulesStore, ServiceRulesStore>();
     services.AddSingleton <IServiceOccasionsStore, ServiceOccasionsStore>();
     services.AddSingleton <IUserProfileStore, UserProfileStore>();
     BsonClassMap.RegisterClassMap <Fleet>(cm =>
     {
         cm.AutoMap();
         cm.MapIdMember(x => x.Id).SetIdGenerator(StringObjectIdGenerator.Instance);
     });
     BsonClassMap.RegisterClassMap <Car>(cm =>
     {
         cm.AutoMap();
         cm.MapIdMember(x => x.Id).SetIdGenerator(StringObjectIdGenerator.Instance).SetIgnoreIfDefault(true);
     });
     BsonClassMap.RegisterClassMap <MonthlyAggregateLimit>(cm =>
     {
         cm.AutoMap();
         cm.MapIdMember(x => x.Id).SetIdGenerator(StringObjectIdGenerator.Instance).SetIgnoreIfDefault(true);
     });
     BsonClassMap.RegisterClassMap <Payment>(cm =>
     {
         cm.AutoMap();
         cm.MapIdMember(x => x.Id).SetIdGenerator(StringObjectIdGenerator.Instance).SetIgnoreIfDefault(true);
     });
     BsonClassMap.RegisterClassMap <ServiceRule>(cm =>
     {
         cm.AutoMap();
         cm.MapIdMember(x => x.Id).SetIdGenerator(StringObjectIdGenerator.Instance).SetIgnoreIfDefault(true);
         cm.AddKnownType(typeof(TimeServiceRule));
         cm.AddKnownType(typeof(MileageServiceRule));
         cm.SetIsRootClass(true);
     });
     BsonClassMap.RegisterClassMap <ServiceOccasion>(cm =>
     {
         cm.AutoMap();
         cm.MapIdMember(x => x.Id).SetIdGenerator(StringObjectIdGenerator.Instance).SetIgnoreIfDefault(true);
     });
     BsonClassMap.RegisterClassMap <UserProfile>(cm =>
     {
         cm.AutoMap();
         cm.MapIdMember(x => x.Id).SetIdGenerator(StringObjectIdGenerator.Instance).SetIgnoreIfDefault(true);
     });
     return(services);
 }