Skip to content

Commit 2ce5f1c

Browse files
committed
Encapsuladas regras para limpeza de certificado
1 parent 3cebcae commit 2ce5f1c

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

MDFe.Utils/Configuracoes/MDFeConfiguracao.cs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ public X509Certificate2 X509Certificate2
117117
{
118118
get
119119
{
120-
if (_certificado != null)
121-
if (!ConfiguracaoCertificado.ManterDadosEmCache)
122-
_certificado.Reset();
120+
if (_certificado != null && !DeveManterCertificadoEmCache())
121+
_certificado.Reset();
122+
123123
_certificado = ObterCertificado();
124124
return _certificado;
125125
}
@@ -190,15 +190,20 @@ public void Dispose()
190190

191191
private void LimparCertificado()
192192
{
193-
var deveManterCertificadoEmCache = _certificado == null ||
194-
ConfiguracaoCertificado == null ||
195-
ConfiguracaoCertificado.ManterDadosEmCache;
196-
197-
if (deveManterCertificadoEmCache)
193+
if (DeveManterCertificadoEmCache())
198194
return;
199195

200196
_certificado.Reset();
201197
_certificado = null;
202198
}
199+
200+
private bool DeveManterCertificadoEmCache()
201+
{
202+
var deveManterCertificadoEmCache = _certificado == null ||
203+
ConfiguracaoCertificado == null ||
204+
ConfiguracaoCertificado.ManterDadosEmCache;
205+
206+
return deveManterCertificadoEmCache;
207+
}
203208
}
204209
}

0 commit comments

Comments
 (0)