/// ------------------------------------------------------------------------------------ /// <summary> /// Gets the TsString that this instance wraps. /// </summary> /// <param name="ws">The WS to force the TsString to use.</param> /// <param name="writingSystemFactory">The writing system factory which will be used to /// add missing writing systems.</param> /// <returns>A TsString object</returns> /// ------------------------------------------------------------------------------------ public ITsString GetTsStringUsingWs(int ws, ILgWritingSystemFactory writingSystemFactory) { ITsString tss = TsStringSerializer.DeserializeTsStringFromXml(m_Xml, writingSystemFactory); if (tss.Length > 0) { ITsStrBldr bldr = tss.GetBldr(); bldr.SetIntPropValues(0, bldr.Length, (int)FwTextPropType.ktptWs, 0, ws); tss = bldr.GetString(); } return(tss); }
internal static int ReadAstrElementOfMultiString(XElement aStrNode, ILgWritingSystemFactory wsf, out ITsString tss) { var wsHvo = 0; var wsAttr = aStrNode.Attribute("ws"); if (wsAttr != null) { wsHvo = wsf.GetWsFromStr(wsAttr.Value); } tss = TsStringSerializer.DeserializeTsStringFromXml(aStrNode, wsf); if (wsHvo == 0) { // THIS SHOULD NEVER HAPPEN but we live in a fallen world! var ttp = tss.get_PropertiesAt(0); int nVar; wsHvo = ttp.GetIntPropValues((int)FwTextPropType.ktptWs, out nVar); } return(wsHvo); }
/// <summary> /// Reads multilingual string data from XML fragments like /// <Description> /// <AStr ws="en"> /// <Run ws="en">This list contains categories.</Run> /// </AStr> /// </Description> /// </summary> private void SetMultiStringFromXml(XmlReader xrdr, IMultiString ms) { if (xrdr.IsEmptyElement) { xrdr.Read(); return; } if (xrdr.ReadToDescendant("AStr")) { do { string sWs = xrdr.GetAttribute("ws"); string sXml = xrdr.ReadOuterXml(); int ws = m_wsf.GetWsFromStr(sWs); if (ws != 0) { ITsString tss = TsStringSerializer.DeserializeTsStringFromXml(sXml, m_wsf); ms.set_String(ws, tss); } } while (xrdr.ReadToNextSibling("AStr")); } xrdr.Read(); // read the end tag. }
private void SetMultiStringFromXml(XmlReader xrdr, IMultiString ms) { if (xrdr.IsEmptyElement) { xrdr.Read(); return; } if (xrdr.ReadToDescendant("AStr")) { do { string sWs = xrdr.GetAttribute("ws"); string sXml = xrdr.ReadOuterXml(); if (sWs == "en") { continue; // don't overwrite the English string } int ws = GetWsFromStr(sWs); ITsString tss = TsStringSerializer.DeserializeTsStringFromXml(sXml, m_wsf); ms.set_String(ws, tss); } while (xrdr.ReadToNextSibling("AStr")); } xrdr.Read(); // read the end tag. }
public void Setup() { m_tss = TsStringSerializer.DeserializeTsStringFromXml("<AStr ws='en-US'><Run ws='en-US'>English</Run><Run ws='fr'>french</Run><Run ws='en-US'>English</Run></AStr>", Cache.ServiceLocator.GetInstance <IWritingSystemManager>()); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Gets the TsString that this instance wraps. /// </summary> /// <param name="writingSystemFactory">The writing system factory which will be used to /// add missing writing systems.</param> /// <returns>A TsString object</returns> /// ------------------------------------------------------------------------------------ public ITsString GetTsString(ILgWritingSystemFactory writingSystemFactory) { return(TsStringSerializer.DeserializeTsStringFromXml(m_Xml, writingSystemFactory)); }