/// <summary> /// Populates this <see cref="AssociatedTypeInfo"/> instance from the data in the specified XML. /// </summary> /// /// <param name="navigator"> /// The XML to get the AssociatedTypeInfo data from. /// </param> /// /// <exception cref="ArgumentNullException"> /// If <paramref name="navigator"/> parameter is <b>null</b>. /// </exception> /// public override void ParseXml(XPathNavigator navigator) { if (navigator == null) { throw new ArgumentNullException( nameof(navigator), Resources.ParseXmlNavNull); } Guid?thingTypeVersionId = XPathHelper.GetOptNavValueAsGuid(navigator, "thing-type-version-id"); Validator.ThrowInvalidIfNull(thingTypeVersionId, Resources.AssociatedThingTypeVersionIdNullorEmpty); if (thingTypeVersionId.Equals(Guid.Empty)) { throw new InvalidOperationException(Resources.AssociatedThingTypeVersionIdNullorEmpty); } thingTypeVersionId = thingTypeVersionId.Value; _thingTypeValueXPath = XPathHelper.GetOptNavValue(navigator, "thing-type-value-xpath"); _thingTypeDisplayXPath = XPathHelper.GetOptNavValue(navigator, "thing-type-display-xpath"); }
/// <summary> /// Creates an ApplicationInfo instance from the XML info section. /// </summary> /// /// <param name="app"> /// The navigator. /// </param> /// /// <returns> /// A fully constructed ApplicationInfo object. /// </returns> /// internal static ApplicationInfo CreateFromInfoXml(XPathNavigator app) { ApplicationInfo appInfo = new ApplicationInfo { Id = new Guid(app.SelectSingleNode("id").Value) }; appInfo.CultureSpecificNames.PopulateFromXml(app, "name"); if (app.SelectSingleNode("restrict-app-users").ValueAsBoolean) { appInfo.SetApplicationOptions(ApplicationOptions.RestrictApplicationUsers); } if (app.SelectSingleNode("is-published").ValueAsBoolean) { appInfo.SetApplicationOptions(ApplicationOptions.PublishApplication); } string actionUrl = XPathHelper.GetOptNavValue(app, "action-url"); if (!string.IsNullOrEmpty(actionUrl)) { appInfo.ActionUrl = new Uri(actionUrl); } appInfo.CultureSpecificDescriptions.PopulateFromXml(app, "description"); appInfo.CultureSpecificAuthorizationReasons.PopulateFromXml(app, "auth-reason"); appInfo.DomainName = XPathHelper.GetOptNavValue(app, "domain-name"); appInfo.LargeLogo = ApplicationBinaryConfiguration.CreateFromXml( app, "large-logo", "logo", "content-type"); appInfo.SmallLogo = ApplicationBinaryConfiguration.CreateFromXml( app, "small-logo", "logo", "content-type"); XPathNavigator persistentTokensNav = app.SelectSingleNode("persistent-tokens"); if (persistentTokensNav != null) { bool persistentTokensEnabled = persistentTokensNav.SelectSingleNode("enabled") .ValueAsBoolean; if (persistentTokensEnabled) { appInfo.SetApplicationOptions(ApplicationOptions.PersistentTokensAllowed); XPathNavigator tokensTtlSecondsNav = persistentTokensNav.SelectSingleNode( "token-ttl-seconds"); if (tokensTtlSecondsNav != null) { appInfo.PersistentTokenTtlInSeconds = tokensTtlSecondsNav.ValueAsInt; } } } appInfo.OnlineBaseAuthorizations = AuthorizationRule.CreateFromXml( app.SelectSingleNode("person-online-base-auth-xml")); XPathNavigator personOfflineBaseAuthNav = app.SelectSingleNode("person-offline-base-auth-xml"); if (personOfflineBaseAuthNav != null) { appInfo.OfflineBaseAuthorizations = AuthorizationRule.CreateFromXml( personOfflineBaseAuthNav); } appInfo.PrivacyStatement = ApplicationBinaryConfiguration.CreateFromXml( app, "privacy-statement", "statement", "content-type"); appInfo.TermsOfUse = ApplicationBinaryConfiguration.CreateFromXml( app, "terms-of-use", "statement", "content-type"); appInfo.DtcSuccessMessage = ApplicationBinaryConfiguration.CreateFromXml( app, "dtc-success-message", "statement", "content-type"); XPathNavigator attributesNav = app.SelectSingleNode("app-attributes"); if (attributesNav != null) { XPathNodeIterator attributesIterator = attributesNav.Select("app-attribute"); foreach (XPathNavigator attributeNav in attributesIterator) { appInfo.ApplicationAttributes.Add(attributeNav.Value); } } XPathNavigator ipPrefixesNav = app.SelectSingleNode("valid-ip-prefixes"); if (ipPrefixesNav != null) { appInfo.ValidIPPrefixes = ipPrefixesNav.Value; } appInfo.ClientServiceToken = XPathHelper.GetOptNavValueAsGuid(app, "client-service-token"); XPathNavigator vocabularyAuthorizationsNav = app.SelectSingleNode("vocabulary-authorizations"); if (vocabularyAuthorizationsNav != null) { appInfo.VocabularyAuthorizations = VocabularyAuthorization.CreateFromXml(vocabularyAuthorizationsNav); } XPathNavigator childVocabularyAuthCeilingNav = app.SelectSingleNode("child-vocabulary-authorizations-ceiling"); if (childVocabularyAuthCeilingNav != null) { appInfo.ChildVocabularyAuthorizationsCeiling = VocabularyAuthorization.CreateFromXml(vocabularyAuthorizationsNav); } XPathNavigator supportedRecordLocationsIterator = app.SelectSingleNode("supported-record-locations"); if (supportedRecordLocationsIterator != null) { LocationCollection locationCollection = new LocationCollection(); locationCollection.ParseXml(supportedRecordLocationsIterator); appInfo.SupportedRecordLocations = locationCollection; } foreach (XPathNavigator instanceIdNav in app.Select("supported-instances/instance-id")) { appInfo.SupportedHealthVaultInstances.Add(instanceIdNav.Value); } XPathNavigator instancesNode = app.SelectSingleNode("supported-instances"); string supportAllInstancesString = instancesNode?.GetAttribute("support-all-instances", string.Empty); if (!string.IsNullOrEmpty(supportAllInstancesString)) { appInfo.SupportAllHealthVaultInstances = XmlConvert.ToBoolean(supportAllInstancesString); } foreach (XPathNavigator meaningfulUseSourceNav in app.Select("meaningful-use-sources/source")) { appInfo.MeaningfulUseSources.Add(meaningfulUseSourceNav.Value); } XPathNavigator bulkExtractionSettingsNav = app.SelectSingleNode("bulk-extraction-settings"); if (bulkExtractionSettingsNav != null) { XPathNavigator isOnboardedNav = bulkExtractionSettingsNav.SelectSingleNode("is-onboarded"); if (isOnboardedNav != null) { appInfo.IsOnboardedToBdp = isOnboardedNav.ValueAsBoolean; } XPathNavigator isPermissionRequired = bulkExtractionSettingsNav.SelectSingleNode("is-permission-required"); if (isPermissionRequired != null) { appInfo.IsBulkExtractionPermissionRequired = isPermissionRequired.ValueAsBoolean; } } return(appInfo); }