Exemplo n.º 1
0
        /// <summary>
        /// Parses the supplied text string into the separate components of a PEPPOL Document Identifier.
        /// </summary>
        /// <param name="documentIdAsText">textual representation of a document identifier.</param>
        /// <returns>type safe instance of DocumentTypeIdentifier</returns>
        public static PeppolDocumentTypeId ValueOf(string documentIdAsText)
        {
            if (documentIdAsText == null)
            {
                throw new ArgumentNullException(nameof(documentIdAsText), "Value 'null' is not a valid document type identifier.");
            }

            Match matcher = DocumentIdPattern.Match(documentIdAsText.Trim());

            if (matcher.Success)
            {
                string rootNameSpace         = matcher.Groups[1].Value;
                string localName             = matcher.Groups[2].Value;
                string customizationIdAsText = matcher.Groups[3].Value;
                string version = matcher.Groups[4].Value;
                CustomizationIdentifier customizationIdentifier =
                    CustomizationIdentifier.ValueOf(customizationIdAsText);
                return(new PeppolDocumentTypeId(rootNameSpace, localName, customizationIdentifier, version));
            }
            else
            {
                throw new ArgumentException(
                          $"Unable to parse '{documentIdAsText}' into PEPPOL Document Type Identifier");
            }
        }
Exemplo n.º 2
0
 public PeppolDocumentTypeId(
     string rootNameSpace,
     string localName,
     CustomizationIdentifier customizationIdentifier,
     string version)
 {
     this.RootNameSpace           = rootNameSpace;
     this.LocalName               = localName;
     this.CustomizationIdentifier = customizationIdentifier;
     this.Version = version;
 }