Exemplo n.º 1
0
        /// ------------------------------------------------------------------------------------
        /// <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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Reads multilingual string data from XML fragments like
 /// &lt;Description&gt;
 ///		&lt;AStr ws="en"&gt;
 ///			&lt;Run ws="en"&gt;This list contains categories.&lt;/Run&gt;
 ///		&lt;/AStr&gt;
 ///	&lt;/Description&gt;
 /// </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.
 }
Exemplo n.º 4
0
 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.
 }
Exemplo n.º 5
0
 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>());
 }
Exemplo n.º 6
0
 /// ------------------------------------------------------------------------------------
 /// <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));
 }