static DocumentSessionFactory()
 {
     _engineFactory = str => new StreamStorageEngine(() => _openStream(str),
                                                     () => _openStream(str + ".temp"),
                                                     _deleteStream(str),
                                                     _deleteStream(str + ".temp"));
 }
        public void CachingIsEnabledByDefault()
        {
            var engine = new EngineFactory().GetEngine();
            engine = ((ParameterDecorator)engine).Underlying;

            Assert.That(engine, Is.TypeOf<CacheDecorator>());
        }
Esempio n. 3
0
        public static void Main(string[] args)
        {
            var arguments = new List<string>();

            arguments.AddRange(args);

            var configuration = GetConfigurationFromArguments(arguments);

            if(configuration.Help)
                return;

            if (arguments.Count == 0)
            {
                WriteHelp();
                return;
            }

            var inputFile = new FileInfo(arguments[0]);

            if (!inputFile.Exists && inputFile.Extension != ".less" && !inputFile.FullName.EndsWith(".less.css"))
                inputFile = new FileInfo(inputFile.FullName + ".less");

            string outputFilePath;
            if (arguments.Count > 1)
            {
                outputFilePath = arguments[1] + (Path.HasExtension(arguments[1]) ? "" : ".css");
                outputFilePath = Path.GetFullPath(outputFilePath);
            }
            else if (inputFile.FullName.EndsWith(".less.css"))
                outputFilePath = inputFile.Name.Substring(0, inputFile.Name.Length - 9) + ".css";
            else
                outputFilePath = Path.ChangeExtension(inputFile.Name, ".css");

            var currentDir = Directory.GetCurrentDirectory();
            if (inputFile.Directory != null)
                Directory.SetCurrentDirectory(inputFile.Directory.FullName);

            var engine = new EngineFactory(configuration).GetEngine();
            Func<IEnumerable<string>> compilationDelegate = () => Compile(engine, inputFile.Name, outputFilePath);

            var files = compilationDelegate();

            if (configuration.Watch)
            {
                WriteAbortInstructions();

                var watcher = new Watcher(files, compilationDelegate);

                while (Console.ReadLine() != "")
                {
                    WriteAbortInstructions();
                }

                watcher.RemoveWatchers();
            }

            Directory.SetCurrentDirectory(currentDir);
        }
Esempio n. 4
0
        public void ExecuteStatement_ImportCLRPrintHelloWorld_NoException()
        {
            LanguageSettingsSerialisation serialise = new LanguageSettingsSerialisation();
            LanguageSettings ironPython = serialise.Deserialise("TestConfig\\IronPython.xml");
            EngineFactory factory = new EngineFactory(ironPython);
            ScriptEngine engine = factory.CreateEngine();

            StringBuilder outputString = new StringBuilder();
            TextWriter writer = new StringWriter(outputString);
            ScriptExecutor exec = new ScriptExecutor(engine, writer);
            exec.ExecuteStatement("import clr");

            Assert.IsFalse(outputString.ToString().Contains("Error"), outputString.ToString());
            Assert.IsFalse(outputString.ToString().Contains("Exception"), outputString.ToString());
        }
Esempio n. 5
0
        public static bool UpdateRecords(this ServerDns dns, string domain, bool force = false)
        {
            if (string.IsNullOrEmpty(domain) || dns == null)
            {
                return(false);
            }

            var utcNow = DateTime.UtcNow;

            var hasChanges = false;

            if (force)
            {
                if (dns.UpdateMx(domain))
                {
                    hasChanges = true;
                }

                if (dns.UpdateSpf(domain))
                {
                    hasChanges = true;
                }

                if (dns.UpdateDkim(domain))
                {
                    hasChanges = true;
                }
            }
            else
            {
                if (dns.MxDateChecked.HasValue && dns.MxDateChecked.Value.AddSeconds(dns.MxTtl) >= utcNow &&
                    dns.SpfDateChecked.HasValue && dns.SpfDateChecked.Value.AddSeconds(dns.SpfTtl) >= utcNow &&
                    dns.DkimDateChecked.HasValue && dns.DkimDateChecked.Value.AddSeconds(dns.DkimTtl) >= utcNow)
                {
                    return(hasChanges);
                }

                var engineFactory = new EngineFactory(dns.Tenant, dns.User);
                engineFactory.OperationEngine.CheckDomainDns(domain, dns);
            }

            return(hasChanges);
        }
Esempio n. 6
0
        public Form1()
        {
            LoggerProvider.Instance.Level = SourceLevels.Verbose;
            LoggerProvider.Instance.FileLoggingEnabled = true;
            LoggerProvider.Instance.OutputFile         = "log.txt";
            BrowserView webView = new BrowserView {
                Dock = DockStyle.Fill
            };

            Task.Run(() =>
            {
                engine = EngineFactory
                         .Create(new EngineOptions.Builder
                {
                    RenderingMode = RenderingMode.HardwareAccelerated
                }.Build());
                browser = engine.CreateBrowser();
            }).ContinueWith(t =>
            {
                webView.InitializeFrom(browser);
                // #docfragment "ContextMenu.WinForms.Configuration"
                browser.ShowContextMenuHandler =
                    new AsyncHandler <ShowContextMenuParameters, ShowContextMenuResponse
                                      >(ShowMenu);
                // #enddocfragment "ContextMenu.WinForms.Configuration"

                byte[] htmlBytes = Encoding.UTF8.GetBytes(@"<html>
                                    <head>
                                      <meta charset='UTF-8'>
                                    </head>
                                    <body>
                                    <textarea autofocus cols='30' rows='20'>Simpple mistakee</textarea>
                                    </body>
                                    </html>");
                browser.Navigation.LoadUrl("data:text/html;base64,"
                                           + Convert.ToBase64String(htmlBytes));
            }, TaskScheduler.FromCurrentSynchronizationContext());

            InitializeComponent();
            FormClosing += Form1_FormClosing;
            Controls.Add(webView);
        }
        private static void Main(string[] args)
        {
            using (IEngine engine = EngineFactory.Create())
            {
                using (IBrowser browser = engine.CreateBrowser())
                {
                    engine.Profiles.Default.Network.SendUrlRequestHandler =
                        new Handler <SendUrlRequestParameters,
                                     SendUrlRequestResponse>(OnSendUrlRequest);
                    engine.Profiles.Default.Network.ResponseBytesReceived += OnResponseBytesReceived;
                    engine.Profiles.Default.Network.RequestCompleted      += OnRequestCompleted;

                    browser.Navigation
                    .LoadUrl("https://www.w3schools.com/xml/tryit.asp?filename=tryajax_first")
                    .Wait();

                    IFrame demoFrame = browser.AllFrames.FirstOrDefault(FrameHasDemoElement);

                    if (demoFrame != null)
                    {
                        //Click the button in the demo frame to make an AJAX request.
                        Console.WriteLine("Demo frame found");
                        demoFrame.Document.GetElementByTagName("button").Click();
                    }

                    Console.WriteLine("Wait for 15 seconds to be sure that at least some requests are completed.");
                    Thread.Sleep(15000);

                    // The dictionary will contain some requests, including the one we sent by clicking the button.
                    string key =
                        AjaxRequests.Keys.FirstOrDefault(k => k.Contains("ajax_info.txt"));
                    if (!string.IsNullOrEmpty(key))
                    {
                        HttpRequest ajaxRequest = AjaxRequests[key];
                        Console.WriteLine($"Response intercepted: \n{ajaxRequest.Response}");
                    }
                }
            }

            Console.WriteLine("Press any key to terminate...");
            Console.ReadKey();
        }
        public static void Main()
        {
            try
            {
                using (IEngine engine = EngineFactory.Create(new EngineOptions.Builder().Build()))
                {
                    Console.WriteLine("Engine created");

                    using (IBrowser browser = engine.CreateBrowser())
                    {
                        Console.WriteLine("Browser created");

                        browser.MainFrame
                        .LoadHtml(new LoadHtmlParameters("<html><body>"
                                                         + "<script>localStorage.myKey = \"Initial Value\";"
                                                         + "function myFunction(){return localStorage.myKey;}"
                                                         + "</script></body></html>"
                                                         )
                        {
                            BaseUrl = "https://teamdev.com",
                            Replace = true
                        })
                        .Wait();
                        IWebStorage webStorage = browser.MainFrame.LocalStorage;
                        // Read and display the 'myKey' storage value.
                        Console.Out.WriteLine("The initial myKey value: " + webStorage["myKey"]);
                        // Modify the 'myKey' storage value.
                        webStorage["myKey"] = "Hello from Local Storage";
                        string updatedValue = browser.MainFrame.ExecuteJavaScript <IJsObject>("window")
                                              .Result.Invoke <string>("myFunction");
                        Console.Out.WriteLine("The updated myKey value: " + updatedValue);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            Console.WriteLine("Press any key to terminate...");
            Console.ReadKey();
        }
Esempio n. 9
0
        public MainWindow()
        {
            chromiumDirectory = Path.GetFullPath("chromium");

            //Delete the Chromium directory it it exists - this will force downloading the binaries over network.
            if (Directory.Exists(chromiumDirectory))
            {
                Directory.Delete(chromiumDirectory, true);
            }

            Directory.CreateDirectory(chromiumDirectory);

            //Create and initialize the BinariesResolver
            BinariesResolver = new BinariesResolver();
            //Subscribe to the StatusUpdated event to update the UI accordingly.
            BinariesResolver.StatusUpdated += (sender, e) => InitializationStatus = e.Message;

            DataContext = this;

            Task.Run(() =>
            {
                IsInitializationInProgress  = true;
                EngineOptions engineOptions = new EngineOptions.Builder
                {
                    RenderingMode     = RenderingMode.HardwareAccelerated,
                    ChromiumDirectory = chromiumDirectory
                }
                .Build();
                InitializationStatus = "Creating DotNetBrowser engine";
                engine = EngineFactory.Create(engineOptions);
                InitializationStatus = "DotNetBrowser engine created";
                browser = engine.CreateBrowser();
            })
            .ContinueWith(t =>
            {
                BrowserView.InitializeFrom(browser);
                IsInitializationInProgress = false;
                browser.Navigation.LoadUrl("https://www.teamdev.com/");
            }, TaskScheduler.FromCurrentSynchronizationContext());

            InitializeComponent();
        }
Esempio n. 10
0
        public void StartImport()
        {
            HttpContext.Current = null;
            try
            {
                LogStatus("started");

                CoreContext.TenantManager.SetCurrentTenant(Id);
                Thread.CurrentPrincipal = _principal;

                HttpContext.Current = new HttpContext(
                    new HttpRequest("fake", CommonLinkUtility.GetFullAbsolutePath("/"), string.Empty),
                    new HttpResponse(new StringWriter()));

                scope          = DIHelper.Resolve(_disableNotifications);
                _engineFactory = scope.Resolve <EngineFactory>();

                StatusState.SetStatusStarted();
                StatusState.StatusLogInfo(ImportResource.ImportStarted);
                var basecampManager = BaseCamp.GetInstance(_url, _userName, _password);

                LogStatus("import users");
                SaveUsers(basecampManager);

                LogStatus("import projects");

                SaveProjects(basecampManager);

                StatusState.SetStatusCompleted();

                StatusState.StatusLogInfo(ImportResource.ImportCompleted);
            }
            finally
            {
                if (HttpContext.Current != null)
                {
                    new DisposableHttpContext(HttpContext.Current).Dispose();
                    HttpContext.Current = null;
                }
                scope.Dispose();
            }
        }
Esempio n. 11
0
 private void CreateEngine()
 {
     string[] arguments = Environment.GetCommandLineArgs();
     renderingMode = RenderingMode.HardwareAccelerated;
     if (arguments.FirstOrDefault(arg => arg.ToLower().Contains("lightweight")) != null)
     {
         renderingMode = RenderingMode.OffScreen;
     }
     if (arguments.FirstOrDefault(arg => arg.ToLower().Contains("enable-file-log")) != null)
     {
         LoggerProvider.Instance.Level = SourceLevels.Verbose;
         LoggerProvider.Instance.FileLoggingEnabled = true;
         string logFile = $"DotNetBrowser-WPF-{Guid.NewGuid()}.log";
         LoggerProvider.Instance.OutputFile = System.IO.Path.GetFullPath(logFile);
     }
     try
     {
         engine = EngineFactory.Create(new EngineOptions.Builder
         {
             RenderingMode = renderingMode
         }.Build());
         engine.Downloads.StartDownloadHandler = new DefaultStartDownloadHandler(this);
         engine.Network.AuthenticateHandler    = new DefaultAuthenticationHandler(this);
         engine.Disposed += (sender, args) =>
         {
             if (args.ExitCode != 0)
             {
                 string message = $"The Chromium engine exit code was {args.ExitCode:x8}";
                 Trace.WriteLine(message);
                 MessageBox.Show(message,
                                 "DotNetBrowser Warning", MessageBoxButton.OK,
                                 MessageBoxImage.Warning);
             }
         };
     }
     catch (Exception e)
     {
         Trace.WriteLine(e);
         MessageBox.Show(e.Message, "DotNetBrowser Initialization Error", MessageBoxButton.OK,
                         MessageBoxImage.Error);
     }
 }
        public MainWindow()
        {
            try
            {
                Task.Run(() =>
                {
                    engine = EngineFactory.Create(new EngineOptions.Builder
                    {
                        RenderingMode = RenderingMode.OffScreen
                    }.Build());
                    browser = engine.CreateBrowser();
                    browser.Settings.TransparentBackgroundEnabled = true;
                })
                .ContinueWith(t =>
                {
                    WebBrowser1.InitializeFrom(browser);
                    browser
                    .MainFrame
                    .LoadHtml(
                        "<html>\n"
                        + "     <body>"
                        + "         <div style='background: yellow; opacity: 0.7;'>\n"
                        + "             This text is in the yellow half-transparent div."
                        + "        </div>\n"
                        + "         <div style='background: red;'>\n"
                        + "             This text is in the red opaque div and should appear as is."
                        + "        </div>\n"
                        + "         <div>\n"
                        + "             This text is in the non-styled div and should appear as a text"
                        + " on the completely transparent background."
                        + "        </div>\n"
                        + "    </body>\n"
                        + " </html>");
                }, TaskScheduler.FromCurrentSynchronizationContext());

                InitializeComponent();
            }
            catch (Exception exception)
            {
                Debug.WriteLine(exception);
            }
        }
Esempio n. 13
0
        /// <summary>
        /// Executes demo2 live tests with loop.
        /// </summary>
        internal static void RunLiveTests2()
        {
            // set package execution parameters eg. variables, connections
            var parameters = new ExecutionParameters();

            // create engine for live testing
            var engine = EngineFactory.GetClassInstance <ILiveTestEngine>();

            // load packages and relate them to the logical group - repository
            engine.LoadPackages("DEMO2", Constants.PathToPackages);

            // load live tests from the current assembly
            engine.LoadRepositoryActions("DEMO2");

            // set execution parameters
            engine.SetExecutionParameters(parameters);

            // execute the package and attach live tests
            engine.ExecuteLiveTestsWithGui("DEMO2", "Loop.dtsx");
        }
Esempio n. 14
0
        public void TestServerClientGameVirtual()
        {
            var game = new GodGameServerClient();

            // Virtual connection setup

            var virtualNetworkConnectorServer = new VirtualNetworkConnectorServer();
            var virtualNetworkConnectorClient = virtualNetworkConnectorServer.CreateClient();

            // Create
            var server = game.CreateServer(virtualNetworkConnectorServer);
            var client = game.CreateClient(virtualNetworkConnectorClient);

            // Initialize gameloop

            var engine = EngineFactory.CreateEngine();

            server.AddSimulatorsToEngine(engine);
            client.AddSimulatorsToEngine(engine);
        }
Esempio n. 15
0
        public void TestTranslatedVoxelTerrain()
        {
            var engine = EngineFactory.CreateEngine();

            engine.Initialize();

            var terr = createBlob();

            terr.WorldPosition = new Vector3(30, 0, 0);

            terr = createBlob();

            terr.NodeSize      = 5;
            terr.WorldPosition = new Vector3(0, 0, 100);

            engine.AddSimulator(new VoxelTerrainSimulator());
            engine.AddSimulator(new WorldRenderingSimulator());

            engine.Run();
        }
Esempio n. 16
0
            public void Run()
            {
                var engine = EngineFactory.CreateEngine();

                engine.AddSimulator(new BasicSimulator(() =>
                {
                    lodRenderer.UpdateRendererState();

                    lodRenderer.RenderLines();
                }));
                engine.AddSimulator(new WorldRenderingSimulator());
                for (int x = 0; x < 200; x++)
                {
                    for (int y = 0; y < 200; y++)
                    {
                        var i = level.CreateNewIsland(new Vector3(x * 100, 0, y * 100));
                        i.Mesh = TW.Assets.LoadMesh("Scattered\\TestIsland");
                    }
                }
            }
Esempio n. 17
0
        public static void Main()
        {
            using (IEngine engine = EngineFactory.Create())
            {
                using (IBrowser browser = engine.CreateBrowser())
                {
                    browser.Size = new Size(700, 500);
                    browser.Navigation.LoadUrl("https://www.teamdev.com").Wait();

                    browser.MainFrame.Execute(EditorCommand.SelectAll());

                    Console.WriteLine("Current selection:");
                    Console.WriteLine($"\tSelected text: {browser.MainFrame.SelectedText}");
                    Console.WriteLine($"\tSelected HTML:  {browser.MainFrame.SelectedHtml}");
                }
            }

            Console.WriteLine("Press any key to terminate...");
            Console.ReadKey();
        }
Esempio n. 18
0
        public void RemoveMailBox(IDaoFactory daoFactory, MailBoxData mailbox, bool needRecalculateFolders = true)
        {
            if (mailbox.MailBoxId <= 0)
            {
                throw new Exception("MailBox id is 0");
            }

            var freedQuotaSize = RemoveMailBoxInfo(daoFactory, mailbox);

            var engine = new EngineFactory(mailbox.TenantId, mailbox.UserId);

            engine.QuotaEngine.QuotaUsedDelete(freedQuotaSize);

            if (!needRecalculateFolders)
            {
                return;
            }

            engine.OperationEngine.RecalculateFolders();
        }
Esempio n. 19
0
        public MainWindow()
        {
            engine = EngineFactory
                     .Create(new EngineOptions.Builder
            {
                RenderingMode    = RenderingMode.HardwareAccelerated,
                ChromiumSwitches = { "--enable-com-in-drag-drop" },
                SandboxDisabled  = true
            }
                             .Build());

            browser = engine.CreateBrowser();

            browser.DragAndDrop.EnterDragHandler = new Handler <EnterDragParameters>(OnDragEnter);
            browser.DragAndDrop.DropHandler      = new Handler <DropParameters>(OnDrop);

            InitializeComponent();
            browserView.InitializeFrom(browser);
            browser.Navigation.LoadUrl("teamdev.com");
        }
Esempio n. 20
0
        private static void RemoveUserFolders(int tenant, string userId, ILog log)
        {
            try
            {
                var engineFactory = new EngineFactory(tenant, userId);

                var engine = engineFactory.UserFolderEngine;

                var folders = engine.GetList(parentId: 0);

                foreach (var folder in folders)
                {
                    engine.Delete(folder.Id);
                }
            }
            catch (Exception ex)
            {
                log.ErrorFormat("RemoveUserFolders() Failure\r\nException: {0}", ex.ToString());
            }
        }
Esempio n. 21
0
        public void SetUp()
        {
            chunkSize       = BuilderConfiguration.ChunkNumVoxels;
            voxelSize       = BuilderConfiguration.VoxelSize;
            NumChunks       = BuilderConfiguration.NumChunks;
            surfaceRenderer = VoxelCustomRenderer.CreateDefault(TW.Graphics);
            TW.Graphics.AcquireRenderer().AddCustomGBufferRenderer(surfaceRenderer);

            initDefaultWorld();

            EngineFactory.CreateEngine().AddSimulator(processUserInput, "UserInput");
            interactiveTestingEnv = new InteractiveTestingEnvironment();
            interactiveTestingEnv.LoadIntoEngine(EngineFactory.CreateEngine());
            EngineFactory.CreateEngine().AddSimulator(new WorldRenderingSimulator());


            //TODO: add commands!

            //PlaceInWorld(createUnitBox(), new Point3(0, 20, 0));
        }
Esempio n. 22
0
        public void ConfigureServices(IServiceCollection services)
        {
            var coreAssemblies = new Assembly[]
            {
                typeof(Smartstore.Engine.IEngine).Assembly,
                typeof(Smartstore.Core.CoreStarter).Assembly,
                typeof(Smartstore.Web.Startup).Assembly,
                typeof(Smartstore.Web.Theming.IThemeRegistry).Assembly
            };

            _appContext = new SmartApplicationContext(
                Environment,
                Configuration,
                StartupLogger,
                coreAssemblies);

            _engineStarter = EngineFactory.Create(_appContext.AppConfiguration).Start(_appContext);

            _engineStarter.ConfigureServices(services);
        }
Esempio n. 23
0
        public LessHandler(IFileWrapper fileWrapper)
        {
            this.fileWrapper = fileWrapper;
            var config = new DotlessConfiguration
            {
                CacheEnabled = false,
                Logger       = typeof(LessLogger),
                Web          = HttpContext.Current != null,
            };
            var engineFactory = new EngineFactory(config);

            if (HttpContext.Current == null)
            {
                engine = engineFactory.GetEngine();
            }
            else
            {
                engine = engineFactory.GetEngine(new AspNetContainerFactory());
            }
        }
Esempio n. 24
0
    protected void createButton_Click(object sender, EventArgs e)
    {
        string className = nameTextBox.Text;

        if (string.IsNullOrEmpty(className))
        {
            return;
        }

        string tableName = tableTextBox.Text;

        if (string.IsNullOrEmpty(tableName))
        {
            tableName = className;
        }

        IEngine engine = EngineFactory.CreateEngine();

        engine.Execute("create class " + className + "(Table = " + tableName + ")");
    }
    protected void addPropertyButton_Click(object sender, EventArgs e)
    {
        string propertyName = propertyNameTextBox.Text;

        if (string.IsNullOrEmpty(propertyName))
        {
            return;
        }

        string propertyTypeName = propertyTypeDropDownList.SelectedValue;

        if (string.IsNullOrEmpty(propertyTypeName))
        {
            return;
        }

        if (string.IsNullOrEmpty(typeName))
        {
            return;
        }

        IEngine engine = EngineFactory.CreateEngine();

        string command = "create property " + typeName + "." + propertyName + " (Type = " + propertyTypeName + ", Nullable = " + nullableCheckBox.Checked.ToString();

        if (!string.IsNullOrEmpty(stringLengthTextBox.Text))
        {
            command += ", Length = " + stringLengthTextBox.Text;
        }

        if (!string.IsNullOrEmpty(columnNameTextBox.Text))
        {
            command += ", Column = " + columnNameTextBox.Text;
        }

        command += ")";

        engine.Execute(command);

        ListProperties();
    }
Esempio n. 26
0
 private static void Main(string[] args)
 {
     try
     {
         // [START SEPARATE_ENGINES]
         string userDataDir1 = Path.GetFullPath("user-data-dir-one");
         Directory.CreateDirectory(userDataDir1);
         IEngine engine1 = EngineFactory.Create(new EngineOptions.Builder
         {
             UserDataDirectory = userDataDir1
         }.Build());
         Console.WriteLine("Engine1 created");
         //
         string userDataDir2 = Path.GetFullPath("user-data-dir-two");
         Directory.CreateDirectory(userDataDir2);
         IEngine engine2 = EngineFactory.Create(new EngineOptions.Builder
         {
             UserDataDirectory = userDataDir2
         }.Build());
         Console.WriteLine("Engine2 created");
         //
         // This Browser instance will store cookies and user data files in "user-data-dir-one" dir.
         IBrowser browser1 = engine1.CreateBrowser();
         Console.WriteLine("browser1 created");
         //
         // This Browser instance will store cookies and user data files in "user-data-dir-two" dir.
         IBrowser browser2 = engine2.CreateBrowser();
         Console.WriteLine("browser2 created");
         //
         // The browser1 and browser2 instances will not see the cookies and cache data files of each other.
         // [END SEPARATE_ENGINES]
         engine2.Dispose();
         engine1.Dispose();
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
     Console.WriteLine("Press any key to terminate...");
     Console.ReadKey();
 }
        public static void Main()
        {
            try
            {
                using (IEngine engine = EngineFactory.Create(new EngineOptions.Builder().Build()))
                {
                    Console.WriteLine("Engine created");

                    using (IBrowser browser = engine.CreateBrowser())
                    {
                        Console.WriteLine("Browser created");
                        browser.Size = new Size(700, 500);
                        browser.MainFrame.LoadHtml("<html><body><p>Find me</p><p>Find me</p></body></html>").Wait();

                        Thread.Sleep(2000);
                        // Find text from the beginning of the loaded web page.
                        string searchText = "find me";

                        IHandler <FindResultReceivedParameters> intermediateResultsHandler =
                            new Handler <FindResultReceivedParameters>(ProcessSearchResults);
                        Console.WriteLine("Find text (1/2)");

                        FindResult findResult =
                            browser.TextFinder.Find(searchText, null, intermediateResultsHandler).Result;
                        Console.Out.WriteLine($"Find Result: {findResult.SelectedMatch}/{findResult.NumberOfMatches}");
                        Console.WriteLine("Find text (2/2)");

                        findResult = browser.TextFinder.Find(searchText, null, intermediateResultsHandler).Result;
                        Console.Out.WriteLine($"Find Result: {findResult.SelectedMatch}/{findResult.NumberOfMatches}");
                        browser.TextFinder.StopFinding();
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            Console.WriteLine("Press any key to terminate...");
            Console.ReadKey();
        }
Esempio n. 28
0
        public static void Main()
        {
            using (IEngine engine = EngineFactory.Create())
            {
                ICookieStore cookieStorage = engine.Profiles.Default.CookieStore;
                using (IBrowser browser = engine.CreateBrowser())
                {
                    browser.Navigation.LoadUrl(Url).Wait();

                    IEnumerable <Cookie> cookies = cookieStorage.GetAllCookies(Url).Result;

                    foreach (Cookie cookie in cookies)
                    {
                        Console.WriteLine($"cookie = {cookie}");
                    }
                }
            }

            Console.WriteLine("Press any key to terminate...");
            Console.ReadKey();
        }
Esempio n. 29
0
 public Form1()
 {
     Task.Run(() =>
     {
         EngineOptions engineOptions = new EngineOptions.Builder
         {
             RenderingMode = RenderingMode.HardwareAccelerated
         }
         .Build();
         engine  = EngineFactory.Create(engineOptions);
         browser = engine.CreateBrowser();
         browser.Navigation.StartNavigationHandler =
             new Handler <StartNavigationParameters, StartNavigationResponse>(OnStartNavigation);
     })
     .ContinueWith(t =>
     {
         browserView1.InitializeFrom(browser);
         browser.Navigation.LoadUrl("https://www.teamdev.com/contact");
     }, TaskScheduler.FromCurrentSynchronizationContext());
     InitializeComponent();
 }
Esempio n. 30
0
        public TimeWrapper UpdateTime(int timeid, string note, DateTime date, Guid personId, float hours)
        {
            if (date == DateTime.MinValue)
            {
                throw new ArgumentException("date can't be empty");
            }
            if (personId == Guid.Empty)
            {
                throw new ArgumentException("person can't be empty");
            }

            var time = EngineFactory.GetTimeTrackingEngine().GetByID(timeid).NotFoundIfNull();

            time.Date   = date.Date;
            time.Person = personId;
            time.Hours  = hours;
            time.Note   = note;

            EngineFactory.GetTimeTrackingEngine().SaveOrUpdate(time);
            return(new TimeWrapper(time));
        }
Esempio n. 31
0
        public MainWindow()
        {
            Task.Run(() =>
            {
                engine = EngineFactory
                         .Create(new EngineOptions.Builder
                {
                    RenderingMode = RenderingMode.OffScreen
                }
                                 .Build());
                browser = engine.CreateBrowser();
            })
            .ContinueWith(t =>
            {
                WebView.InitializeFrom(browser);
                ConfigureContextMenu();
                browser.Navigation.LoadUrl("https://www.google.com/");
            }, TaskScheduler.FromCurrentSynchronizationContext());

            InitializeComponent();
        }
Esempio n. 32
0
        public void TestSimple()
        {
            var engine = EngineFactory.CreateEngine();

            engine.Initialize();

            var gen = new VoxelTerrainConvertor();

            var data = new bool[5, 5, 5];

            for (int i = 0; i < 5; i++)
            {
                data[i, i, i] = true;
            }

            gen.SetTerrain(data);

            engine.AddSimulator(new VoxelTerrainSimulator());
            engine.AddSimulator(new WorldRenderingSimulator());
            engine.Run();
        }
Esempio n. 33
0
        public void NonVeryTimeConsumingBenchmarksAreExecutedMoreThanOncePerIterationWithUnrollFactorForDefaultSettings()
        {
            var engineParameters = CreateEngineParameters(mainNoUnroll: InstantNoUnroll, mainUnroll: InstantUnroll, job: Job.Default);

            var engine = new EngineFactory().CreateReadyToRun(engineParameters);

            Assert.Equal(1, timesGlobalSetupCalled);
            Assert.Equal(1 + 1, timesIterationSetupCalled); // once for single and & once for 16
            Assert.Equal(1 + 16, timesBenchmarkCalled);
            Assert.Equal(1 + 16, timesOverheadCalled);
            Assert.Equal(1 + 1, timesIterationCleanupCalled); // once for single and & once for 16
            Assert.Equal(0, timesGlobalCleanupCalled);

            Assert.False(engine.TargetJob.Run.HasValue(AccuracyMode.EvaluateOverheadCharacteristic)); // remains untouched

            Assert.False(engine.TargetJob.Run.HasValue(RunMode.InvocationCountCharacteristic));

            engine.Dispose();

            Assert.Equal(1, timesGlobalCleanupCalled);
        }
Esempio n. 34
0
        public static void Main(string[] args)
        {
            int carsCount = int.Parse(Console.ReadLine());

            CarFactory    carFactory    = new CarFactory();
            EngineFactory engineFactory = new EngineFactory();
            TireFactory   tireFactory   = new TireFactory();

            CarCatalog carCatalog = new CarCatalog(carFactory, engineFactory, tireFactory);

            for (int i = 0; i < carsCount; i++)
            {
                string[] carArgs = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

                carCatalog.Add(carArgs);
            }

            string command = Console.ReadLine();

            carCatalog.GetCarInfo(command);
        }
Esempio n. 35
0
        public void DefaultEngineIsParameterDecorator()
        {
            var engine = new EngineFactory().GetEngine();

            Assert.That(engine, Is.TypeOf<ParameterDecorator>());
        }
Esempio n. 36
0
        public static int Main(string[] args)
        {
            var arguments = new List<string>();

            arguments.AddRange(args);

            var configuration = GetConfigurationFromArguments(arguments);

            if (configuration.Help)
                return 0;

            if (arguments.Count == 0)
            {
                WriteHelp();
                return 0;
            }

            Stopwatch timer = null;

            if (configuration.TimeCompilation)
            {
                timer = new Stopwatch();
                timer.Start();
            }

            var returnValue = 0;

            var inputDirectoryPath = Path.GetDirectoryName(arguments[0]);
            if (string.IsNullOrEmpty(inputDirectoryPath)) inputDirectoryPath = ".\\";
            var inputFilePattern = Path.GetFileName(arguments[0]);
            var outputDirectoryPath = string.Empty;
            var outputFilename = string.Empty;

            if (string.IsNullOrEmpty(inputFilePattern)) inputFilePattern = "*.less";
            if (!Path.HasExtension(inputFilePattern)) inputFilePattern = Path.ChangeExtension(inputFilePattern, "less");

            if (arguments.Count > 1)
            {
                outputDirectoryPath = Path.GetDirectoryName(arguments[1]);
                outputFilename = Path.GetFileName(arguments[1]);
                outputFilename = Path.ChangeExtension(outputFilename, "css");
            }
            else outputDirectoryPath = inputDirectoryPath;
            if (HasWildcards(inputFilePattern)) outputFilename = string.Empty;

            var factory = new EngineFactory(configuration);

            var filenames = Directory.GetFiles(inputDirectoryPath, inputFilePattern, configuration.Recurse ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly);

            var parallelFiles = filenames.AsParallel();
            parallelFiles =
                parallelFiles.WithDegreeOfParallelism(
                    configuration.CompileInParallel ?
                        Environment.ProcessorCount :
                        1
                ).WithExecutionMode(ParallelExecutionMode.ForceParallelism);

            var logLock = new object();
            Action<string> logDel =
                delegate(string log)
                {
                    if (string.IsNullOrEmpty(log)) return;

                    lock (logLock)
                    {
                        Console.Write(log);
                    }
                };

            parallelFiles.ForAll(
                delegate(string filename)
                {
                    var log = new StringBuilder();

                    var inputFile = new FileInfo(filename);

                    var engine = factory.GetEngine(Path.GetDirectoryName(inputFile.FullName));

                    var pathbuilder = configuration.Recurse
                                          ? new System.Text.StringBuilder(Path.GetDirectoryName(filename) + "\\")
                                          : new System.Text.StringBuilder(outputDirectoryPath + "\\");
                    if (string.IsNullOrEmpty(outputFilename)) pathbuilder.Append(Path.ChangeExtension(inputFile.Name, "css"));
                    else pathbuilder.Append(outputFilename);
                    var outputFilePath = Path.GetFullPath(pathbuilder.ToString());

                    CompilationDelegate compilationDelegate = () => CompileImpl(engine, inputFile.FullName, outputFilePath, log, configuration.SilenceLogging);

                    if (!configuration.SilenceLogging)
                    {
                        log.AppendLine("[Compile]");
                    }

                    var files = compilationDelegate();

                    if (files == null)
                    {
                        returnValue = 1;
                    }

                    logDel(log.Length == 0 ? null : log.ToString());
                }
            );

            if (configuration.TimeCompilation)
            {
                timer.Stop();
                Console.WriteLine("Compilation took: {0}ms", timer.ElapsedMilliseconds);
            }

            return returnValue;
        }
Esempio n. 37
0
        public static void Main(string[] args)
        {
            bool watch = false;
            var arguments = new List<string>();
            arguments.AddRange(args);

            if (arguments.Count == 0)
            {
                WriteHelp();
                return;
            }

            DotlessConfiguration configuration;
            try
            {
                watch = arguments.Any(p => p == "-w" || p == "--watch");
                configuration = GetConfigurationFromArguments(arguments);
            }
            catch (HelpRequestedException)
            {
                return;
            }

            var inputFilePath = arguments[0];
            string outputFilePath;
            if (arguments.Count > 1)
            {
                outputFilePath = arguments[1];
            }
            else
            {
                outputFilePath = String.Format("{0}.css", inputFilePath);
            }
            if (File.Exists(inputFilePath))
            {
                Action compilationDelegate = () =>
                                                 {
                                                     var factory = new EngineFactory();
                                                     ILessEngine engine = factory.GetEngine(configuration);
                                                     Console.Write("Compiling {0} -> {1} ", inputFilePath, outputFilePath);
                                                     try
                                                     {
                                                         string css =
                                                             engine.TransformToCss(new FileSource().GetSource(inputFilePath));
                                                         File.WriteAllText(outputFilePath, css);
                                                         Console.WriteLine("[Done]");
                                                     } catch(Exception ex)
                                                     {
                                                         if (ex is IOException) throw; //Rethrow

                                                         Console.WriteLine("[FAILED]");
                                                         Console.WriteLine("Compilation failed: {0}", ex.Message);
                                                         Console.WriteLine(ex.StackTrace);
                                                     }

                                                 };
                compilationDelegate();
                if (watch)
                {
                    var watcher = new Watcher(inputFilePath, compilationDelegate);
                    while(Console.ReadLine() != "")
                    {
                        Console.WriteLine("Hit Enter to stop watching");
                    }
                    Console.WriteLine("Stopped watching file. Exiting");
                }
            }
            else
            {
                Console.WriteLine("Input file {0} does not exist", inputFilePath);
            }
        }
Esempio n. 38
0
        public static int Main(string[] args)
        {
            var arguments = new List<string>();

            arguments.AddRange(args);

            var configuration = GetConfigurationFromArguments(arguments);

            if(configuration.Help)
                return -1;

            if (arguments.Count == 0)
            {
                WriteHelp();
                return -1;
            }

            var inputDirectoryPath = Path.GetDirectoryName(arguments[0]);
            if(string.IsNullOrEmpty(inputDirectoryPath)) inputDirectoryPath = "." + Path.DirectorySeparatorChar;
            var inputFilePattern = Path.GetFileName(arguments[0]);
            var outputDirectoryPath = string.Empty;
            var outputFilename = string.Empty;

            if (string.IsNullOrEmpty(inputFilePattern)) inputFilePattern = "*.less";
            if (!Path.HasExtension(inputFilePattern)) inputFilePattern = Path.ChangeExtension(inputFilePattern, "less");

            if (arguments.Count > 1)
            {
                outputDirectoryPath = Path.GetDirectoryName(arguments[1]);
                outputFilename = Path.GetFileName(arguments[1]);
                outputFilename = Path.ChangeExtension(outputFilename, "css");
            }

            if (string.IsNullOrEmpty(outputDirectoryPath))
            {
                outputDirectoryPath = inputDirectoryPath;
            }
            else
            {
                Directory.CreateDirectory(outputDirectoryPath);
            }

            if (HasWildcards(inputFilePattern))
                outputFilename = string.Empty;

            var filenames = Directory.GetFiles(inputDirectoryPath, inputFilePattern);
            var engine = new EngineFactory(configuration).GetEngine();

            using (var watcher = new Watcher() { Watch = configuration.Watch })
            {
                if (watcher.Watch && HasWildcards(inputFilePattern))
                {
                    CompilationFactoryDelegate factoryDelegate = (input) => CreationImpl(engine, input, Path.GetFullPath(outputDirectoryPath));
                    watcher.SetupDirectoryWatcher(Path.GetFullPath(inputDirectoryPath), inputFilePattern, factoryDelegate);
                }

                foreach (var filename in filenames)
                {
                    var inputFile = new FileInfo(filename);

                    var outputFile =
                        string.IsNullOrEmpty(outputFilename) ?
                            Path.Combine(outputDirectoryPath, Path.ChangeExtension(inputFile.Name, "css")) :
                            Path.Combine(outputDirectoryPath, outputFilename);

                    var outputFilePath = Path.GetFullPath(outputFile);

                    CompilationDelegate compilationDelegate = () => CompileImpl(engine, inputFile.FullName, outputFilePath);

                    Console.WriteLine("[Compile]");

                    var files = compilationDelegate();

                    if (watcher.Watch)
                        watcher.SetupWatchers(files, compilationDelegate);
                }

                if (configuration.Watch)
                    WriteAbortInstructions();

                while (watcher.Watch && Console.ReadKey(true).Key != ConsoleKey.Enter)
                {
                    System.Threading.Thread.Sleep(200);
                }
            }
            return returnCode;
        }
Esempio n. 39
0
 public static void SetEngineFactory(EngineFactory engineFactory)
 {
     _engineFactory = engineFactory;
 }
Esempio n. 40
0
 static DocumentSessionFactory()
 {
     _engineFactory = str => new SqliteEngine(str);
 }