public RecurrenceRule Parse(string recurrenceData) { var recurrenceXml = new XmlDocument(); try { recurrenceXml.LoadXml(recurrenceData); } catch (Exception ex) { SPLog.SiteSettingsInvalidXML(ex, String.Format("An exception of type {0} occurred while parsing recurrenceData in XML format for a recurrence rule. The exception message is: {1}", ex.GetType().Name, ex.Message)); } var recurrenceRules = new RecurrenceRulePool(); return(recurrenceRules.FromXml(recurrenceXml)); }
public static bool TryParse(string xml, out SPProfileSyncProvider spProfileSyncSettings) { var doc = new XmlDocument(); XmlNode xmlNode = null; try { doc.LoadXml(xml); var profileSyncXml = doc[ProfileSyncElement]; if (profileSyncXml != null) { xmlNode = profileSyncXml.FirstChild; } } catch (Exception ex) { SPLog.SiteSettingsInvalidXML(ex, String.Format("An exception of type {0} occurred while parsing XML for a profile sync settings. The exception message is: {1}", ex.GetType().Name, ex.Message)); } return(TryParse(xmlNode, out spProfileSyncSettings)); }
public SPProfileSyncProviderList(String xml) : this() { if (String.IsNullOrEmpty(xml)) { return; } var doc = new XmlDocument(); try { doc.LoadXml(xml); if (!doc.HasChildNodes) { return; } XmlNode spProfileSyncSettingsListXml = doc[SPProfileSyncSettingsElement]; if (spProfileSyncSettingsListXml == null) { return; } foreach (XmlNode spProfileSyncSettingsXml in spProfileSyncSettingsListXml.ChildNodes) { SPProfileSyncProvider settings; if (SPProfileSyncProvider.TryParse(spProfileSyncSettingsXml, out settings)) { settingsCollection.Add(settings); } } } catch (Exception ex) { SPLog.SiteSettingsInvalidXML(ex, String.Format("An exception of type {0} occurred while parsing XML node for a profile sync settings list. The exception message is: {1}", ex.GetType().Name, ex.Message)); } }
public static bool TryParse(XmlNode xmlNode, out SPProfileSyncProvider spProfileSyncSettings) { spProfileSyncSettings = new SPProfileSyncProvider(); if (xmlNode == null || xmlNode.Attributes == null || xmlNode.Attributes.Count == 0 || xmlNode[SPUserElement] == null) { return(false); } XmlNode userNode = xmlNode[SPUserElement]; if (userNode == null) { return(false); } XmlNode siteUrlNode = xmlNode[SPSiteUrlElement]; if (siteUrlNode == null) { return(false); } // try to get id int id; if (xmlNode.Attributes[IdAttr] != null && int.TryParse(xmlNode.Attributes[IdAttr].Value, out id)) { nextId = Math.Max(nextId, id + 1); try { spProfileSyncSettings = new SPProfileSyncProvider { Id = id, SPSiteURL = HttpUtility.UrlDecode(siteUrlNode.InnerText), SPUserIdFieldName = userNode.Attributes != null && userNode.Attributes[SPUserIdAttr] != null ? userNode.Attributes[SPUserIdAttr].Value : String.Empty, SPUserEmailFieldName = userNode.Attributes != null && userNode.Attributes[SPUserEmailAttr] != null ? userNode.Attributes[SPUserEmailAttr].Value : String.Empty, SPFarmUserEmailFieldName = userNode.Attributes != null && userNode.Attributes[SPFarmUserEmailAttr] != null ? userNode.Attributes[SPFarmUserEmailAttr].Value : String.Empty }; var authXml = xmlNode[AuthenticationElement]; if (authXml != null) { spProfileSyncSettings.Authentication = AuthenticationHelper.FromQueryString(authXml.InnerText); } var xmlConfig = xmlNode["config"]; if (xmlConfig != null) { spProfileSyncSettings.SyncConfig = Deserialize <SPBaseConfig>(xmlConfig.InnerXml); } return(true); } catch (Exception ex) { SPLog.SiteSettingsInvalidXML(ex, String.Format("An exception of type {0} occurred while parsing XML node for a profile sync settings. The exception message is: {1}", ex.GetType().Name, ex.Message)); return(false); } } return(false); }