// --------------------------------------------------------------------------------------------- /// <summary> /// /// </summary> // --------------------------------------------------------------------------------------------- private void UpdateRenderingInfoFile() { if (m_fileAccessor != null) { m_fileAccessor.Write(DataFileAccessor.DataFileId.KeyTermRenderingInfo, XmlSerializationHelper.SerializeToString(m_keyTermRenderingInfo)); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Loads all the lexical entries from the specified service locator into a collection /// of PaLexEntry objects and returns the collection in a serialized list. /// </summary> /// ------------------------------------------------------------------------------------ internal static string GetAllAsXml(ILcmServiceLocator svcloc) { try { return(XmlSerializationHelper.SerializeToString(GetAll(svcloc))); } catch { return(null); } }
public void WriteBookSpecificData <T>(BookSpecificDataFileId fileId, string bookId, T data) { var serializedData = XmlSerializationHelper.SerializeToString( CheckDataIsXmlSerializable(data), Encoding.UTF8); if (serializedData == null) { throw new SerializationException($"An error occurred serializing {bookId} data for {fileId}."); } WriteBookSpecificData(fileId, bookId, serializedData); }
public void SerializeDeserialize_ObjectIsSound_RoundtripDataRemainsTheSame() { Sound sound = new Sound(); var before = sound.Clone(); var xmlString = XmlSerializationHelper.SerializeToString(sound); AssertThatXmlIn.String(xmlString).HasSpecifiedNumberOfMatchesForXpath("/Sound", 1); var after = XmlSerializationHelper.DeserializeFromString <Sound>(xmlString); Assert.AreEqual(before, after); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Loads all the writing systems from the specified service locator into a /// collection of PaWritingSystem objects. /// </summary> /// ------------------------------------------------------------------------------------ internal static string GetWritingSystemsAsXml(IFdoServiceLocator svcloc) { var wsList = new List <PaWritingSystem>(); foreach (var ws in svcloc.WritingSystems.AllWritingSystems) { if (!wsList.Any(w => w.Id == ws.Id)) { bool isVern = (svcloc.WritingSystems.VernacularWritingSystems.Contains(ws)); bool isAnal = (svcloc.WritingSystems.AnalysisWritingSystems.Contains(ws)); wsList.Add(new PaWritingSystem(ws, svcloc, isVern, isAnal)); } } return(XmlSerializationHelper.SerializeToString(wsList)); }
public void Serialize() { HashSet <RelatedCharacters> set = new HashSet <RelatedCharacters>(); set.Add(new RelatedCharacters { CharacterIds = new List <string> { "David", "David (old)" }, RelationshipType = CharacterRelationshipType.SameCharacterWithMultipleAges }); var serializedString = XmlSerializationHelper.SerializeToString(set); Assert.AreNotEqual(-1, serializedString.IndexOf("<RelatedCharacters RelationshipType=\"SameCharacterWithMultipleAges\">")); Assert.AreNotEqual(-1, serializedString.IndexOf("<CharacterId>David</CharacterId>")); Assert.AreNotEqual(-1, serializedString.IndexOf("<CharacterId>David (old)</CharacterId>")); }
/// ------------------------------------------------------------------------------------ private void SetGridSettings(SettingsPropertyValue propVal, XmlNode propNode) { var gridSettings = propVal.PropertyValue as GridSettings; if (gridSettings == null) { return; } propNode.RemoveAll(); var attrib = m_settingsXml.CreateAttribute("type"); attrib.Value = typeof(GridSettings).FullName; propNode.Attributes.Append(attrib); propNode.InnerXml = (XmlSerializationHelper.SerializeToString(gridSettings, true) ?? string.Empty); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Called after data has been determined to be dirty, verified and OK is clicked or /// the user has confirmed saving the changes. /// </summary> /// <returns>False if closing the form should be canceled. Otherwise, true.</returns> /// ------------------------------------------------------------------------------------ protected override bool SaveChanges() { RenumberArticulators(); m_symbols.AddRange(m_nonEditableSymbols); m_symbols = m_symbols.OrderBy(x => x.Decimal).ToList(); var xml = XmlSerializationHelper.SerializeToString(m_symbols, true); var newSymbols = XElement.Parse(xml); newSymbols.Name = "symbols"; var element = XElement.Load(m_xmlFilePath); element.Element("symbols").ReplaceWith(newSymbols); element.Save(m_xmlFilePath); return(true); }
public new string GetAsXml() { return(XmlSerializationHelper.SerializeToString(this)); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Gets a string respresentation of the settings (suitable for passing to LoadFromString). /// </summary> /// ------------------------------------------------------------------------------------ public override string ToString() { return(XmlSerializationHelper.SerializeToString(this)); }
public void Write <T>(DataFileId fileId, T data) => Write(fileId, XmlSerializationHelper.SerializeToString(CheckDataIsXmlSerializable(data), Encoding.UTF8));
public string GetAsXml(bool includeXmlDeclaration = true) { return(XmlSerializationHelper.SerializeToString(this, !includeXmlDeclaration)); }