private PostalAddressFileKey(SerializationInfo info,
                              StreamingContext context)
     : this()
 {
     UniqueDeliveryPointReferenceNumber     = AlphaDecimal.FromString(info.GetString("_urn"));
     UniqueMultipleResidenceReferenceNumber = AlphaDecimal.FromString(info.GetString("_umr"));
 }
        private static IRecord <T> ToRecord(XmlNode node)
        {
            if (null == node)
            {
                return(null);
            }

            if (null == node.Attributes)
            {
                return(null);
            }

            return(new Record <T>
            {
                Cacheability = node.Attributes["cacheability"].Value,
                Created = XmlConvert.ToDateTime(node.Attributes["created"].Value, XmlDateTimeSerializationMode.Utc),
                Etag = node.Attributes["etag"].Value,
                Expiration = node.Attributes["expiration"].Value,
                Key = AlphaDecimal.FromString(node.Attributes["key"].Value),
                Modified = XmlConvert.ToDateTime(node.Attributes["modified"].Value, XmlDateTimeSerializationMode.Utc),
                Status = XmlConvert.ToInt32(node.Attributes["status"].Value),
                Urn = node.Attributes["urn"].Value,
                Value = node.InnerXml.XmlDeserialize <T>()
            });
        }
Ejemplo n.º 3
0
 public IRecord <T> ToRecord <T>()
 {
     return(new Record <T>
     {
         Cacheability = Headers["cacheability"],
         Created = XmlConvert.ToDateTime(Headers["created"], XmlDateTimeSerializationMode.Utc),
         Etag = Headers["etag"],
         Expiration = Headers["expiration"],
         Key = AlphaDecimal.FromString(Headers["key"]),
         Modified = XmlConvert.ToDateTime(Headers["modified"], XmlDateTimeSerializationMode.Utc),
         Status = XmlConvert.ToInt32(Headers["status"]),
         Urn = Headers["urn"],
         Value = Body.XmlDeserialize <T>()
     });
 }
        private static AlphaDecimal?Token(string value)
        {
            if (string.IsNullOrWhiteSpace(value))
            {
                return(null);
            }

            if (3 > value.Length)
            {
                return(null);
            }

            if (value.Contains("="))
            {
                return(null);
            }

            if (!value.StartsWith("[", StringComparison.Ordinal))
            {
                return(null);
            }

            if (!value.EndsWith("]", StringComparison.Ordinal))
            {
                return(null);
            }

            AlphaDecimal?result = null;

            try
            {
                result = AlphaDecimal.FromString(value.Substring(1, value.Length - 2));
            }
            catch (FormatException)
            {
            }

            return(result);
        }
        public static PostalAddressFileKey FromString(string value)
        {
            if (null == value)
            {
                throw new ArgumentNullException("value");
            }

            value = value.Trim();
            if (0 == value.Length)
            {
                throw new ArgumentOutOfRangeException("value");
            }

            var parts = value.Split('·', StringSplitOptions.RemoveEmptyEntries);
            var urn   = AlphaDecimal.FromString(parts[0]);
            var umr   = 1 == parts.Length ? AlphaDecimal.Zero : AlphaDecimal.FromString(parts[1]);

            return(new PostalAddressFileKey
            {
                UniqueDeliveryPointReferenceNumber = urn,
                UniqueMultipleResidenceReferenceNumber = umr,
            });
        }