0
I have a class that inherits many interface classes, and I want to instantiate it to use only one method, how do I do? It is possible to do without passing all the necessary parameters?
public class PontoSituacaoService : IPontoSituacaoService,
IMessageHandler<DespachoCreatedEvento, bool>,
IMessageHandler<OcorrenciaAssociadaEvento, bool>,
IMessageHandler<OcorrenciaDesassociadaEvento, bool>,
IMessageHandler<PartilharOcorrenciaEvento, bool>,
IMessageHandler<GrupoDespachosCreatedEvento, bool>,
IMessageHandler<AlteracaoEstadoOcorrencia, bool>,
IMessageHandler<NotificacaoManualEvento, bool>,
IMessageHandler<OcorrenciaImportanciaModificadaEvento, bool>,
IMessageHandler<AtualizarPOSITOcorrencia112, bool>,
IMessageHandler<DanoHabitacionalCriadoEvento, bool>
{
private static readonly ILog Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private readonly IRepository<PontoSituacao> _pontoSituacaoRepository;
private readonly IRepository<SumarioPontoSituacao> _sumarioPontoSituacaoRepository;
private readonly IOcorrenciaService _ocorrenciaService;
private readonly ILookupService<TipoPontoSituacao> _tipoPontoSituacaoService;
private readonly IModuloInterfacePortal _moduloInterfacePortal;
private readonly ILookupService<TemplateNotificacaoSINOP> _templateService;
private readonly IMessageBus _bus;
public PontoSituacaoService(IRepository<PontoSituacao> pontoSituacaoRepository,
IOcorrenciaService ocorrenciaService,
ILookupService<TipoPontoSituacao> tipoPontoSituacaoService,
IMessageBus bus,
IModuloInterfacePortal moduloInterfacePortal,
IRepository<SumarioPontoSituacao> sumarioPontoSituacaoRepository,
ILookupService<TemplateNotificacaoSINOP> templateService)
{
_pontoSituacaoRepository = pontoSituacaoRepository;
_sumarioPontoSituacaoRepository = sumarioPontoSituacaoRepository;
_ocorrenciaService = ocorrenciaService;
_tipoPontoSituacaoService = tipoPontoSituacaoService;
_bus = bus;
_moduloInterfacePortal = moduloInterfacePortal;
_templateService = templateService;
}
public ActionConfirmation SaveOrUpdate(PontoSituacao pontoSituacao)
{
return SaveOrUpdate(pontoSituacao, true, false);
}
}
@ramaral conceptually gives to answer this, at this point the question is conceptual. If he has an example then it becomes more practical and can be better answered.
– Maniero
With this alone we cannot understand the whole or the difficulty of instantiation. Give more details of the problem and if possible more code that is part of the problem. Leave out all the code that doesn’t help understand the problem, but leaves out nothing that is important to understand it.
– Maniero
The problem is that when I go to instantiate the class Pontosituacaoservice pts = new Pontosituacaoservice(); he wants me to pass all the parameters, I just want to use method qlq that is below that of this constructor, got it?
– vc_89
There is no method below the constructor.
– Maniero
is a method whatever is down there, I put the Saveorupdate method for you to see, ready I want to instantiate and call it(remembering that this class has "N" other methods implemented).
– vc_89
@vc_89 This class seems to me to be made to be used with depletion injection (Ioc container), and not be instantiated in the "hand" with
new
. I think your difficulty in instantiating this class is because of this.– MurariAlex
The initial concept is that I need to save in another area(table) of my application called "Situation Point" when saved for example a form called "Population Movement" and in this form "Population Movement" the quantity field is greater than 20, so I need to use the saveorupdate function.
– vc_89
Just adding staff I declared a second empty constructor in the class I wanted to instantiate, so the parameters were optional, and it worked. Thank you all for your availability.
– vc_89