use polymorphism, or, create a generic class that can be configured according to the client.
if there are only 2 or 3 models, would use polymorphism, if there is a need to add more in the future, would use only one generic class that would have all this configuration done in database.
Ex: Polymorphism
public class Produto
{
public virtual string GetXml()
{
return "<codigo>1</codigo><descricao>Produto</descricao>";
}
}
public class ProdutoClienteA : Produto
{
public override string GetXml()
{
return "<codigoProduto>1</codigoProduto><descProduto>Produto</descProduto>";
}
}
public class WebService
{
public string GetProduto(string cliente)
{
Produto obj;
if (cliente=="A")
{
obj = new ProdutoClienteA();
}
else
{
obj = new Produto();
}
return obj.GetXml();
}
}
Remembering that it is just a simple example, there are several other features to implement, including serialization, which would generate the object xml automatically.
otherwise, would have a relationship table of the fields of products, customers, and values that should be assigned, ex.
Field, Client, new Field
code, A, code, product
code, B, code, code
then the client would enter all the configuration he needs, and when he returns to the webservice, just read this table and replace the field with the correct value. This way if a new client with a totally different configuration appears, no intervention in the program is necessary.
@Marconi is what I thought I’d do. Have the standard method and then the ones for each customer, making the-for from the customer class to the standard class. But they want to do something Generatic, and as far as I know I would not be able to do this without programming, because I have to have the class ready to generate Webservice. The idea was, customer 3 comes in, puts the structure in a text and generates the new method, but I think this is going to take longer than doing the methods as per demand.
– Tiedt Tech
@Marlon.tiedt. It clarifies a situation to do this for how many customers, I imagine it is not for many.(more than 10) So it wouldn’t be interesting to profile (add a letter to the client), it wouldn’t be easier to use and maintain.
– Luiz Vichiatto
@Luizvichiatto so far is 2 / 3 customers. But my biggest question is, to generate the Webservice for every customer I’m going to have to have the Product, Product, Productob class and so on, where I’m going to have one-to-one from the Product class to the Product class, and the implementations would always be on top of the Product class, and wanted to know if this is valid, or if there would be something more generic to make this implementation.
– Tiedt Tech
@Marconi, I think I’m going to follow the idea of having the Product class and do the de-stop, and always work with the Product. This way I imagine that I can separate a little the functionalities.
– Tiedt Tech
Okay let’s delete the comments? Sometimes someone has an answer to this question. But I believe it is broad dmais.
– Marconi
I agree with Marconi, this question, as it is formulated, is very broad, so much so that it has a flood of comments. Try to edit the question by restricting your scope a little more.
– Felipe Avelar
@Felipeavelar edited question, did it became clearer?
– Tiedt Tech
@Marconi edited question, did it get clearer?
– Tiedt Tech
@Marlon.Tiedt looked much better. These days I made a purchase in Kanui and another in Saraiva both with the same carrier. In the Webservice tracking link of them was treated one for kanui and another for Saraiva. I believe also be the best option;
– Marconi