public void Render_TemplateWithForeach_RenderIEnumerableOfAddresses() { //for this potentially can extract whole section and then render it and re-insert var message = new ComplexModel { SomeText = "Bob", BunchOfAddresses = new List <Address>() { new Address { StreetNumber = 5, StreetName = "Main" }, new Address { StreetNumber = 10, StreetName = "Main" } } }; string templateText = @"{{SomeText}} <<foreach:BunchOfAddresses>>{{StreetNumber}} {{StreetName}} <</foreach:BunchOfAddresses>>"; var template = new Template <ComplexModel>(templateText); var content = new TemplateRenderer <ComplexModel>(template); var text = content.Render(message); Assert.Contains("5 Main", text); Assert.Contains("10 Main", text); Assert.Contains("Bob", text); }
protected virtual string GenerateGetFromMixedArgQueryString(Int32 id, ComplexModel dataArg) { var kvList = GenerateGetFromMixedArgKeyValueList(id, dataArg); var urlTpl = GenerateQueryStrFromKvList(kvList); return(urlTpl); }
public IActionResult ChangeSaleStatus(string saleId) { if (this.saleService.SaleExists(saleId) == false) { return(this.NotFound()); } if (this.TempData[GlobalConstants.ErrorsFromPOSTRequest] != null) { ModelStateHelper.MergeModelStates(this.TempData, this.ModelState); } var viewModel = this.saleService.GetAllSaleStatuses(); var inputModel = new ChangeSaleStatusInputModel { SaleId = saleId }; if (this.TempData["NewSaleStatusId"] != null) { inputModel.NewSaleStatusId = this.TempData["NewSaleStatusId"].ToString(); } var complexModel = new ComplexModel <ChangeSaleStatusInputModel, List <SaleStatus> > { ViewModel = viewModel, InputModel = inputModel }; return(this.View(complexModel)); }
public void TestErrorDuringRetrieval_GetOverflownContents() { // Arrange var client = new CloudEnvironment(); var queue = client.QueueClient.GetQueueReference("test7"); var overflow = client.BlobClient.GetContainerReference("overflownqueues-7"); var rnd = new Random(); ComplexModel result = null; var expected = new ComplexModel { Name = new string(Enumerable.Range(1, 128 * 1024).Select(r => (char)rnd.Next(1024, 4096)).ToArray()) }; var sw = new Stopwatch(); var succeeded = false; var factoryOne = new DefaultExtendedQueueFactory( new AzureQueueMessageProvider(), new AzureMaximumMessageSizeProvider(), new AzureMaximumMessagesPerRequestProvider(), new ChaosMonkeyOverflownMessageHandler(new AzureBlobContainer(overflow), ChaosMonkeyOverflownMessageHandler.FailureMode.GetOverflownContents), new ConsoleLogService() ); new AzureExtendedQueueFactory(new AzureBlobContainer(overflow), new ConsoleLogService()); var equeue = factoryOne.Create(new AzureQueue(queue)); using (var mre = new ManualResetEvent(false)) { var options = new HandleMessagesSerialOptions( TimeSpan.FromSeconds(0), TimeSpan.FromMinutes(2), TimeSpan.FromSeconds(30), 1, new CancellationToken(), message => { result = message.GetMessageContents <ComplexModel>(); mre.Set(); return(Task.FromResult(true)); }, null, ex => { succeeded = true; mre.Set(); }); // Act sw.Start(); queue.CreateIfNotExists(); overflow.CreateIfNotExists(); queue.Clear(); equeue.AddMessageEntity(expected); equeue.HandleMessagesInSerialAsync(options); // Assert mre.WaitOne(); sw.Stop(); Trace.WriteLine("Total execution time (in seconds): " + sw.Elapsed.TotalSeconds.ToString(CultureInfo.InvariantCulture)); Assert.IsTrue(succeeded); } }
public async Task BindModelAsync(ModelBindingContext bindingContext) { if (bindingContext == null) { throw new ArgumentNullException(nameof(bindingContext)); } var typeValue = bindingContext.ValueProvider.GetValue(nameof(ComplexModel.Type)).Values; var nameValue = bindingContext.ValueProvider.GetValue(nameof(ComplexModel.Name)).Values; var finalModel = new ComplexModel { Name = nameValue, Type = typeValue }; var innerType = LookupType(typeValue); if (innerType != null) { finalModel.Parameters = Activator.CreateInstance(innerType); var modelMetadata = _modelMetadataProvider.GetMetadataForType(innerType); var modelBinder = _modelBinderFactory.CreateBinder(new ModelBinderFactoryContext { Metadata = modelMetadata, CacheToken = modelMetadata }); var modelName = bindingContext.BinderModelName == null ? "Parameters" : $"{bindingContext.BinderModelName}.Parameters"; using (var scope = bindingContext.EnterNestedScope(modelMetadata, modelName, modelName, finalModel.Parameters)) { await modelBinder.BindModelAsync(bindingContext); } } bindingContext.Result = ModelBindingResult.Success(finalModel); return; }
public async Task Update__Given_Model__When_NoPatch__Then_Return (Guid modelId) { var model = new ComplexModel { Id = modelId }; var mockRequestBuilder = new Mock <IHttpRequestBuilder>(); var mockHandler = new MockRequestHandler(); var modelRegistry = CreateModelRegistry( typeof(ComplexModel), typeof(BasicModel)); var mockCacheProvider = new Mock <ICacheProvider>(); var subject = CreateSubject( mockHandler, mockRequestBuilder.Object, mockCacheProvider.Object, modelRegistry); model = subject.ManageModel(model); await subject.Update(model); Assert.Equal(0, mockHandler.RequestsSent); mockRequestBuilder.Verify(x => x.UpdateResource(It.IsAny <Resource>(), It.IsAny <ResourceRootSingle>()), Times.Never); mockCacheProvider.Verify(x => x.Update(It.IsAny <Guid>(), It.IsAny <object>()), Times.Never); }
public async Task QueryByRelationship(Guid parentId, Guid[] childIds) { await DeleteAll <ComplexModel>(); await DeleteAll <BasicModel>(); using (var session = SessionFactory.CreateSession()) { var parent = new ComplexModel { Id = parentId, BasicModels = childIds.Select(x => new BasicModel { Id = x, PropA = "hello" }) .ToList() }; await session.Create(parent); } using (var session = SessionFactory.CreateSession()) { var result = session.GetRelated <ComplexModel, BasicModel>(parentId, x => x.BasicModels) .Where(x => x.PropA == "hello") .ToArray(); Assert.NotNull(result); Assert.Equal(childIds.Length, result.Length); Assert.All(childIds, x => Assert.NotNull(result.SingleOrDefault(c => c.Id == x))); } await DeleteAll <ComplexModel>(); await DeleteAll <BasicModel>(); }
public static ComplexModel UpdateComplexModel(ComplexModel complexModel) { if (complexModel == null) throw new ArgumentNullException("complexModel"); return complexModel; }
/// <summary> /// /// </summary> /// <param name="dataArg"></param> /// <returns></returns> public virtual async Task <ComplexModel> GetFromComplexArgAsync(ComplexModel dataArg) { var requestUrl = "api/test/GetFromComplexArg"; var queryHasParamUrl = ""; var queryNoParamUrl = GenerateGetFromComplexArgQueryString(dataArg); if (string.IsNullOrEmpty(queryHasParamUrl)) { requestUrl = requestUrl + "?" + queryNoParamUrl; } else { requestUrl = requestUrl + "?" + queryHasParamUrl + "&" + queryNoParamUrl; } var result = await HttpClient.GetAsync(requestUrl); EnsureSuccess(result); return(await result.Content.ReadAsAsync <ComplexModel>()); }
/// <summary> /// /// </summary> /// <param name="id"></param> /// <param name="dataArg"></param> /// <returns></returns> public virtual async Task <NestedModel> GetFromMixedArgAsync(Int32 id, ComplexModel dataArg) { var requestUrl = "api/test/GetFromMixedArg"; var queryHasParamUrl = "id=" + Uri.EscapeDataString(Convert.ToString(id)) + ""; var queryNoParamUrl = GenerateGetFromMixedArgQueryString(id, dataArg); if (string.IsNullOrEmpty(queryHasParamUrl)) { requestUrl = requestUrl + "?" + queryNoParamUrl; } else { requestUrl = requestUrl + "?" + queryHasParamUrl + "&" + queryNoParamUrl; } var result = await HttpClient.GetAsync(requestUrl); EnsureSuccess(result); return(await result.Content.ReadAsAsync <NestedModel>()); }
public bool BindModel(ModelBindingExecutionContext modelBindingExecutionContext, ModelBindingContext bindingContext) { ModelBinderUtil.ValidateBindingContext(bindingContext, typeof(ComplexModel), false /* allowNullModel */); ComplexModel complexModel = (ComplexModel)bindingContext.Model; foreach (ModelMetadata propertyMetadata in complexModel.PropertyMetadata) { ModelBindingContext propertyBindingContext = new ModelBindingContext(bindingContext) { ModelMetadata = propertyMetadata, ModelName = ModelBinderUtil.CreatePropertyModelName(bindingContext.ModelName, propertyMetadata.PropertyName) }; // bind and propagate the values IModelBinder propertyBinder = bindingContext.ModelBinderProviders.GetBinder(modelBindingExecutionContext, propertyBindingContext); if (propertyBinder != null) { if (propertyBinder.BindModel(modelBindingExecutionContext, propertyBindingContext)) { complexModel.Results[propertyMetadata] = new ComplexModelResult(propertyBindingContext.Model, propertyBindingContext.ValidationNode); } else { complexModel.Results[propertyMetadata] = null; } } } return(true); }
public IActionResult Index(string sortOrder, string currentFilter, string SearchCode, int?pageNumber, string GroupValue) { ViewData["CurrentSort"] = sortOrder; ViewData["CurrentFilter"] = SearchCode; ViewData["DateSortParm"] = sortOrder == "Date" ? "date_desc" : "Date"; var posts = from s in _context.Files select s; switch (sortOrder) { case "Date": posts = posts.OrderBy(s => s.CreatedOn); break; case "date_desc": posts = posts.OrderByDescending(s => s.CreatedOn); break; default: posts = posts.OrderByDescending(s => s.CreatedOn); break; } if (!String.IsNullOrEmpty(SearchCode) && !String.IsNullOrEmpty(GroupValue)) { posts = posts.Where(s => s.CourseCode.Equals(SearchCode) && s.Category.Equals(GroupValue)); } else if (!String.IsNullOrEmpty(SearchCode)) { posts = posts.Where(s => s.CourseCode.Equals(SearchCode)); } else { } if (SearchCode != null) { pageNumber = 1; } else { SearchCode = currentFilter; } int pageSize = 10; ViewBag.CourseCode = new SelectList(_dataHelper.GetDict().Keys.ToList()); var obj = HttpContext.Session.GetObject <Student>("student"); if (obj != null) { return(RedirectToAction("Index", "Student")); } IPagedList <Files> _posts = posts.ToPagedList(pageNumber ?? 1, pageSize); List <Files> _favoriteList = Get_Favorite_Posts(); var modelView = new ComplexModel(_posts, _favoriteList); return(View(modelView)); // table contextinin kullanilabilmesi için yukarıda olusturulan nesne kullanıldı }
public static ComplexModel UpdateComplexModel(ComplexModel complexModel) { if (complexModel == null) { throw new ArgumentNullException("complexModel"); } return(complexModel); }
static void Main(string[] args) { var baseAddr = "http://localhost:8888"; Console.WriteLine("hello------from origin http client"); var client = new HttpClient { BaseAddress = new Uri(baseAddr) }; var res = client.GetAsync("api/test/GetFromSimpleArg?id=world").Result.Content.ReadAsStringAsync().Result; Console.WriteLine(res); Console.WriteLine("\n\n"); var proxy = new ProxyClient(); Console.WriteLine("hello------from web api proxy"); var v1 = proxy.GetFromSimpleArg("just say this is my name"); Console.WriteLine("1---" + JsonConvert.SerializeObject(v1)); v1 = proxy.GetFromSimpleArgAsync("just say this is my name").Result; Console.WriteLine("1-async---" + JsonConvert.SerializeObject(v1)); var complexModel = new ComplexModel() { Age = 18, Name = "super star" }; var v2 = proxy.GetFromComplexArg(complexModel); Console.WriteLine("2---" + JsonConvert.SerializeObject(v2)); var v3 = proxy.GetFromMixedArg(2016, complexModel); Console.WriteLine("3---" + JsonConvert.SerializeObject(v3)); var nest = new NestedModel() { Id = 999999, ComplexModel = complexModel }; var v4 = proxy.PostFromMixedArg("this is my str", nest, complexModel); Console.WriteLine("4---" + JsonConvert.SerializeObject(v4)); var v5 = proxy.PostFromMixedArg2("this is my str", complexModel, nest); Console.WriteLine("5---" + JsonConvert.SerializeObject(v5)); Console.WriteLine("---------------done!"); Console.ReadLine(); }
public void IsNotValidTestComplex() { var model = new ComplexModel { Value1 = new ComplexModel.SubModel { InnerValue = "hello" }, Value2 = "" }; Assert.False(model.IsValid("Value2")); }
public override bool Equals(object obj) { ComplexModel model = obj as ComplexModel; if (model == null) { return(false); } return(ComplexIntProperty == model.ComplexIntProperty && ComplexNullableIntProperty == model.ComplexNullableIntProperty); }
protected override void EstablishContext() { model = new ComplexModel() { FirstName = "Albert", LastName = "Weinert", Age = 39, Sex = 'm', Amount = 815.4711m }; }
public void IsNotValidTestComplex() { var model = new ComplexModel() { Value1 = new ComplexModel.SubModel() { InnerValue = "hello" }, Value2 = "" }; var ctx = new ValidationContext(model, null, null); var results = new List<ValidationResult>(); bool actual = Validator.TryValidateObject(model, ctx, results, true); var expected = false; Assert.AreEqual(actual, expected); }
public void Render_WithTemplateForNullable_ReturnsValueIs5() { var message = new ComplexModel() { NullIntProp = 5 }; var template = new Template <ComplexModel>("Value is {{NullIntProp}}"); var content = new TemplateRenderer <ComplexModel>(template); var text = content.Render(message); Assert.Equal("Value is 5", text); }
public void IsValidTestComplex() { var model = new ComplexModel() { Value1 = new ComplexModel.SubModel() { InnerValue = "hello" }, Value2 = "bla" }; Assert.IsTrue(model.IsValid("Value2")); }
public void IsNotValidTestComplex() { var model = new ComplexModel() { Value1 = new ComplexModel.SubModel() { InnerValue = "hello" }, Value2 = new string[] { "bla", "bla2", "bla3", "bla4" } }; Assert.IsFalse(model.IsValid("Value2")); }
public static void AssertPopulatedData(ComplexModel expected, ComplexModel actual) { var expectedObject = JObject.FromObject(expected); expectedObject.Property("NonPersisted").Remove(); var actualObject = JObject.FromObject(actual); actualObject.Property("NonPersisted").Remove(); Assert.AreEqual(expectedObject, actualObject); }
public async Task PostComplexModel(ComplexModel complexModel) { var message = RouteHelper.BuildRequestMessage <UnitTestController, Task <string> >(controller => controller.PostComplexModel(complexModel)); message.Should().NotBeNull(); message.Method.Should().Be(System.Net.Http.HttpMethod.Post); message.Content.Should().BeOfType <StringContent>(); var content = await message.Content.ReadAsStringAsync(); var ogContent = JsonConvert.SerializeObject(complexModel); content.Should().Be(ogContent); }
public void CastEmbeddedItemAsEntity_WithValidMapperForTypeRegistered_ReturnsPopulatedEntity() { string validJson = "{ }"; const string keyName = "some-Key"; var loader = new Mock <IHalResponseLoader>(); loader.Setup(loader => loader.Load(validJson)).Returns( new Dictionary <string, object> { { "_embedded", new Dictionary <string, object> { { keyName, new Dictionary <string, object> { { "id", Guid.Parse("3b947c60-dcf8-4199-95a1-7a70fd81d16a") }, { "full-name", "My Name" }, { "date", new DateTime(2020, 7, 5) } } } } } }); var expectedEmbeddedModel = new ComplexModel { Id = Guid.Parse("3b947c60-dcf8-4199-95a1-7a70fd81d16a"), Name = "My Name", Date = new DateTime(2020, 7, 5) }; var mapper = new Mock <IEntityMapper <ComplexModel> >(); mapper.Setup(mapper => mapper.Map()).Returns(expectedEmbeddedModel); var mapperFactory = new Mock <IEntityMapperFactory>(); mapperFactory.Setup(factory => factory.GetMapper <ComplexModel>()).Returns(mapper.Object); var resource = new HalResource(loader.Object, mapperFactory.Object); resource.Load(validJson); var retrievedValue = resource.CastEmbeddedItemAs <ComplexModel>(keyName); retrievedValue.ShouldDeepEqual(expectedEmbeddedModel); }
public void TestSerializedMessages() { // Arrange var client = new CloudEnvironment(); var queue = client.QueueClient.GetQueueReference("test5"); var overflow = client.BlobClient.GetContainerReference("overflownqueues-5"); ComplexModel result = null; var expected = new ComplexModel { Name = "Test" }; var sw = new Stopwatch(); var factory = new AzureExtendedQueueFactory(new AzureBlobContainer(overflow), new ConsoleLogService()); var equeue = factory.Create(new AzureQueue(queue)); using (var mre = new ManualResetEvent(false)) { var options = new HandleMessagesSerialOptions( TimeSpan.FromSeconds(0), TimeSpan.FromMinutes(2), TimeSpan.FromSeconds(30), 5, new CancellationToken(), message => { result = message.GetMessageContents <ComplexModel>(); mre.Set(); return(Task.FromResult(true)); }, null, ex => { throw ex; }); // Act sw.Start(); queue.CreateIfNotExists(); overflow.CreateIfNotExists(); queue.Clear(); equeue.AddMessageEntity(expected); equeue.HandleMessagesInSerialAsync(options); // Assert mre.WaitOne(); sw.Stop(); Trace.WriteLine("Total execution time (in seconds): " + sw.Elapsed.TotalSeconds.ToString(CultureInfo.InvariantCulture)); Assert.AreEqual(expected.Name, result.Name); Assert.AreEqual(expected.ADictionary.First().Key, result.ADictionary.First().Key); Assert.AreEqual(expected.ADictionary.First().Value, result.ADictionary.First().Value); Assert.AreEqual(expected.AList.First(), result.AList.First()); } }
public async Task PostComplexModelWithRouteParameter(ComplexModel complexModel) { //this is how we add custom controller action parameter decomposers ControllerActionParameterBinders.AddBinders(new IdModelProvider()); var message = RouteHelper.BuildRequestMessage <UnitTestController, Task <string> >(controller => controller.PostComplexModelWithId(complexModel)); message.Should().NotBeNull(); message.Method.Should().Be(System.Net.Http.HttpMethod.Post); message.Content.Should().BeOfType <StringContent>(); message.RequestUri.ToString().Should().Be($"/api/v1/UnitTest/{complexModel.Id}"); var content = await message.Content.ReadAsStringAsync(); var ogContent = JsonConvert.SerializeObject(complexModel); content.Should().Be(ogContent); }
public void Render_TemplateWithIEnumerable_RenderIEnumerableOfString() { var message = new ComplexModel { BunchOfStrings = new List <string>() { "ONE", "TWO" } }; var template = new Template <ComplexModel>("{{BunchOfStrings}}"); var content = new TemplateRenderer <ComplexModel>(template); var text = content.Render(message); Assert.Contains("ONE, TWO", text); }
public void Compare_ComparesComplexModels_DefaultOptions_SameObject() { const int id = 123; const string value = "fnord"; var date = DateTime.Now; const string link = @"http://example.com/subpage/?param=1&other=test"; var options = new CompareOptions().Use(EqualityComparer <Uri> .Default); var complex = new ComplexModel { Codes = new HashSet <string>(new[] { "A", "b", "cee" }), Link = new Uri(link), NumberSequence = new List <int> { 1, 2, 3 }, Simple = new SimpleModel { Id = id, Timestamp = date, Value = value }, Simples = new[] { new SimpleModel { Id = id + 1, Timestamp = date, Value = value }, new SimpleModel { Id = id + 2, Timestamp = date, Value = value } }, Nested = new ComplexModel { Codes = new HashSet <string>(new[] { "test1", "test2" }) } }; ReferenceEquals(complex, complex).Should().BeTrue("they are the same objects"); ObjectComparer.Compare(complex, complex, out _, options).Should().BeTrue("they are the same object"); }
public async Task <IActionResult> Buy(ComplexModel <List <BuyProductInputModel>, List <ProductCartViewModel> > complexModel) { this.TempData[GlobalConstants.InputModelFromPOSTRequestType] = $"List<{nameof(BuyProductInputModel)}>"; this.TempData[GlobalConstants.InputModelFromPOSTRequest] = JsonSerializer.Serialize(complexModel.InputModel); //Inital model validation without checking the database if (this.ModelState.IsValid == false) { this.TempData[GlobalConstants.ErrorsFromPOSTRequest] = ModelStateHelper.SerialiseModelState(this.ModelState); //Set notification NotificationHelper.SetNotification(this.TempData, NotificationType.Error, "An error occured while processing your request"); return(this.RedirectToAction(nameof(All))); } var currentUserId = this.userService.GetUserId(this.User.Identity.Name); foreach (var productInputModel in complexModel.InputModel) { if (this.cartService.ProductIsInCart(productInputModel.Id, currentUserId) == false) { //Set notification NotificationHelper.SetNotification(this.TempData, NotificationType.Error, "One or more of the products are not in the cart"); this.ModelState.AddModelError("", "One or more of the products are not in the cart"); } } if (this.ModelState.IsValid == false) { //Set error model state this.TempData[GlobalConstants.ErrorsFromPOSTRequest] = ModelStateHelper.SerialiseModelState(this.ModelState); return(this.RedirectToAction(nameof(All))); } var inputModel = complexModel.InputModel; foreach (var item in inputModel) { await this.cartService.SetCheckoutCartAsync(currentUserId, inputModel); } return(this.RedirectToAction("Checkout", "Sales")); }
public void should_correctly_serialize_populated_data_into_existing_object_with_json() { var model = SerializationTestHelper.GeneratePopulatedModel(); var serializer = new JsonSerializer(_mappingRegistry); var output = serializer.Serialize(model); testOutputHelper.WriteLine("FileSize: " + output.AsString.Length + " bytes"); testOutputHelper.WriteLine(output.AsString); var deserializer = new JsonDeserializer(_mappingRegistry, _typeCreator); var result = new ComplexModel(); deserializer.DeserializeInto(output, result); SerializationTestHelper.AssertPopulatedData(model, result); }
public void should_correctly_serialize_nulled_data_into_existing_object_with_binary() { var model = SerializationTestHelper.GenerateNulledModel(); var serializer = new BinarySerializer(_mappingRegistry); var output = serializer.Serialize(model); _outputHelper.WriteLine("FileSize: " + output.AsBytes.Length + " bytes"); _outputHelper.WriteLine(BitConverter.ToString(output.AsBytes)); var deserializer = new BinaryDeserializer(_mappingRegistry, _typeCreator); var result = new ComplexModel(); deserializer.DeserializeInto(output, result); SerializationTestHelper.AssertNulledData(model, result); }
public void TestComplexModelWithUniqueIdentityReferenceAttributeShouldSucceed() { var model = new ComplexModel { Identities = new List <string> { "1", "2", "3" }, Identity = "0", Inner = new ComplexModel { Identities = new List <string> { "1.1", "1.2", "1.3" }, Identity = "0.0", OtherProperty = "innerothers", Inner = new ComplexModel { Identities = new List <string> { "1.1.1", "1.1.2" }, Identity = "0.0.0", OtherProperty = "innersinner" } }, OtherProperty = "others", InnerModels = new List <InnerModel> { new InnerModel { Identity = "2.1", CrefType = TestCrefType.Cref }, new InnerModel { Identity = "2.2", CrefType = TestCrefType.Href } } }; var context = Handle(model); Assert.Equal(12, context.LinkToUids.Count); Assert.Equal(new List <string> { "0", "1", "2", "3", "2.2", "0.0", "1.1", "1.2", "1.3", "0.0.0", "1.1.1", "1.1.2" }, context.LinkToUids); }
public void RazorEngineService_CanRenderWithInclude_WithCustomModel_WithNullAndDynamic() { RunTestHelper(service => { const string child = "<div>Content from child for @(Model == null ? \"\" : Model.Forename)</div>"; const string template = "@Include(\"Child\", @Model.Subject)"; const string expected = "<div>Content from child for </div>"; var model = new ComplexModel(); //model.Subject = new Person() { Forename = "" }; service.Compile(child, "Child", null); string result = service.RunCompile(template, "parent", typeof(ComplexModel), model); Assert.AreEqual(expected, result); }, config => config.AllowMissingPropertiesOnDynamic = true); }
public LightProcessor(Game game, List<Light> lights, Color ambientLight) : base(game) { Lights = lights; AmbientLight = ambientLight; // Ajout des dépendances Inputs.Add("Normal", null); Inputs.Add("Depth", null); Inputs.Add("Color", null); // Création des textures Light et Specular Outputs.Add("Light", new RenderTarget2D(Game.GraphicsDevice, Width, Height, false, SurfaceFormat.Color, DepthFormat.None, 0, RenderTargetUsage.PreserveContents)); // Chargement des shaders pointLightEffect = Game.Content.Load<Effect>("Shaders/Lighting/PointLight"); spotLightEffect = Game.Content.Load<Effect>("Shaders/Lighting/SpotLight"); directionalLightEffect = Game.Content.Load<Effect>("Shaders/Lighting/DirectionalLight"); // Chargement des models sphere = new ComplexModel(Game, "Models/LowSphere", Vector3.Zero, Vector3.Zero, Vector3.Zero, Materials.Default); cone = new ComplexModel(Game, "Models/LowCone", Vector3.Zero, Vector3.Zero, Vector3.Zero, Materials.Default); }