Esempio n. 1
0
        private DFeSerializer <T> GetSerializer <T>() where T : class
        {
            var serializer = DFeSerializer.CreateSerializer <T>();

            serializer.Options.RemoverAcentos = Configuracoes.RemoverAcentos;
            return(serializer);
        }
Esempio n. 2
0
        public static CFe Load(Stream stream, Encoding encoding = null)
        {
            var serializer = DFeSerializer.CreateSerializer <CFe>();

            if (encoding != null)
            {
                serializer.Options.Encoder = encoding;
            }
            return(serializer.Deserialize(stream));
        }
Esempio n. 3
0
        public static SatRede Load(string path, Encoding encoding = null)
        {
            var serializer = DFeSerializer.CreateSerializer <SatRede>();

            if (encoding != null)
            {
                serializer.Options.Encoder = encoding;
            }
            return(serializer.Deserialize(path));
        }
        /// <summary>
        /// Carrega a assinatura do Xml.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <returns>DFeSignature.</returns>
        protected DFeSignature LoadSignature(XElement element)
        {
            if (element == null)
            {
                return(new DFeSignature());
            }

            var serializer = DFeSerializer.CreateSerializer <DFeSignature>();

            return(serializer.Deserialize(element.ToString()));
        }
        /// <summary>
        /// Retornar o XML da assinatura ou nulo caso não tenha nada.
        /// </summary>
        /// <param name="signature">The signature.</param>
        /// <returns>XElement.</returns>
        protected XElement WriteSignature(DFeSignature signature)
        {
            if (signature.SignatureValue.IsEmpty() || signature.SignedInfo.Reference.DigestValue.IsEmpty() ||
                signature.KeyInfo.X509Data.X509Certificate.IsEmpty())
            {
                return(null);
            }

            var ms         = new MemoryStream();
            var serializer = DFeSerializer.CreateSerializer <DFeSignature>();

            if (!serializer.Serialize(signature, ms))
            {
                return(null);
            }

            return(XElement.Load(ms));
        }
Esempio n. 6
0
        /// <summary>
        /// Loads the c fe.
        /// </summary>
        /// <param name="stream">The stream.</param>
        /// <returns>CFe.</returns>
        public static CFeCanc Load(Stream stream, Encoding encoding = null)
        {
            var serializer = DFeSerializer.CreateSerializer <CFeCanc>();

            return(serializer.Deserialize(stream));
        }
Esempio n. 7
0
        /// <summary>
        /// Loads the c fe.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <returns>CFe.</returns>
        public static CFeCanc Load(string path, Encoding encoding = null)
        {
            var serializer = DFeSerializer.CreateSerializer <CFeCanc>();

            return(serializer.Deserialize(path));
        }