private void createobjs( int minus = 0) { int numColumns = 7 - minus; int numRows = 7 - minus; int numHigh = 7 - minus; float separation = 3; for (int i = 0; i < numRows; i++) for (int j = 0; j < numColumns; j++) for (int k = 0; k < numHigh; k++) { SimpleModel sm = new SimpleModel(GraphicFactory, "..\\Content\\Model\\cubo"); sm.SetTexture(GraphicFactory.CreateTexture2DColor(1, 1, StaticRandom.RandomColor()), TextureType.DIFFUSE); MaterialDescription md = MaterialDescription.DefaultBepuMaterial(); md.Bounciness = 1; BoxObject pi = new BoxObject(new Vector3(separation * i, k * separation, separation * j), 1, 1, 1, 1, new Vector3(1), Matrix.Identity, md); pi.Entity.AngularDamping = 0f; ForwardXNABasicShader shader = new ForwardXNABasicShader(); IMaterial mat = new ForwardMaterial(shader); IObject obj5 = new IObject(mat, sm, pi); this.World.AddObject(obj5); shader.BasicEffect.EnableDefaultLighting(); } }
public void Should_Be_Able_To_Commit_NoSql_Transaction() { var initial = NoSqlInitialModel; using (var trans = TransactionFactory.NewTransaction()) { var rm = trans.EnlistNosqlResourceManager(); var toTry = new SimpleModel { Id = initial.Id, Name = initial.Name, Number = 10 }; toTry.Should().NotBe(initial); rm.Add(() => NoSqlContext.Simple.Update(toTry), () => NoSqlContext.Simple.Update(initial)); trans.Commit(); } var results = NoSqlContext.Simple.FindAll().ToList(); results.Count.Should().Be(1); results.First().Should().NotBe(initial); results.First().Number.Should().Be(10); }
public void Should_Be_Able_To_Rollback_Async_Transaction() { var expected = SqlInitialModel; using (var trans = TransactionFactory.NewTransaction()) { var ctx = SqlContext; trans.EnlistSqlResourceManager(() => ctx.GetConnection()); var toTry = new SimpleModel { Id = expected.Id, Name = expected.Name, Number = expected.Number + 1 }; toTry.Should().NotBe(expected); Task.Factory.StartNew( () => { ctx.Update(toTry); }); trans.Rollback(); } var results = SqlContext.Simple.ToList(); results.Count.Should().Be(1); results.First().Should().Be(expected); }
public void BeforeEach() { _notification = new Notification(); _model = new SimpleModel(); _strategy = new GreaterThanZeroFieldStrategy(); _accessor = AccessorFactory.Create<SimpleModel>(m => m.GreaterThanZero); _rule = new FieldRule(_accessor, new TypeResolver(), _strategy); }
public void AttributeBypassesNonBlogViewModels() { var simpleModel = new SimpleModel(); var context = CreateContext(simpleModel); var attribute = new BlogModelAttribute(null); attribute.OnResultExecuting(context); Assert.That(simpleModel, Is.Not.TypeOf<BlogViewModel>()); }
public void SetUp() { theModel = new SimpleModel(); r1 = MockRepository.GenerateStub<IValidationRule>(); r2 = MockRepository.GenerateStub<IValidationRule>(); theSource = typeof(ConfiguredValidationSource); theContext = ValidationContext.For(theModel); theStep = new ValidationStep(theModel.GetType(), theSource, new[] { r1, r2 }); }
public void AddingLink_WhenValid_MakesLinksTheFirstKey() { const string rel = "myrel"; var model = new SimpleModel(); var graph = new HalGraph(model); var expectedLink = new Link("/api/some-resource"); var result = (HalGraph)graph.AddLink(rel, expectedLink); Assert.IsType <Dictionary <string, object> >(result[0]); }
public void AddingLink_WhenValid_ReturnsTheHalGraph() { const string rel = "myrel"; var model = new SimpleModel(); var graph = new HalGraph(model); var expectedLink = new Link("/api/some-resource"); var result = graph.AddLink(rel, expectedLink); Assert.Equal(expected: graph, actual: result); }
/// <summary> /// Create a simple Sphere object /// </summary> /// <param name="pos"></param> /// <param name="ori"></param> /// <returns></returns> private IObject SpawnPrimitive(Vector3 pos, Matrix ori) { ///Load a Model with a custom texture SimpleModel sm2 = new SimpleModel(factory, "Model\\ball"); sm2.SetTexture(factory.CreateTexture2DColor(1, 1, Color.White, false), TextureType.DIFFUSE); ForwardXNABasicShader nd = new ForwardXNABasicShader(); IMaterial m = new ForwardMaterial(nd); BulletPhysicObject BulletPhysicObject = new BulletPhysicObject(new SphereShape(1), pos, Matrix.Identity, Vector3.One, 10); IObject o = new IObject(m, sm2, BulletPhysicObject); return(o); }
public void AddingCurie_WhenValid_CreatesCurieCollection() { var model = new SimpleModel(); var graph = new HalGraph(model); var curieToCreate = new Curie("xx", "http://www.myapi.com/api/{something}"); graph.AddCurie(curieToCreate); var actualLink = ((Dictionary <string, object>)graph["_links"])["curies"]; Assert.IsAssignableFrom <IEnumerable <Link> >(actualLink); }
public ObjectMock(GraphicFactory GraphicFactory, String modelName, Vector3 position, Matrix orientation, Vector3 scale) { this.modelName = modelName; this.position = position; this.scale = scale; this.orientation = orientation; Modelo = new SimpleModel(GraphicFactory, modelName); PhysicObject = new TriangleMeshObject(Modelo, position, orientation, scale, MaterialDescription.DefaultBepuMaterial()); ForwardXNABasicShader shader = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default()); Material = new ForwardMaterial(shader); IObjectAttachment = new List <IObjectAttachment>(); }
public void AddingEmbeddedItem_WhenValid_ReturnsTheHalGraph() { const string embeddedItemName = "SOME-VALID-STRING"; var model = new SimpleModel(); var graph = new HalGraph(model); var expectedEmbeddedGraph = new HalGraph(model); var result = graph.AddEmbeddedItem(embeddedItemName, expectedEmbeddedGraph); Assert.Equal(expected: graph, actual: result); }
public async Task <IActionResult> Confirm([FromBody] SimpleModel <int> model) { var apiModel = new APIEmpIdModel <int>(); apiModel.EmployeeId = int.Parse(User.Claims.Single(c => c.Type == "userid").Value); apiModel.Model = model.Value; var result = await api.Post <APIEmpIdModel <int>, bool>("PurchaseOrder/Confirm", apiModel); //var result=await api.Get<bool>($"PurchaseOrder/Confirm/{id}"); //return RedirectToAction("Confirmed",new{id=model}); return(Json(result)); }
private IObject CreateSphere(Vector3 pos, Matrix ori) { ///Load a Model with a custom texture SimpleModel sm2 = new SimpleModel(gf, "Model\\ball"); sm2.SetTexture(gf.CreateTexture2DColor(1, 1, Color.White, false), TextureType.DIFFUSE); DeferredNormalShader nd = new DeferredNormalShader(); IMaterial m = new DeferredMaterial(nd); SphereObject pi2 = new SphereObject(pos, 1, 0.5f, 1, MaterialDescription.DefaultBepuMaterial()); IObject o = new IObject(m, sm2, pi2); return(o); }
/// <summary> /// Load content for the screen. /// </summary> /// <param name="GraphicInfo"></param> /// <param name="factory"></param> /// <param name="contentManager"></param> protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager) { base.LoadContent(GraphicInfo, factory, contentManager); RasterizerState = new RasterizerState(); RasterizerState.FillMode = FillMode.WireFrame; ///Forward Shader (look at this shader construction for more info) TerrainMaterial material = new TerrainMaterial(factory, "Terrain//HeightMap"); ///The object itself TerrainObject to = new TerrainObject(factory, Vector3.Zero, Matrix.Identity, material.Model.GetHeights(), MaterialDescription.DefaultBepuMaterial()); IObject obj = new IObject(material, null, to); ///Add to the world this.World.AddObject(obj); ///add a camera RotatingCamera cam = new RotatingCamera(this, new Vector3(-200, -100, -300)); this.World.CameraManager.AddCamera(cam); SkyBoxSetTextureCube stc = new SkyBoxSetTextureCube("Textures//cubeMap"); CommandProcessor.getCommandProcessor().SendCommandAssyncronous(stc); { Texture2D t = factory.CreateTexture2DColor(1, 1, Color.Red); SimpleModel simpleModel = new SimpleModel(factory, "Model/block"); simpleModel.SetTexture(t); ///Forward Shader (look at this shader construction for more info) ForwardXNABasicShader shader = new ForwardXNABasicShader(); ///Forward material ForwardMaterial fmaterial = new ForwardMaterial(shader); for (int i = 0; i < 10; i++) { for (int j = 0; j < 5; j++) { ///Physic info (position, rotation and scale are set here) BoxObject tmesh = new BoxObject(new Vector3(j * 10 + 200, 100, i * 10 + 200), 1, 1, 1, 10, Vector3.One * 2, Matrix.Identity, MaterialDescription.DefaultBepuMaterial()); ///The object itself obj = new IObject(fmaterial, simpleModel, tmesh); ///Add to the world this.World.AddObject(obj); objs.Add(obj); tmesh.isMotionLess = true; } } shader.BasicEffect.EnableDefaultLighting(); } }
protected override void AfterLoadContent(IContentManager manager, PloobsEngine.Engine.GraphicInfo ginfo, PloobsEngine.Engine.GraphicFactory factory) { base.AfterLoadContent(manager, ginfo, factory); this.ginfo = ginfo; pointLightEffect = factory.GetEffect("PrePass/plight"); _clearGBuffer = factory.GetEffect("PrePass/ClearGBuffer"); _lighting = factory.GetEffect("PrePass/LightingLpp"); sphereModel = new SimpleModel(factory, "Model/Dsphere"); ForwardPass = new ForwardPass(ForwardPassDescription.Default()); _width = ginfo.BackBufferWidth; _height = ginfo.BackBufferHeight; _cwDepthState = new DepthStencilState(); _cwDepthState.DepthBufferWriteEnable = false; _cwDepthState.DepthBufferFunction = CompareFunction.LessEqual; _ccwDepthState = new DepthStencilState(); _ccwDepthState.DepthBufferWriteEnable = false; _ccwDepthState.DepthBufferFunction = CompareFunction.GreaterEqual; _directionalDepthState = new DepthStencilState();; _directionalDepthState.DepthBufferWriteEnable = false; _directionalDepthState.DepthBufferFunction = CompareFunction.Greater; _depthStateDrawLights = new DepthStencilState(); //we draw our volumes with front-face culling, so we have to use GreaterEqual here _depthStateDrawLights.DepthBufferFunction = CompareFunction.GreaterEqual; //with our z-buffer reconstructed we only need to read it _depthStateDrawLights.DepthBufferWriteEnable = false; _depthStateReconstructZ = new DepthStencilState { DepthBufferEnable = true, DepthBufferWriteEnable = true, DepthBufferFunction = CompareFunction.Always }; _lightAddBlendState = new BlendState() { AlphaSourceBlend = Blend.One, ColorSourceBlend = Blend.One, AlphaDestinationBlend = Blend.One, ColorDestinationBlend = Blend.One, }; CreateGBuffer(factory); }
public ModelBuilder(GeneratorConfiguration configuration, XmlSchemaSet set) { _configuration = configuration; _set = set; DocumentationModel.DisableComments = _configuration.DisableComments; var objectModel = new SimpleModel(_configuration) { Name = "AnyType", Namespace = CreateNamespaceModel(new Uri(XmlSchema.Namespace), AnyType), XmlSchemaName = AnyType, XmlSchemaType = null, ValueType = typeof(object), UseDataTypeAttribute = false }; var key = BuildKey(new XmlSchemaComplexType(), AnyType); Types[key] = objectModel; AttributeGroups = set.Schemas().Cast <XmlSchema>().SelectMany(s => s.AttributeGroups.Values.Cast <XmlSchemaAttributeGroup>()) .DistinctBy(g => g.QualifiedName.ToString()) .ToDictionary(g => g.QualifiedName); Groups = set.Schemas().Cast <XmlSchema>().SelectMany(s => s.Groups.Values.Cast <XmlSchemaGroup>()) .DistinctBy(g => g.QualifiedName.ToString()) .ToDictionary(g => g.QualifiedName); var dependencyOrder = new List <XmlSchema>(); var seenSchemas = new HashSet <XmlSchema>(); foreach (var schema in set.Schemas().Cast <XmlSchema>()) { ResolveDependencies(schema, dependencyOrder, seenSchemas); } foreach (var schema in dependencyOrder) { var types = set.GlobalTypes.Values.Cast <XmlSchemaType>().Where(s => s.GetSchema() == schema); CreateTypes(types); var elements = set.GlobalElements.Values.Cast <XmlSchemaElement>().Where(s => s.GetSchema() == schema); CreateElements(elements); } if (configuration.GenerateInterfaces) { RenameInterfacePropertiesIfRenamedInDerivedClasses(); RemoveDuplicateInterfaceProperties(); } AddXmlRootAttributeToAmbiguousTypes(); }
public void Benchmark_Simple_Model() { var oldModel = new SimpleModel { Id = 1, Check = true, Name = "Name", Value = 1.23m, Date = new DateTime(2015, 01, 01, 12, 50, 30), Time = new TimeSpan(5, 4, 3), State = State.Inactive, Nullable = null, }; var newModel = new SimpleModel { Id = 1, Check = false, Name = "Name?", Value = 10.23m, Date = new DateTime(2015, 01, 02, 12, 50, 30), Time = new TimeSpan(5, 4, 1), State = State.Active, Nullable = true, }; var sw = new Stopwatch(); sw.Start(); var comparer = SutEngine.Get <SimpleModel>(); sw.Stop(); var compilation = sw.ElapsedMilliseconds; sw.Reset(); sw.Start(); var numIterations = 100000; for (var i = 0; i < numIterations; i++) { var updates = comparer(oldModel, newModel); } sw.Stop(); var benchmark = sw.ElapsedMilliseconds; Console.WriteLine($"Compilation took {compilation} ms."); Console.WriteLine($"{numIterations} iterations took {benchmark} ms."); Assert.IsTrue(benchmark < 500); }
protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager) { base.LoadContent(GraphicInfo, factory, contentManager); { SimpleModel simpleModel = new SimpleModel(factory, "Model//cenario"); TriangleMeshObject tmesh = new TriangleMeshObject(simpleModel, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial()); ForwardXNABasicShader shader = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default()); ForwardMaterial fmaterial = new ForwardMaterial(shader); IObject obj = new IObject(fmaterial, simpleModel, tmesh); this.World.AddObject(obj); } { SimpleModel sm = new SimpleModel(factory, "..\\Content\\Model\\block"); sm.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Blue), TextureType.DIFFUSE); ForwardXNABasicShader shader = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default()); ForwardMaterial fmaterial = new ForwardMaterial(shader); CharacterControllerInput character = new CharacterControllerInput(this, new Vector3(100, 150, 1), 1, 1, 50, Vector3.One * 10, 0.5f); BaseObject marine = new BaseObject(fmaterial, character.Characterobj, sm); this.World.AddObject(marine); ///ever !!! marine.Behavior = new Repeater <BaseObject>( new Watch <BaseObject>( (a, b) => { ///condition if (a.PhysicObject.Position.Length() < 100) { return(TaskResult.Failure); } return(TaskResult.Success); } , ///chnage its color =P new BehaviorTrees.Action <BaseObject>( (a, b) => { a.Modelo.SetTexture(factory.CreateTexture2DColor(1, 1, StaticRandom.RandomColor()), TextureType.DIFFUSE); return(TaskResult.Success); } ) ) ); } this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo)); }
protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager) { base.LoadContent(GraphicInfo, factory, contentManager); this.contentManager = contentManager; SimpleModel simpleModel = new SimpleModel(factory, "Model//cenario"); TriangleMeshObject tmesh = new TriangleMeshObject(simpleModel, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial()); DeferredNormalShader shader = new DeferredNormalShader(); DeferredMaterial fmaterial = new DeferredMaterial(shader); IObject obj = new IObject(fmaterial, simpleModel, tmesh); this.World.AddObject(obj); //ap = new SoundAudioPlayer(contentManager); //ap.AddSoundToRepository("Songs/bye", "bye"); //se = new SimpleSoundEffect(contentManager, "Songs/alarm"); //LocalMediaAudioPlayer lm = new LocalMediaAudioPlayer(); //AlbumCollection ac = lm.MediaLibrary.Albums; //lm.PlayAlbum(ac[0]); sound = new Static3DSound(factory, "Songs/pianosong", Vector3.Zero); this.World.AddSoundEmitter(sound, true); //ObjectFollower3DSound sound2 = new ObjectFollower3DSound(contentManager, "Songs/pianosong", obj); #region NormalLight DirectionalLightPE ld1 = new DirectionalLightPE(Vector3.Left, Color.White); DirectionalLightPE ld2 = new DirectionalLightPE(Vector3.Right, Color.White); DirectionalLightPE ld3 = new DirectionalLightPE(Vector3.Backward, Color.White); DirectionalLightPE ld4 = new DirectionalLightPE(Vector3.Forward, Color.White); DirectionalLightPE ld5 = new DirectionalLightPE(Vector3.Down, Color.White); float li = 0.5f; ld1.LightIntensity = li; ld2.LightIntensity = li; ld3.LightIntensity = li; ld4.LightIntensity = li; ld5.LightIntensity = li; this.World.AddLight(ld1); this.World.AddLight(ld2); this.World.AddLight(ld3); this.World.AddLight(ld4); this.World.AddLight(ld5); #endregion this.World.CameraManager.AddCamera(new CameraFirstPerson(true, GraphicInfo)); SkyBoxSetTextureCube stc = new SkyBoxSetTextureCube("Textures//cubemap"); CommandProcessor.getCommandProcessor().SendCommandAssyncronous(stc); }
public void AddingLink_WithEmptyRel_ThrowsException() { string rel = ""; var model = new SimpleModel(); var graph = new HalGraph(model); var linkToAdd = new Link("/api/some-resource"); Assert.Throws <ArgumentException>(() => { graph.AddLink(rel, linkToAdd); }); }
public MemoryStream BuildMemoryStream(SimpleModel model) { var json = "{" + $"\"Name\":\"{model.Name}\"," + $"\"Surname\":\"{model.Surname}\"" + "}"; var jsonAsByteArray = Encoding.UTF8.GetBytes(json); var stream = new MemoryStream(); stream.Write(jsonAsByteArray, 0, jsonAsByteArray.Length); stream.Position = 0; return(stream); }
public async Task Given_ModelAsJsonFormatter_When_Deserialize_IsCaller_WithValid_StreamAsJson_Then_Return_Model() { var sut = new ModelAsJsonFormatter(); var testExpectation = new SimpleModel { Name = "Foo", Surname = "Bar" }; var testEntry = BuildMemoryStream(testExpectation); var testResult = await sut.Deserialize <SimpleModel>(testEntry).ConfigureAwait(false); testResult.Should().BeEquivalentTo(testExpectation); }
public void ValidateField_PropertyInvalid() { var model = new SimpleModel { Age = 42 }; var fieldIdentifier = FieldIdentifier.Create(() => model.Age); var editContext = ValidateField(model, fieldIdentifier); var messages = editContext.GetValidationMessages(fieldIdentifier); Assert.Single(messages); Assert.Single(editContext.GetValidationMessages()); }
public void AddingMultipleLinks_WithEmptyLinksCollection_ThrowsException() { string rel = "my-rel"; var model = new SimpleModel(); var graph = new HalGraph(model); var linksToAdd = new List <Link>(); Assert.Throws <ArgumentException>(() => { graph.AddLinks(rel, linksToAdd); }); }
protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager) { PhysxPhysicWorld PhysxPhysicWorld = World.PhysicWorld as PhysxPhysicWorld; base.LoadContent(GraphicInfo, factory, contentManager); { SimpleModel simpleModel = new SimpleModel(factory, "Model//cenario"); PhysxTriangleMesh tmesh = new PhysxTriangleMesh(PhysxPhysicWorld, simpleModel, Matrix.Identity, Vector3.One); ForwardXNABasicShader shader = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default()); ForwardMaterial fmaterial = new ForwardMaterial(shader); IObject obj = new IObject(fmaterial, simpleModel, tmesh); this.World.AddObject(obj); } { ///Load a Model with a custom texture SimpleModel sm2 = new SimpleModel(factory, "Model\\ball"); sm2.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Aquamarine, false), TextureType.DIFFUSE); ForwardXNABasicShader nd = new ForwardXNABasicShader(); IMaterial m = new ForwardMaterial(nd); SphereShapeDescription SphereGeometry = new SphereShapeDescription(15f); PhysxGhostObject PhysxPhysicObject = new PhysxGhostObject(new Vector3(100, 100, 100), Matrix.Identity, Vector3.One * 15f); IObject o = new IObject(m, sm2, PhysxPhysicObject); this.World.AddObject(o); ///Physx Trigger !!! ///Just need to pass a shape to it ///WORKS THE SAME AS BEPU TRIGGER ///LOOK AT INTRODUCTION DEMOS PhysxTrigger PhysxTrigger = new PloobsEngine.Physics.PhysxTrigger( SphereGeometry, Matrix.CreateTranslation(new Vector3(100, 100, 100)), new PloobsEngine.Trigger.TriggerEvent("TriggerEvent", "TriggerEvent"), null, true, true, true); World.AddTrigger(PhysxTrigger); } BallThrowPhysx28 BallThrowBullet = new BallThrowPhysx28(this.World, GraphicFactory); this.AttachCleanUpAble(BallThrowBullet); this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo)); ReciveMessage = new ReciveMessage(); }
public void ChangeEvent_OnModelInsideCollection_ShouldFireCollectionChangeEvent() { var firstModel = new SimpleModel {Id = 3}; var c = new ViewModelCollection<SimpleModel>(typeof(SimpleModel)) { firstModel, new SimpleModel {Id = 6}, new SimpleModel {Id = 10} }; var collectionHasChanged = false; c.Bind("change", e => collectionHasChanged = true); firstModel.Trigger("change"); Assert.IsTrue(collectionHasChanged); }
protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager) { base.LoadContent(GraphicInfo, factory, contentManager); { SimpleModel simpleModel = new SimpleModel(factory, "Model//cenario"); TriangleMeshObject tmesh = new TriangleMeshObject(simpleModel, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial()); DeferredNormalShader shader = new DeferredNormalShader(); DeferredMaterial fmaterial = new DeferredMaterial(shader); IObject obj = new IObject(fmaterial, simpleModel, tmesh); this.World.AddObject(obj); } { SimpleModel sm = new SimpleModel(factory, "..\\Content\\Model\\block"); sm.SetTexture(factory.CreateTexture2DColor(1, 1, Color.White), TextureType.DIFFUSE); BoxObject pi = new BoxObject(new Vector3(100, 40, 0), 1, 1, 1, 25, new Vector3(100, 10, 100), Matrix.Identity, MaterialDescription.DefaultBepuMaterial()); DeferredNormalShader shader = new DeferredNormalShader(); IMaterial mat = new DeferredMaterial(shader); IObject obj3 = new IObject(mat, sm, pi); this.World.AddObject(obj3); } #region NormalLight DirectionalLightPE ld1 = new DirectionalLightPE(Vector3.Left, Color.White); DirectionalLightPE ld2 = new DirectionalLightPE(Vector3.Right, Color.White); DirectionalLightPE ld3 = new DirectionalLightPE(Vector3.Backward, Color.White); DirectionalLightPE ld4 = new DirectionalLightPE(Vector3.Forward, Color.White); DirectionalLightPE ld5 = new DirectionalLightPE(Vector3.Down, Color.White); float li = 0.5f; ld1.LightIntensity = li; ld2.LightIntensity = li; ld3.LightIntensity = li; ld4.LightIntensity = li; ld5.LightIntensity = li; this.World.AddLight(ld1); this.World.AddLight(ld2); this.World.AddLight(ld3); this.World.AddLight(ld4); this.World.AddLight(ld5); #endregion CameraFirstPerson cam = new CameraFirstPerson(GraphicInfo); cam.FarPlane = 1000; this.World.CameraManager.AddCamera(cam); this.RenderTechnic.AddPostEffect(new SSAOPost()); SkyBoxSetTextureCube stc = new SkyBoxSetTextureCube("Textures//grasscube"); CommandProcessor.getCommandProcessor().SendCommandAssyncronous(stc); }
public void Constructing_WithSinglePropertyModelProvided_AddsProperty() { const string expectedKeyName = "StringProperty"; const string expectedValue = "I AM A STRING FIELD"; var model = new SimpleModel { StringProperty = expectedValue }; var graph = new HalGraph(model); Assert.True(graph.Contains(expectedKeyName)); Assert.Equal(expected: expectedValue, actual: graph[expectedKeyName]); }
public void TrySetPropertyWithValidValues() { SimpleModel model = new SimpleModel(); ModelProperties <SimpleModel> modelProperties = new ModelProperties <SimpleModel>(); AssertPropertySetValue(modelProperties, model, "Id", "100"); AssertPropertySetValue(modelProperties, model, "Name", "Ampla"); AssertPropertySetValue(modelProperties, model, "Value", "1.234"); Assert.That(model.Id, Is.EqualTo(100)); Assert.That(model.Name, Is.EqualTo("Ampla")); Assert.That(model.Value, Is.EqualTo(1.234D)); }
public void AddingEmbeddedItem_WithEmptyName_ThrowsException() { var embeddedItemName = string.Empty; var model = new SimpleModel(); var graph = new HalGraph(model); var embeddedGraph = new HalGraph(model); Assert.Throws <ArgumentException>(() => { graph.AddEmbeddedItem(embeddedItemName, embeddedGraph); }); }
public void parseStreamWithEntitiesInNamespaceDeclaration() { string rdf = @"<?xml version=""1.0"" encoding=""UTF-8""?> <!DOCTYPE rdf:RDF [ <!ENTITY ex 'http://example.com/ns/'> ]> <rdf:RDF xmlns:rdf=""http://www.w3.org/1999/02/22-rdf-syntax-ns#"" xmlns:ex=""&ex;""> <rdf:Description rdf:about=""http://example.com""> <ex:value>Test</ex:value> </rdf:Description> </rdf:RDF>"; SimpleModel model = new SimpleModel(new XsltParserFactory()); XsltParserFactory parserFactory = new XsltParserFactory(); Parser parser = parserFactory.MakeParser(new ResourceFactory(), new StatementFactory()); parser.NewStatement += new StatementHandler(model.Add); MemoryStream stream = new MemoryStream(); StreamWriter writer = new StreamWriter(stream); writer.Write(rdf); writer.Flush(); stream.Position = 0; parser.Parse(stream, ""); NTripleListVerifier verifier = new NTripleListVerifier(); verifier.Expect(@"<http://example.com> <http://example.com/ns/value> ""Test"" ."); foreach (string ntriple in model) { verifier.Receive(ntriple); } bool testPassed = verifier.Verify(); string failureDescription = verifier.GetLastFailureDescription() + "\r\nTriples received:\r\n" + model.ToString(); if (!testPassed) { Console.WriteLine("XsltParserTest.parseWithEntities FAILED because "); Console.WriteLine(failureDescription); } Assert.IsTrue(testPassed); }
public void Clear() { if (mActivePlayer != null) { mActivePlayer.Destroy(); } mActivePlayer = null; if (mRoleRoot != null) { GameObject.Destroy(mRoleRoot); mRoleRoot = null; } }
public async Task <IActionResult> SendAsync([FromBody] SimpleModel model) { if (model != null) { var echo = $"Echo from server '{model.Key}' - {DateTime.Now}"; var obj = new { message = echo }; var webSocketContext = new WebSocketMessageContext { Command = WebSocketCommands.DataSend, Value = obj }; await _connectionManager.BroadcastAsync(webSocketContext); } return(Ok()); }
public ActionResult NormalPost(SimpleModel model) { var id = model.Id; var name = model.Name; var guid = Guid.NewGuid().ToString(); var filename = guid + Path.GetExtension(model.File.FileName); var filePath = Path.Combine(_env.WebRootPath, "_temp_upload", filename); // ~/wwwroot/_temp_upload/ var inputStream = model.File.OpenReadStream(); SaveFile(inputStream, filePath); var html = "download <a href=\"" + Url.Action("Download", new { file = filename }) + "\">" + filename + "</a>"; return(Content(html, "text/html")); }
protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager) { base.LoadContent(GraphicInfo, factory, contentManager); { SimpleModel simpleModel = new SimpleModel(factory, "Model//cenario"); TriangleMeshObject tmesh = new TriangleMeshObject(simpleModel, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial()); ForwardXNABasicShader shader = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default()); ForwardMaterial fmaterial = new ForwardMaterial(shader); IObject obj = new IObject(fmaterial, simpleModel, tmesh); this.World.AddObject(obj); } NeoforceGui guiManager = this.Gui as NeoforceGui; System.Diagnostics.Debug.Assert(guiManager != null); // Create and setup Window control. Window window = new Window(guiManager.Manager); window.Init(); window.Text = "Getting Started"; window.Width = 480; window.Height = 200; window.Center(); window.Visible = true; // Create Button control and set the previous window as its parent. Button button = new Button(guiManager.Manager); button.Init(); button.Text = "OK"; button.Width = 72; button.Height = 24; button.Left = (window.ClientWidth / 2) - (button.Width / 2); button.Top = window.ClientHeight - button.Height - 8; button.Anchor = Anchors.Bottom; button.Parent = window; button.Click += new TomShane.Neoforce.Controls.EventHandler(button_Click); // Add the window control to the manager processing queue. guiManager.Manager.Add(window); this.World.CameraManager.AddCamera(new CameraFirstPerson(false, GraphicInfo)); SkyBoxSetTextureCube stc = new SkyBoxSetTextureCube("Textures//grassCube"); CommandProcessor.getCommandProcessor().SendCommandAssyncronous(stc); }
protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, IContentManager contentManager) { base.LoadContent(GraphicInfo, factory, contentManager); ///Cenario SimpleModel sm = new SimpleModel(factory, "..\\Content\\Model\\cenario"); IShader normal = new DeferredNormalShader(); IMaterial mat = new DeferredMaterial(normal); IPhysicObject pi = new TriangleMeshObject(sm, new Vector3(0, 10, 100), Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial()); pi.isMotionLess = true; IObject obj4 = new IObject(mat, sm, pi); this.World.AddObject(obj4); ///Luzes DirectionalLightPE ld = new DirectionalLightPE(new Vector3(4, -2, 7), Color.White); this.World.AddLight(ld); ///Camera basica ICamera cam = new CameraFirstPerson(GraphicInfo); cam.Name = "stdCam"; this.World.CameraManager.AddCamera(cam); ///Associando callbacks com eventos do teclado { InputPlayableKeyBoard ipp = new SimpleConcreteKeyboardInputPlayable(StateKey.PRESS, Keys.R, Start); bkk0 = new BindKeyCommand(ipp, BindAction.ADD); CommandProcessor.getCommandProcessor().SendCommandAssyncronous(bkk0); InputPlayableKeyBoard ipp2 = new SimpleConcreteKeyboardInputPlayable(StateKey.PRESS, Keys.T, Stop); bkk1 = new BindKeyCommand(ipp2, BindAction.ADD); CommandProcessor.getCommandProcessor().SendCommandAssyncronous(bkk1); InputPlayableKeyBoard ipp3 = new SimpleConcreteKeyboardInputPlayable(StateKey.PRESS, Keys.Y, Load); bkk2 = new BindKeyCommand(ipp3, BindAction.ADD); CommandProcessor.getCommandProcessor().SendCommandAssyncronous(bkk2); } ///Camera Recorder (objeto q gravara e carregara os caminhos) record = new CameraRecordPath(this, cam); record.FinishInTheStartPosition = true; }
public bool IsOccluded(SimpleModel model) { timer.Start(); occQuery.Begin(); shapeDrawer.DrawBoundingBox(model.AABB, mainCamera); occQuery.End(); timer.Stop(); totalTime += timer.ElapsedMilliseconds; if (occQuery.IsComplete && occQuery.PixelCount>0) { return true; } return false; }
public void AddObject(SimpleModel _object) { Objects.Add(_object); if (childNodes==null) { if (Objects.Count>MaxObjectsPerNode) { SubDivide(); } } else { Distribute(); } }
public void ChangeEvent_OnModelInsideCollection_ShouldNotFireCollectionChangeEventAfterModelWasRemovedFromCollection() { var firstModel = new SimpleModel {Id = 3}; var c = new ViewModelCollection<SimpleModel>(typeof(SimpleModel)) { firstModel, new SimpleModel {Id = 6}, new SimpleModel {Id = 10} }; var collectionHasChanged = false; c.Bind("change", e => collectionHasChanged = true); c.Remove(firstModel, new ViewSetOptions {IsSilent = true}); Assert.IsFalse(collectionHasChanged, "Remove with silent should not trigger change"); firstModel.Trigger("change"); Assert.IsFalse(collectionHasChanged, "triggering the change event on an item that has been removed from a collection should not trigger the change event on the collection"); }
public void Benchmark_Simple_Model() { var oldModel = new SimpleModel { Id = 1, Check = true, Name = "Name", Value = 1.23m, Date = new DateTime(2015, 01, 01, 12, 50, 30), Time = new TimeSpan(5, 4, 3), State = State.Inactive, Nullable = null, }; var newModel = new SimpleModel { Id = 1, Check = false, Name = "Name?", Value = 10.23m, Date = new DateTime(2015, 01, 02, 12, 50, 30), Time = new TimeSpan(5, 4, 1), State = State.Active, Nullable = true, }; var sw = new Stopwatch(); sw.Start(); var comparer = SutEngine.Get<SimpleModel>(); sw.Stop(); var compilation = sw.ElapsedMilliseconds; sw.Reset(); sw.Start(); var numIterations = 100000; for (var i = 0; i < numIterations; i++) { var updates = comparer(oldModel, newModel); } sw.Stop(); var benchmark = sw.ElapsedMilliseconds; Console.WriteLine($"Compilation took {compilation} ms."); Console.WriteLine($"{numIterations} iterations took {benchmark} ms."); Assert.IsTrue(benchmark < 500); }
public void Should_Be_Able_To_Rollback_Serialized_Transaction() { var expected = NoSqlInitialModel; using (var trans = TransactionFactory.NewTransaction()) { var transToken = trans.ChildTransaction().ToToken(); var deserializedTrans = TransactionFactory.FromToken(transToken); var rm = deserializedTrans.EnlistNosqlResourceManager(); var toTry = new SimpleModel { Id = expected.Id, Name = expected.Name, Number = expected.Number + 1 }; toTry.Should().NotBe(expected); rm.Add(() => NoSqlContext.Simple.Update(toTry), () => NoSqlContext.Simple.Update(expected)); trans.Rollback(); } var results = NoSqlContext.Simple.FindAll().ToList(); results.Count.Should().Be(1); results.First().Should().Be(expected); }
protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, IContentManager contentManager) { base.LoadContent(GraphicInfo, factory, contentManager); #region Models createobjs(); ///Some Physic World Parameters ///No accuracy (speed up the simulation) and no gravity BepuPhysicWorld physicWorld = this.World.PhysicWorld as BepuPhysicWorld; physicWorld.Space.Solver.IterationLimit = 1; //Essentially no sustained contacts, so don't need to worry about accuracy. { SimpleModel sm = new SimpleModel(factory, "..\\Content\\Model\\cubo"); sm.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Blue), TextureType.DIFFUSE); MaterialDescription md = MaterialDescription.DefaultBepuMaterial(); md.Bounciness = 1; BoxObject pi = new BoxObject(new Vector3(0,-30,0), 1, 1, 1, 1, new Vector3(50,1,50), Matrix.Identity, md); pi.isMotionLess = true; pi.Entity.AngularDamping = 0f; ForwardXNABasicShader shader = new ForwardXNABasicShader(); IMaterial mat = new ForwardMaterial(shader); IObject obj5 = new IObject(mat, sm, pi); this.World.AddObject(obj5); shader.BasicEffect.EnableDefaultLighting(); } #endregion cam = new RotatingCamera(this); this.World.CameraManager.AddCamera(cam); }
private SqlDataContext CreateSqlDataContext() { if (!File.Exists(SqlDataFile)) { SQLiteConnection.CreateFile(SqlDataFile); } var connBuilder = new SQLiteConnectionStringBuilder(SqliteBaseConnectionString) { DataSource = SqlDataFile }; using (var ctx = new SqlDataContext(connBuilder.ConnectionString)) { using (var cmd = ctx.CreateCommand()) { cmd.CommandText = "CREATE TABLE IF NOT EXISTS Simple(Id INTEGER PRIMARY KEY ASC AUTOINCREMENT, Name TEXT NOT NULL, Number INTEGER NOT NULL)"; cmd.ExecuteNonQuery(); } ctx.Insert(CreateInitialModel()); SqlInitialModel = ctx.Simple.First(); } return new SqlDataContext(connBuilder.ConnectionString); }
public void Set_ShouldWork() { var c = new ViewModelCollection<SimpleModel>(typeof(SimpleModel)); var json = new SimpleModel {Id = 3}.ToJSON(); var list = new List<JsDictionary<string, object>> {json}; c.Set(list); Assert.AreEqual(c.Count, 1); Assert.AreEqual(c.ElementAt(0).Id, 3); }
// // GET: /Home/ public ActionResult Index(SimpleModel model) { string content = string.Format("Controller: {0}<br/>Action: {1}", model.Controller, model.Action); return new RawContentResult(content); }
public void AddModel(SimpleModel model) { model.Initialize(); model.LoadContent(); gameObjects.Add(model); }
public bool FustrumContains(SimpleModel model) { if (mainCamera.Frustum.Contains(model.AABB) != ContainmentType.Disjoint) return true; return false; }
public void Should_Be_Able_To_Rollback_Insert() { var nosqlResults = NoSqlContext.Simple.FindAll().ToList(); nosqlResults.Count.Should().Be(1); var sqlResults = SqlContext.Simple.ToList(); sqlResults.Count.Should().Be(1); using (var trans = TransactionFactory.NewTransaction()) { var @try = new SimpleModel { Id = 23, Name = Guid.NewGuid().ToString("N"), Number = new Random().Next() }; var nosqlTrans = trans.ChildTransaction(); var nosqlRm = nosqlTrans.EnlistNosqlResourceManager(); nosqlRm.Add(() => NoSqlContext.Simple.Insert(@try), () => NoSqlContext.Simple.Delete(x => x.Name == @try.Name && x.Number == @try.Number)); nosqlTrans.Complete(); var sqlTrans = trans.ChildTransaction(); sqlTrans.EnlistSqlResourceManager(() => SqlContext.GetConnection()); SqlContext.Insert(@try); sqlTrans.Complete(); trans.Rollback(); } nosqlResults = NoSqlContext.Simple.FindAll().ToList(); nosqlResults.Count.Should().Be(1); sqlResults = SqlContext.Simple.ToList(); sqlResults.Count.Should().Be(1); }
protected override void doWork(object sender, System.ComponentModel.DoWorkEventArgs e) { base.doWork(sender, e); path_candidates = new SimpleModel<LocationPath>(); user_candidates = new SimpleModel<string>(); ProgressHandler.state = ProgressState.Indeterminate; try { if (archive == null) { } } catch (Exception ex) { TranslatingMessageHandler.SendException(ex); } if (ArgArchives.Count > 0) archive = new Archive(new FileInfo(ArgArchives.Dequeue())); if (archive == null) throw new TranslateableException("NoRestoreFileSelected"); TranslatingProgressHandler.setTranslatedMessage("DetectingGameForRestoration"); if (!archive.Exists) throw new TranslateableException("FileNotFound", archive.ArchivePath); GameID selected_game = archive.id.Game; string backup_owner = archive.id.Owner; string archive_type = archive.id.Type; try { game_data = Games.detectGame(selected_game); } catch (Exception ex) { TranslatingMessageHandler.SendException(ex); } NotifyPropertyChanged("GameNotDetected"); if (game_data != null) { // This adds hypothetical locations foreach (LocationPath location in game_data.Locations.Paths) { if (game_data.DetectionRequired) break; filterPathCandidates(location); } // This add already found locations foreach (DetectedLocationPathHolder location in game_data.DetectedLocations) { location.IsSelected = true; switch (location.EV) { case EnvironmentVariable.ProgramFiles: case EnvironmentVariable.ProgramFilesX86: // This adds a fake VirtualStore folder, just in case if (Core.locations.uac_enabled) { DetectedLocationPathHolder temp = new DetectedLocationPathHolder(location, Core.locations.getFolder(EnvironmentVariable.LocalAppData, location.owner), location.owner); temp.ReplacePath(Path.Combine("VirtualStore", location.FullDirPath.Substring(3))); temp.EV = EnvironmentVariable.LocalAppData; addPathCandidate(temp); } addPathCandidate(location); break; default: addPathCandidate(location); break; } } //if (archive.id.Game.OS!=null&&archive.id.Game.OS.StartsWith("PS")) { // foreach (string drive in Core.locations.ps.GetDriveCandidates()) { // DetectedLocationPathHolder loc = new DetectedLocationPathHolder(EnvironmentVariable.Drive, drive, null); // addPathCandidate(loc); // } //} } if (archive.id.OriginalEV != EnvironmentVariable.None && archive.id.OriginalRelativePath != null) { LocationPath path = new LocationPath(archive.id.OriginalEV, archive.id.OriginalRelativePath); filterPathCandidates(path); } if (archive.id.OriginalLocation != null) { DetectedLocations locs = Core.locations.interpretPath(archive.id.OriginalLocation); DetectedLocationPathHolder loc = locs.getMostAccurateLocation(); if (loc != null) { addPathCandidate(loc); } } if (path_candidates.Count == 1) { multiple_paths = false; NotifyPropertyChanged("only_path"); } else if (path_candidates.Count > 1) { multiple_paths = true; } else { throw new TranslateableException("NoRestorePathsDetected", this.archive.id.ToString()); } }
public void Clear_ShouldWork() { bool isClearTriggered = false, isAllTriggered = false; var c = new ViewModelCollection<SimpleModel>(typeof(SimpleModel)); var m = new SimpleModel {Id = 3}; c.Add(m); Assert.AreEqual(c.Count, 1); c.Bind("all", e => isAllTriggered = true); c.Bind("clear", e => isClearTriggered = true); c.Clear(); Assert.AreEqual(c.Count, 0); Assert.AreEqual(isClearTriggered, true, "clear event should have been triggered"); Assert.AreEqual(isAllTriggered, true, "all event should have been triggered"); }
public void Contains_ShouldWork() { var c = new ViewModelCollection<SimpleModel>(typeof(SimpleModel)); var m = new SimpleModel {Id = 3}; c.Add(m); Assert.AreEqual(c.Count, 1); Assert.IsTrue(c.Contains(m)); }
public void ElementAt_ShouldWork() { var c = new ViewModelCollection<SimpleModel>(typeof(SimpleModel)); var m = new SimpleModel {Id = 3}; c.Add(m); Assert.AreEqual(c.Count, 1); Assert.AreEqual(c.ElementAt(0).Id, m.Id); }
public void Should_Be_Able_To_Rollback_Parent_Transaction() { var sqlExpected = SqlInitialModel; var nosqlExpected = NoSqlInitialModel; using (var trans = TransactionFactory.NewTransaction()) { var sqlTry = new SimpleModel { Id = sqlExpected.Id, Name = sqlExpected.Name + "-" + sqlExpected.Name, Number = sqlExpected.Number + 10 }; sqlTry.Should().NotBe(sqlExpected); var nosqlTry = new SimpleModel { Id = nosqlExpected.Id, Name = nosqlExpected.Name + "-" + nosqlExpected.Name, Number = nosqlExpected.Number + 10 }; nosqlTry.Should().NotBe(nosqlExpected); var nosqlTrans = trans.ChildTransaction(); var nosqlRm = nosqlTrans.EnlistNosqlResourceManager(); nosqlRm.Add(() => NoSqlContext.Simple.Update(nosqlTry), () => NoSqlContext.Simple.Update(nosqlExpected)); nosqlTrans.Complete(); var sqlTrans = trans.ChildTransaction(); sqlTrans.EnlistSqlResourceManager(() => SqlContext.GetConnection()); SqlContext.Update(sqlTry); sqlTrans.Complete(); trans.Rollback(); } var nosqlResults = NoSqlContext.Simple.FindAll().ToList(); nosqlResults.Count.Should().Be(1); nosqlResults.First().Should().Be(nosqlExpected); var sqlResults = SqlContext.Simple.ToList(); sqlResults.Count.Should().Be(1); sqlResults.First().Should().Be(sqlExpected); }
public void Should_Be_Able_To_Rollback_Native_Sql_Transaction() { var expected = SqlInitialModel; using (var trans = TransactionFactory.NewTransaction()) { trans.EnlistSqlResourceManager(() => SqlContext.GetConnection()); var toTry = new SimpleModel { Id = expected.Id, Name = expected.Name, Number = expected.Number + 1 }; toTry.Should().NotBe(expected); var nativeTrans = SqlContext.BeginTransaction(); SqlContext.Update(toTry); trans.Rollback(); nativeTrans.Invoking(x => x.Commit()).ShouldThrow<SQLiteException>(); } var results = SqlContext.Simple.ToList(); results.Count.Should().Be(1); results.First().Should().Be(expected); }
public void GetById_ShouldWork() { var c = new ViewModelCollection<SimpleModel>(typeof(SimpleModel)); var model = new SimpleModel {Id = 3}; c.Add(model); Assert.AreEqual(c.Count, 1); var a = c.GetById(model.Id); Assert.AreEqual(a.Id, model.Id); Assert.AreEqual(a, model); }
public void Remove_WithSilent_ShouldNotTriggerChangeEvent() { bool isChangeTriggered = false, isRemoveTriggered = false, isAllTriggered = false; var c = new ViewModelCollection<SimpleModel>(typeof(SimpleModel)); var m = new SimpleModel {Id = 3}; c.Add(m); Assert.AreEqual(c.Count, 1); c.Bind("all", e => isAllTriggered = true); c.Bind("change", e => isChangeTriggered = true); c.Bind("remove", e => isRemoveTriggered = true); c.Remove(m); Assert.AreEqual(c.Count, 0); Assert.AreEqual(isChangeTriggered, true, "change event should not have been triggered"); Assert.AreEqual(isRemoveTriggered, true, "remove event should not have been triggered"); Assert.AreEqual(isAllTriggered, true, "all event should not have been triggered"); }