0
I would like to create an interface (called Interfacex)
interface InterfaceX
{
...
}
Where your future implementation returns the following structure:
ClasseDaInterfaceX.ClasseA.Metodo1daClasseA(parametro);
ClasseDaInterfaceX.ClasseA.Metodo2daClasseA(parametro);
ClasseDaInterfaceX.ClasseB.Metodo1daClasseB(parametro);
...
That is, the result would be a class with two nested classes. However, that the methods of the Classea and Classeb classes also need to be implemented.
Follow the concrete example:
Imagine a system you can use as a "database," anything. In a certain place I can use SQL Server. Some other Firebird place. In another I can use a webservice or even a text files!
The implementation of this DLL will depend on the conditions I will find in the place using the system.
So I need to create an interface with all the routines, their inputs and their returns, so that future Dlls can implement it, thus following the contract.
However, imagine that this system can have hundreds of methods of accessing the database.
Imagine an interface with 250 methods, for example. In my view, it’s bizarre.
So I thought: is there a way for me to organize this interface with "subclasses" or with "subinterfaces".
It would be something like the example below:
interface IDatabase
{
interface ClienteDB
{
public bool Create(Cliente);
public Cliente Read();
public Cliente Update();
public bool Delete();
}
interface FornecedorDB
{
public bool Create(Fornecedor);
public Fornecedor Read();
public Fornecedor Update();
public bool Delete();
}
...
}
With this, it would have a well defined and relatively organized contract, which would force the implementation of the DLL following the same organization.
And access to methods would look like this:
Database.Clientes.Create(...);
Is there any way to create an interface like this in C#?
Explain this better, make a more concrete example.
– Maniero
I reinforce the comment of Maniero, without explaining better has no way to help.
– Jéf Bueno
I will edit the question with a concrete example.
– AlexQL
What you want, if you know what I mean, it doesn’t make sense. If you don’t want to do something bizarre, don’t do it, it’s not the code, it’s the wrong idea. It seems like you’re trying to reinvent the Entity Framework the wrong way.
– Maniero
I don’t know how flexible the Entity Framework is. There are people who still use systems in Clipper, for example. Will the EF access . dbf, binary files, etc? Entity I can use in a specific DLL implementation, to map tables, etc.
– AlexQL