Posts by Guilherme Silva • 298 points
9 posts
-
1
votes2
answers331
viewsA: Reading HTML pages with . NET Core
I managed to solve with the following code: private string GetCodePage() { HttpClient httpClient = new HttpClient(); var response = httpClient.GetAsync(URL).Result; return…
-
4
votes2
answers331
viewsQ: Reading HTML pages with . NET Core
Next, I have a code that performs reading of a particular web page: private string GetCodePage() { WebRequest request = WebRequest.Create(URL); WebResponse response = request.GetResponse();…
-
2
votes1
answer1483
viewsQ: Create a mock for any instance of a class
How do I mock any instance of a class? I would like to do this so I don’t have to mock an object and have to put it inside a class. Example: [TestFixture] public class TokenTest { GeradorDeToken…
-
3
votes1
answer1235
viewsQ: Destruction of an instance
How do I destroy an instance? I have an object whose instance is referenced in various parts of my code. At some point I need to delete this object and for that I am doing the following: meuObjeto =…
-
2
votes2
answers247
viewsA: With resource in Java
In Java 7, ARM(Automatic Resource Management) has been implemented, which allows something very similar: try ( FileInputStream in = new FileInputStream("xanadu.txt"); FileOutputStream out = new…
javaanswered Guilherme Silva 298 -
5
votes1
answer219
viewsQ: How to simplify code with Foreach List?
How to use the ForEach() of List in the implementation below using System.Collections.Generic; public class Program { public static void Main() { List<Pessoa> pessoas = new…
-
3
votes1
answer811
viewsQ: Is it possible to return the child class through a method in the parent class?
I’m making a Builder and I’d like you to behave as follows: abstract class ClassePaiBuilder { public ClassePaiBuilder SetAtributo(string atributo) { // codigo return this; } public string Build() {…
-
8
votes1
answer89
viewsQ: How do I extract values from an Expression?
Hello. It is possible to extract from an Expression which filters, arrays, etc were used in a query? Example: public class Program { class Produto { public int Id; public string Nome; public…
-
1
votes1
answer58
viewsQ: How do I recover filters from a query?
Hello. You can find out which filters, sorters, etc were used in a query? Example: public class Program { class Produto { public int Id; public string Nome; public Produto(int id, string nome) {…