/// <summary>
        /// Parses HealthRecordInfo member data from the specified XPathNavigator.
        /// </summary>
        /// 
        /// <param name="navigator">
        /// The XML containing the record information.
        /// </param>
        /// 
        internal override void ParseXml(XPathNavigator navigator)
        {
            base.ParseXml(navigator);

            _custodian = XPathHelper.ParseAttributeAsBoolean(navigator, "record-custodian", false);

            long? relationshipNumber = null;

            relationshipNumber = XPathHelper.ParseAttributeAsLong(navigator, "rel-type", 0);
            if (relationshipNumber.HasValue &&
               (relationshipNumber <= (int)RelationshipType.Daughter))
            {
                _relationshipType = (RelationshipType)relationshipNumber;
            }

            _relationshipName = navigator.GetAttribute("rel-name", String.Empty);

            _dateAuthorizationExpires = XPathHelper.ParseAttributeAsDateTime(navigator, "auth-expires", DateTime.MinValue);

            _authExpired = XPathHelper.ParseAttributeAsBoolean(navigator, "auth-expired", false);

            _name = navigator.Value;

            _displayName = navigator.GetAttribute("display-name", String.Empty);

            _state = XPathHelper.ParseAttributeAsEnum<HealthRecordState>(navigator, "state", HealthRecordState.Unknown);
            if (_state > HealthRecordState.Deleted)
            {
                _state = HealthRecordState.Unknown;
            }

            _dateCreated = XPathHelper.ParseAttributeAsDateTime(navigator, "date-created", DateTime.MinValue);

            _quotaInBytes = XPathHelper.ParseAttributeAsLong(navigator, "max-size-bytes", null);
            _quotaUsedInBytes = XPathHelper.ParseAttributeAsLong(navigator, "size-bytes", null);

            _authorizationStatus = XPathHelper.ParseAttributeAsEnum<HealthRecordAuthorizationStatus>(
                    navigator,
                    "app-record-auth-action",
                    HealthRecordAuthorizationStatus.Unknown);

            _applicationSpecificRecordId = navigator.GetAttribute("app-specific-record-id", String.Empty);

            _updated = true;
        }
Exemplo n.º 2
0
        internal void WriteXml(string nodeName, XmlWriter writer)
        {
            writer.WriteStartElement(nodeName);

            writer.WriteAttributeString("id", Id.ToString());

            if (Location != null)
            {
                writer.WriteAttributeString("location-country", Location.Country);
                if (!string.IsNullOrEmpty(Location.StateProvince))
                {
                    writer.WriteAttributeString("location-state-province", Location.StateProvince);
                }
            }

            writer.WriteAttributeString(
                "record-custodian",
                XmlConvert.ToString(_custodian));

            writer.WriteAttributeString(
                "rel-type",
                XmlConvert.ToString((int)_relationshipType));

            if (!string.IsNullOrEmpty(_relationshipName))
            {
                writer.WriteAttributeString(
                    "rel-name",
                    _relationshipName);
            }

            writer.WriteAttributeString(
                "auth-expires",
                DateAuthorizationExpires == null ? "9999-12-31T23:59:59.999Z" : SDKHelper.XmlFromInstant(DateAuthorizationExpires.Value));

            writer.WriteAttributeString(
                "auth-expired",
                SDKHelper.XmlFromBool(_authExpired));

            if (!string.IsNullOrEmpty(_displayName))
            {
                writer.WriteAttributeString(
                    "display-name",
                    _displayName);
            }

            writer.WriteAttributeString(
                "state",
                State.ToString());

            writer.WriteAttributeString(
                "date-created",
                SDKHelper.XmlFromInstant(DateCreated));

            if (QuotaInBytes.HasValue)
            {
                writer.WriteAttributeString(
                    "max-size-bytes",
                    XmlConvert.ToString(QuotaInBytes.Value));
            }

            if (QuotaUsedInBytes.HasValue)
            {
                writer.WriteAttributeString(
                    "size-bytes",
                    XmlConvert.ToString(QuotaUsedInBytes.Value));
            }

            writer.WriteAttributeString(
                "app-record-auth-action",
                HealthRecordAuthorizationStatus.ToString());

            writer.WriteAttributeString(
                "app-specific-record-id",
                ApplicationSpecificRecordId);

            writer.WriteAttributeString(
                "date-updated",
                SDKHelper.XmlFromInstant(DateUpdated));

            writer.WriteValue(_name);

            writer.WriteEndElement();
        }