Created
June 6, 2014 21:08
-
-
Save alexsandro-xpt/05337641bf1b18c006aa to your computer and use it in GitHub Desktop.
Demo Builder em https://nfe.visualstudio.com/DefaultCollection/Nfe/_versionControl#path=%24%2FNfe%2FNfe%2FNfeXml%2FCpf.cs&_a=contents
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Text.RegularExpressions; | |
namespace NfeXml | |
{ | |
/// <summary> | |
/// Usando como CPF do emitente da NF de produtor (v2.0) | |
/// E tambem usando como Número do CPF do emitente. CPF do transportador. | |
/// </summary> | |
public class Cpf : XmlBuilder, IDocumentoPessoa | |
{ | |
/// <summary> | |
/// Usando como CPF do emitente da NF de produtor (v2.0) | |
/// E tambem usando como Número do CPF do emitente. CPF do transportador. | |
/// </summary> | |
/// <param name="cpf"></param> | |
public Cpf(string cpf) | |
: base("CPF") | |
{ | |
cpf = cpf.Replace(".", string.Empty).Replace("-", string.Empty); | |
if (!Regex.IsMatch(cpf, "^[0-9]{11}$")) | |
{ | |
throw new ArgumentException(String.Format("O CPF fornecido ({0}) não passa na validação esperada ([0-9]{{11}}).", cpf)); | |
} | |
AdicionarAoCorpo(cpf); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment