Class Converter
Classe para conversão de objetos
Inherited Members
Namespace: Unimake.Business.DFe.Utility
Assembly: Unimake.Business.DFe.dll
Syntax
public static class Converter
Methods
Base64ToPDF(string, string)
Escreve uma string base64 em um arquivo PDF.
A string já deve ser um PDF válido. Este método apenas escreve o arquivo
Declaration
public static void Base64ToPDF(string content, string path)
Parameters
| Type | Name | Description |
|---|---|---|
| string | content | Conteúdo que será escrito no arquivo |
| string | path | Pasta e nome do arquivo onde deve ser gravado o PDF |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Se o |
| ArgumentException | Se o |
CalculateSHA1Hash(string)
Calcula o hash SHA-1 de uma entrada e retorna o resultado em formato Base64.
Declaration
public static string CalculateSHA1Hash(string input)
Parameters
| Type | Name | Description |
|---|---|---|
| string | input | A string de entrada para a qual o hash SHA-1 será calculado. |
Returns
| Type | Description |
|---|---|
| string | O hash SHA-1 calculado em formato Base64. |
IsSHA1Base64(string)
Verifica se uma string está no formato Base64 de um hash SHA-1.
Declaration
public static bool IsSHA1Base64(string input)
Parameters
| Type | Name | Description |
|---|---|---|
| string | input | A string a ser verificada. |
Returns
| Type | Description |
|---|---|
| bool | True se a string estiver no formato de hash SHA-1 em Base64, False caso contrário. |
IsSHA1Hash(string)
Verifica se uma string está no formato hexadecimal de um hash SHA-1.
Declaration
public static bool IsSHA1Hash(string input)
Parameters
| Type | Name | Description |
|---|---|---|
| string | input | A string a ser verificada. |
Returns
| Type | Description |
|---|---|
| bool | True se a string estiver no formato de hash SHA-1, False caso contrário. |
StringToStreamUTF8(string)
Converter string para MemoryStream com UTF8 Encoding
Declaration
public static MemoryStream StringToStreamUTF8(string contentConvert)
Parameters
| Type | Name | Description |
|---|---|---|
| string | contentConvert | Conteúdo a ser convertido |
Returns
| Type | Description |
|---|---|
| MemoryStream | Conteúdo convertido para MemoryStrem com UTF8 Encoding |
ToAny(object, Type)
Converter tipo de um objeto
Declaration
public static object ToAny(object value, Type expectedType)
Parameters
| Type | Name | Description |
|---|---|---|
| object | value | Conteúdo do objeto a ser convertido |
| Type | expectedType | Para qual tipo converter o conteúdo do objeto |
Returns
| Type | Description |
|---|---|
| object | Conteúdo do objeto convertido para o tipo informado |
ToAny<T>(object)
Tenta converter qualquer objeto passado em value para o tipo esperado em T
Declaration
public static T ToAny<T>(object value)
Parameters
| Type | Name | Description |
|---|---|---|
| object | value | Valor que deverá ser convertido |
Returns
| Type | Description |
|---|---|
| T | Value convertido em T |
Type Parameters
| Name | Description |
|---|---|
| T | Tipo esperado para conversão |
ToDouble(object)
Converte um valor do objeto em double
Declaration
public static double ToDouble(object value)
Parameters
| Type | Name | Description |
|---|---|---|
| object | value | valor a ser convertido |
Returns
| Type | Description |
|---|---|
| double | Valor convertido para double |
ToEnum<T>(string)
Converter STRING para ENUM
Declaration
public static T ToEnum<T>(this string value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | value | String a ser convertida |
Returns
| Type | Description |
|---|---|
| T | Retorna o Enum da string passada como parâmetro |
Type Parameters
| Name | Description |
|---|---|
| T | Tipo do objeto |
ToHexadecimal(string)
Calcular o valor hexadecimal de uma string
Declaration
public static string ToHexadecimal(string input)
Parameters
| Type | Name | Description |
|---|---|---|
| string | input | Valor a ser convertido |
Returns
| Type | Description |
|---|---|
| string | Valor convertido em hexadecimal |
ToRSASHA1(X509Certificate2, string)
Criptografa uma string com RSA-SHA1 e retorna o conteúdo convertido para Base64String
Declaration
public static string ToRSASHA1(X509Certificate2 certificado, string value)
Parameters
| Type | Name | Description |
|---|---|---|
| X509Certificate2 | certificado | certificado utilizado na criptografia |
| string | value | Conteúdo a ser criptografado |
Returns
| Type | Description |
|---|---|
| string | Retorna a string assinada com RSA SHA1 e convertida para Base64String |
ToSHA1HashData(string)
Converte conteúdo para HSA1HashData
Declaration
public static string ToSHA1HashData(string data)
Parameters
| Type | Name | Description |
|---|---|---|
| string | data | Conteúdo a ser convertido |
Returns
| Type | Description |
|---|---|
| string | Conteúdo convertido para SH1HashData |
ToSHA1HashData(string, bool)
Converte conteúdo para HSA1HashData
Declaration
public static string ToSHA1HashData(string data, bool toUpper)
Parameters
| Type | Name | Description |
|---|---|---|
| string | data | Conteúdo a ser convertido |
| bool | toUpper | Resultado todo em maiúsculo? |
Returns
| Type | Description |
|---|---|
| string | Conteúdo convertido para SH1HashData |