public void Do(EngineFactory factory) { //Creates a instance of EngineA IEngine e = factory.CreateEngine <IEngine>("EngineA"); //returns a instance of EngineB IEngine eB = factory.CreateEngine <IEngine>("EngineB"); //returns null IEngine2 e2 = factory.CreateEngine <IEngine2>("EngineA"); //returns a instance of EngineB IEngine2 e2B = factory.CreateEngine <IEngine2>("EngineB"); }
public double CalculateInterest(double principle) { var engine = EngineFactory.CreateEngine <IInterestEngine>(); return(engine.CalculateCompoundedInterest( principle, 0.1, 12, 4)); }
public void TestPointLight() { var game = EngineFactory.CreateEngine(); game.Initialize(); var e = new Engine.WorldRendering.Entity() { Mesh = MeshFactory.Load("Core\\TileSet\\ts001sg001") }; var light = new PointLight { Position = new Vector3(-1, 0, 0) }; var time = 2f; game.AddSimulator(new BasicSimulator(delegate { time += TW.Graphics.Elapsed; light.Position = new Vector3(-1, (float)Math.Sin(time), (float)Math.Cos(time)); light.Size = 10; light.Intensity = 2; })); game.AddSimulator(new WorldRenderingSimulator()); game.Run(); }
public void TestGenerateLodTerrainMeshes() { var tree = new LodOctree(); var size = 128; var root = tree.Create(size, size); tree.UpdateQuadtreeClipmaps(root, new Vector3(size / 2, size / 2, size / 2), 8); var density = new Func <Vector3, float>(v => DensityHermiteGridTest.SineXzDensityFunction(v, 1 / 5f, size / 2, 3)); var builder = new LodOctreeMeshBuilder(); var list = new List <LodOctreeNode>(); builder.ListMeshLessNodes(root, list); list.ForEach(n => { if (n.Children != null) { return; } var mesh = builder.CalculateNodeMesh(n, 8, density); n.Mesh = mesh; // This is flakey builder.CreateRenderElementForNode(n, 8, mesh); }); EngineFactory.CreateEngine().AddSimulator(() => { tree.DrawLines(root, TW.Graphics.LineManager3D); }, "Octreelines"); VisualTestingEnvironment.Load(); }
public void TestDensityBasedLOD() { TW.Graphics.SpectaterCamera.FarClip = 5000; var maxSampleSize = 64; var skipLevels = 1; var density = createDensityFunction5Perlin(19, maxSampleSize / 2); var meshBuilder = new DualContouringMeshBuilder(); var size = maxSampleSize * (int)(Math.Pow(2, skipLevels)); var minSize = skipLevels; var maxSize = Math.Log(size) / Math.Log(2); for (int i = minSize; i < maxSize; i++) { var currI = i; var multiplier = (int)(Math.Pow(2, i)); var resolution = size / multiplier; var grid = HermiteDataGrid.CopyGrid(new DensityFunctionHermiteGrid(v => density(v * multiplier), new Point3(resolution, resolution, resolution))); var mesh = meshBuilder.buildMesh(grid); var el = TW.Graphics.AcquireRenderer().CreateMeshElement(mesh); el.WorldMatrix = Matrix.Scaling(new Vector3(multiplier)) * Matrix.Translation((size * 1.1f) * (i - skipLevels), 0, 0); } EngineFactory.CreateEngine().AddSimulator(new WorldRenderingSimulator()); }
public void TestPlanetSurface() { var engine = EngineFactory.CreateEngine(); engine.Initialize(); var terr = new VoxelTerrainChunk(); int i = 300; terr.Size = new Point3(i, 30, i); terr.Create(); for (int x = 1; x < i; x++) { for (int y = 1; y < 5; y++) { for (int z = 1; z < i; z++) { terr.GetVoxelInternal(new Point3(x, y, z)).Filled = true; } } } engine.AddSimulator(new VoxelTerrainSimulator()); //engine.AddSimulator(new EntityBatcherSimulator()); engine.AddSimulator(new WorldRenderingSimulator()); engine.Run(); }
public IEngine GetRenderingEngine(InstancePurposes renderingPurpose) { var engine = EngineFactory.CreateEngine(Template); engine.Init(Template, App, EnvInstance, Data, renderingPurpose, this, Log); return(engine); }
public void Operation_Deny_Direct_To_User() { EngineFactory factory = new EngineFactory(); ISecurityEngine engine = factory.CreateEngine(); ISecurityItem operation1 = engine.Store.AddSecurityItem().AddBagItem(Name, "Operation1"); ISecurityItem operation2 = engine.Store.AddSecurityItem().AddBagItem(Name, "Operation2"); ISecurityItem task = engine.Store.AddSecurityItem().AddBagItem(Name, "Task"); task.Children.Add(operation1); task.Children.Add(operation2); ISecurityItem hasNoAccessFromUserOperation = engine.Store.AddSecurityItem().AddBagItem(Name, "HasNoAccessFromUserOperation"); ISecurityIdentity user = engine.Store.AddSecurityIdentity().AddBagItem(Name, "user"); engine.Store.AccessAuthorize(user, task); engine.Store.AccessAuthorize(user, operation1).Deny(); ICheckAccessResult operation1AccessResult = engine.CheckAccess(user, operation1); ICheckAccessResult operation2AccessResult = engine.CheckAccess(user, operation2); ICheckAccessResult taskAccessResult = engine.CheckAccess(user, task); ICheckAccessResult hasNoAccessFromUserOperationAccessResult = engine.CheckAccess(user, hasNoAccessFromUserOperation); Assert.False(operation1AccessResult.HasAccess()); Assert.True(operation2AccessResult.HasAccess()); Assert.True(taskAccessResult.HasAccess()); Assert.False(hasNoAccessFromUserOperationAccessResult.HasAccess()); }
public void TestMultipleRooms() { var engine = EngineFactory.CreateEngine(); engine.Initialize(); var grid = new VoxelGrid <bool>(new Point3(50, 40, 50)); var gen = new SimpleCaveGenerator(); gen.Rand = new Random(); grid.ForEach((x, y, z) => grid[x, y, z] = true); //gen.GenerateRandom(grid, 0.30f); //gen.FillBorders(grid); gen.GenerateRooms(grid); //for (int i = 0; i < 5; i++) // gen.ProcessCellularAutomata(grid); new VoxelTerrainConvertor().SetTerrain(grid.ToArray()); engine.AddSimulator(new FlashlightSimulator()); engine.AddSimulator(new VoxelTerrainSimulator()); engine.AddSimulator(new WorldRenderingSimulator()); engine.Run(); }
public void CheckStatisShipWeight() { var ship = ShipFactory.CreateShip(); var engine = EngineFactory.CreateEngine(); var wing1 = WingFactory.CreateWing(); var wing2 = WingFactory.CreateWing(); wing1.Setup(w => w.Weight).Returns(5); wing2.Setup(w => w.Weight).Returns(10); var weapon1 = WeaponFactory.CreateWeapon(); weapon1.Setup(w => w.Weight).Returns(15); weapon1.Setup(w => w.DamageType).Returns(DamageTypeEnum.Statis); var weapon2 = WeaponFactory.CreateWeapon(); weapon2.Setup(w => w.Weight).Returns(20); weapon2.Setup(w => w.DamageType).Returns(DamageTypeEnum.Statis); wing1.Setup(w => w.Hardpoint).Returns((new[] { weapon1.Object }).ToList()); wing2.Setup(w => w.Hardpoint).Returns((new[] { weapon2.Object }).ToList()); engine.Setup(e => e.Weight).Returns(25); ship.Setup(s => s.Engine).Returns(engine.Object); ship.Setup(s => s.Wings).Returns((new[] { wing1.Object, wing2.Object }).ToList()); Assert.Equal(75 * 0.85, _calculations.GetShipWeight(ship.Object)); }
public void Setup() { engine = EngineFactory.CreateEngine(); consoleUi = new DeveloperConsoleUI(createCommandProvider()); var visible = true; consoleUi.Show(); engine.AddSimulator(new BasicSimulator(() => { if (TW.Graphics.Keyboard.IsKeyPressed(Key.Grave)) { visible = !visible; if (visible) { consoleUi.Show(); } else { consoleUi.Hide(); } } consoleUi.Update(); })); TW.Graphics.SpectaterCamera.EnableUserInput = false; }
public void CheckImploderCombination(int engineId, int weaponId) { var ship = ShipFactory.CreateShip(); var wing = WingFactory.CreateWing(); var weapon = WeaponFactory.CreateWeapon(); var engine = EngineFactory.CreateEngine(); wing.Setup(w => w.Hardpoint).Returns((new[] { weapon.Object }).ToList()); ship.Setup(s => s.Wings).Returns((new[] { wing.Object }).ToList()); ship.Setup(s => s.Engine).Returns(engine.Object); engine.Setup(e => e.Id).Returns(engineId); weapon.Setup(w => w.Id).Returns(weaponId); var valid = Validate(ship, "ImplosionDanger"); if (engineId == 2 && weaponId == 9) { Assert.False(valid); } else { Assert.True(valid); } }
public void TestInteractive() { var engine = EngineFactory.CreateEngine(); var game = TW.Graphics; var size = 32; var offset = new Vector3(0, 0, 0); var scaling = new Vector3(1, 1, 1); var density = "20-v.y"; var target = new GPUHermiteCalculator(game); var tex3d = target.CreateDensitySignsTexture(size); engine.AddSimulator(() => { target.WriteHermiteSigns(size, offset, scaling, density, tex3d); if (TW.Graphics.Keyboard.IsKeyPressed(Key.F)) { tex3d.SaveToImageSlices(game, TWDir.Test.CreateSubdirectory("DualContouring.GPU")); } TW.Graphics.Device.ImmediateContext.ClearState(); TW.Graphics.SetBackbuffer(); }, "Generate"); //tex3d.SaveToImageSlices(game, TWDir.Test.CreateSubdirectory("DualContouring.GPU")); }
public void TestRoom() { var engine = EngineFactory.CreateEngine(); engine.Initialize(); var grid = new VoxelGrid <bool>(new Point3(50, 40, 50)); var room = new BoundingBox(new Vector3(20, 20, 20), new Vector3(30, 30, 30)); var gen = new SimpleCaveGenerator(); gen.Rand = new Random(); gen.GenerateRandom(grid, 0.30f); gen.CreateRoom(grid, room); for (int i = 0; i < 5; i++) { gen.ProcessCellularAutomata(grid); } new VoxelTerrainConvertor().SetTerrain(grid.ToArray()); engine.AddSimulator(new FlashlightSimulator()); engine.AddSimulator(new VoxelTerrainSimulator()); engine.AddSimulator(new WorldRenderingSimulator()); engine.Run(); }
public void TestVoxelEditorBig() { var engine = EngineFactory.CreateEngine(); engine.Initialize(); //generateFlat(); generateTerrain(5, 5); TW.Data.GetSingleton <CameraInfo>().Mode = CameraInfo.CameraMode.FirstPerson; engine.AddSimulator(new FirstPersonCameraSimulator()); engine.AddSimulator(new TerrainEditorSimulator()); engine.AddSimulator(new VoxelTerrainSimulator()); engine.AddSimulator(new FlashlightSimulator()); engine.AddSimulator(new BarrelShooterSimulator()); //var playerData = new PlayerData(); //engine.AddSimulator(new LocalPlayerSimulator(playerData)); //engine.AddSimulator(new ThirdPersonCameraSimulator()); engine.AddSimulator(new PhysXSimulator()); engine.AddSimulator(new EngineUISimulator()); engine.AddSimulator(new WorldRenderingSimulator()); //engine.AddSimulator(new PhysXDebugRendererSimulator()); //TW.Data.GetSingleton<CameraInfo>().Mode = CameraInfo.CameraMode.ThirdPerson; //TW.Data.GetSingleton<CameraInfo>().ThirdPersonCameraTarget = playerData.Entity; engine.Run(); }
public void TestPersistence() { var engine = EngineFactory.CreateEngine(); engine.Initialize(); var terr = createBlob(); terr.WorldPosition = new Vector3(30, 0, 0); var file = new FileInfo(TWDir.Test + "\\VoxelTerrainTest_Persistance.txt"); if (file.Exists) { file.Delete(); } TW.Data.GetSingleton <Datastore>().Persist(terr); TW.Data.GetSingleton <Datastore>().SaveToFile(file); TW.Data.GetSingleton <Datastore>().LoadFromFile(file); engine.AddSimulator(new TerrainEditorSimulator()); engine.AddSimulator(new VoxelTerrainSimulator()); engine.AddSimulator(new WorldRenderingSimulator()); engine.Run(); }
public void TestVoxelEditor() { var engine = EngineFactory.CreateEngine(); engine.Initialize(); createBlob(); engine.AddSimulator(new TerrainEditorSimulator()); engine.AddSimulator(new VoxelTerrainSimulator()); engine.AddSimulator(new FlashlightSimulator()); engine.AddSimulator(new BarrelShooterSimulator()); var playerData = new PlayerData(); engine.AddSimulator(new LocalPlayerSimulator(playerData)); engine.AddSimulator(new ThirdPersonCameraSimulator()); engine.AddSimulator(new PhysXSimulator()); engine.AddSimulator(new WorldRenderingSimulator()); TW.Data.GetSingleton <CameraInfo>().Mode = CameraInfo.CameraMode.ThirdPerson; TW.Data.GetSingleton <CameraInfo>().ThirdPersonCameraTarget = playerData.Entity; engine.Run(); }
private NotificationResponse SendOrderEventEmail(int orderId, string eventMessage) { try { // get the order info var order = AccessorFactory.CreateAccessor <IOrderAccessor>() .FindOrder(orderId); // get any necessary seller data var seller = AccessorFactory.CreateAccessor <ISellerAccessor>() .Find(order.SellerId); // format the email var messageBody = EngineFactory.CreateEngine <IEmailFormattingEngine>() .FormatOrderEmailBody(order, seller); // send the email AccessorFactory.CreateAccessor <IEmailAccessor>() .SendEmailNotification(order.BillingAddress.EmailAddress, $"{eventMessage}: {seller.Name}", messageBody); return(new NotificationResponse() { Success = true, Message = $"{eventMessage} email sent to {order.BillingAddress.EmailAddress} for order {order.Id}" }); } catch (Exception ex) { Logger.Error(ex); return(new NotificationResponse() { Success = false, Message = $"There was a problem processing the {eventMessage} notice" }); } }
public HttpResponseMessage RenderTemplate([FromUri] int templateId) { try { var template = Sexy.TemplateContext.GetTemplate(templateId); var engine = EngineFactory.CreateEngine(template); var dataSource = (ViewDataSource)Sexy.GetViewDataSource(ActiveModule.ModuleID, SexyContent.HasEditPermission(ActiveModule), template); engine.Init(template, Sexy.App, ActiveModule, dataSource, InstancePurposes.WebView, Sexy); engine.CustomizeData(); if (template.AttributeSetID.HasValue && !template.DemoEntityID.HasValue && dataSource["Default"].List.Count == 0) { var toolbar = "<ul class='sc-menu' data-toolbar='" + Newtonsoft.Json.JsonConvert.SerializeObject(new { sortOrder = 0, useModuleList = true, action = "edit" }) + "'></ul>"; return(new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent("<div class='dnnFormMessage dnnFormInfo'>No demo item exists for the selected template. " + toolbar + "</div>") }); } var response = new HttpResponseMessage(HttpStatusCode.OK); response.Content = new StringContent(engine.Render(), Encoding.UTF8, "text/plain"); return(response); } catch (Exception e) { DotNetNuke.Services.Exceptions.Exceptions.LogException(e); throw e; } }
public override string TestMe(string input) { input = base.TestMe(input); input = EngineFactory.CreateEngine <IEmailFormattingEngine>().TestMe(input); input = AccessorFactory.CreateAccessor <IEmailAccessor>().TestMe(input); return(input); }
public override string TestMe(string input) { input = base.TestMe(input); input = AccessorFactory.CreateAccessor <SalesAcc.ICartAccessor>().TestMe(input); input = EngineFactory.CreateEngine <ITaxCalculationEngine>().TestMe(input); input = EngineFactory.CreateEngine <ICartPricingEngine>().TestMe(input); return(input); }
public void TestServerGame() { var server = new GodGameServerClient().CreateServer(null); server.AddSimulatorsToEngine(EngineFactory.CreateEngine()); server.Start(); }
protected override void Load(ContainerBuilder builder) { // Engine builder.RegisterInstance(EngineFactory.CreateEngine()).SingleInstance(); // Windsor builder.RegisterType <ProxyGenerator>().SingleInstance(); }
public decimal CalculateMortgagePayment (decimal houseAmount, decimal downPayment, decimal annualInterestRate, decimal loanPeriod) { var engine = EngineFactory.CreateEngine <IMortgageEngine>(); return(engine.CalculateMortgagePayment( houseAmount, downPayment, annualInterestRate, loanPeriod)); }
public void Add_SecurityItem() { EngineFactory factory = new EngineFactory(); ISecurityEngine firstEngine = factory.CreateEngine(); using (StorageProvider storageProvider = GetStorageProvider()) { firstEngine.Store.AttachToStorage(storageProvider.Storage); ISecurityItem addSecurityItem = firstEngine.Store.AddSecurityItem(); } ISecurityEngine secondEngine = factory.CreateEngine(); using (StorageProvider storageProvider = GetStorageProvider()) { secondEngine.Store.AttachToStorage(storageProvider.Storage); } }
public static void Load() { var engine = EngineFactory.CreateEngine(); engine.AddSimulator(new WorldRenderingSimulator()); engine.AddSimulator(new CameraLightSimulator()); engine.AddSimulator(new RecordingSimulator()); }
public void TestClientGame() { var game = new GodGameServerClient(); var client = game.CreateClient(null); client.AddSimulatorsToEngine(EngineFactory.CreateEngine()); client.ConnectToServer("7.63.207.22", 15005); }
public void WebPageEngine_GetWebPageContents() { var factory = new EngineFactory(); var engine = factory.CreateEngine <IWebPageEngine>(); string contents = engine.GetWebPageContents(@"http://www.google.com", false); Assert.AreNotEqual(0, contents.Length); }
BackOffice.OrderDataResponse BackOffice.IBackOfficeRemittanceManager.Totals() { try { // authenticate the user as a seller if (UtilityFactory.CreateUtility <ISecurityUtility>().BackOfficeAdminAuthenticated()) { var sellerOrderData = AccessorFactory.CreateAccessor <IRemittanceAccessor>() .SalesTotal(); if (sellerOrderData != null && sellerOrderData.Length > 0) { var result = new BackOffice.OrderDataResponse(); var items = new List <BackOffice.SellerOrderData>(); foreach (var item in sellerOrderData) { var mapped = DTOMapper.Map <BackOffice.SellerOrderData>(item); var calcResult = EngineFactory.CreateEngine <IRemittanceCalculationEngine>() .CalculateFee(mapped.SellerId, mapped.OrderTotal); mapped.FeeAmount = calcResult.FeeAmount; mapped.RemittanceAmount = calcResult.RemittanceAmount; items.Add(mapped); } result.Success = true; result.SellerOrderData = items.ToArray(); return(result); } else { return(new BackOffice.OrderDataResponse() { Success = false, Message = "No orders" }); } } return(new BackOffice.OrderDataResponse() { Success = false, Message = "BackOfficeAdmin not authenticated" }); } catch (Exception ex) { Logger.Error(ex); return(new BackOffice.OrderDataResponse() { Success = false, Message = "There was a problem accessing sellers orders" }); } }
public void TestShowError() { var engine = EngineFactory.CreateEngine(); engine.AddSimulator(new BasicSimulator(delegate { throw new NotImplementedException(); })); }
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()); }